From 2f66635635c12ee0246a5c4f771772ed2b71bec6 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 14 Aug 2017 09:16:15 +0200 Subject: Prep v235: Apply upstream fixes (3/10) [src/basic] --- src/basic/audit-util.c | 4 +-- src/basic/audit-util.h | 4 +++ src/basic/build.h | 7 +++++ src/basic/bus-label.h | 4 ++- src/basic/cgroup-util.c | 9 +++---- src/basic/def.h | 4 +-- src/basic/escape.c | 2 +- src/basic/fd-util.c | 2 +- src/basic/fileio.c | 20 +++++++------- src/basic/fs-util.c | 2 +- src/basic/hexdecoct.c | 2 +- src/basic/log.c | 14 +++++----- src/basic/log.h | 4 +-- src/basic/parse-util.c | 2 +- src/basic/process-util.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-- src/basic/process-util.h | 6 +++++ src/basic/socket-util.h | 21 +++++++++++++++ src/basic/string-util.c | 4 +-- src/basic/string-util.h | 7 +++++ src/basic/terminal-util.c | 2 +- src/basic/unit-name.c | 15 ----------- src/basic/unit-name.h | 17 ------------ src/basic/util.c | 2 +- src/basic/virt.c | 2 +- 24 files changed, 148 insertions(+), 74 deletions(-) (limited to 'src/basic') diff --git a/src/basic/audit-util.c b/src/basic/audit-util.c index 2b5578394..f6b448aeb 100644 --- a/src/basic/audit-util.c +++ b/src/basic/audit-util.c @@ -54,7 +54,7 @@ int audit_session_from_pid(pid_t pid, uint32_t *id) { if (r < 0) return r; - if (u == AUDIT_SESSION_INVALID || u <= 0) + if (!audit_session_is_valid(u)) return -ENODATA; *id = u; @@ -81,7 +81,7 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid) { if (r < 0) return r; - *uid = (uid_t) u; + *uid = u; return 0; } diff --git a/src/basic/audit-util.h b/src/basic/audit-util.h index b16ca585b..3e354eea7 100644 --- a/src/basic/audit-util.h +++ b/src/basic/audit-util.h @@ -31,3 +31,7 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid); #if 0 /// UNNEEDED by elogind bool use_audit(void); #endif // 0 + +static inline bool audit_session_is_valid(uint32_t id) { + return id > 0 && id != AUDIT_SESSION_INVALID; +} diff --git a/src/basic/build.h b/src/basic/build.h index 6329a8fc3..334383bdf 100644 --- a/src/basic/build.h +++ b/src/basic/build.h @@ -25,6 +25,12 @@ #define _PAM_FEATURE_ "-PAM" #endif +#ifdef HAVE_AUDIT +#define _AUDIT_FEATURE_ "+AUDIT" +#else +#define _AUDIT_FEATURE_ "-AUDIT" +#endif + #ifdef HAVE_SELINUX #define _SELINUX_FEATURE_ "+SELINUX" #else @@ -53,6 +59,7 @@ #define SYSTEMD_FEATURES \ _PAM_FEATURE_ " " \ + _AUDIT_FEATURE_ " " \ _SELINUX_FEATURE_ " " \ _SMACK_FEATURE_ " " \ _UTMP_FEATURE_ " " \ diff --git a/src/basic/bus-label.h b/src/basic/bus-label.h index 62fb2c450..600268b76 100644 --- a/src/basic/bus-label.h +++ b/src/basic/bus-label.h @@ -23,9 +23,11 @@ #include #include +#include "string-util.h" + char *bus_label_escape(const char *s); char *bus_label_unescape_n(const char *f, size_t l); static inline char *bus_label_unescape(const char *f) { - return bus_label_unescape_n(f, f ? strlen(f) : 0); + return bus_label_unescape_n(f, strlen_ptr(f)); } diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index 323c637fe..5999af3ce 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -257,7 +257,7 @@ int cg_kill( return -ENOMEM; } - my_pid = getpid(); + my_pid = getpid_cached(); do { _cleanup_fclose_ FILE *f = NULL; @@ -401,7 +401,7 @@ int cg_migrate( if (!s) return -ENOMEM; - my_pid = getpid(); + my_pid = getpid_cached(); log_debug_elogind("Migrating \"%s\"/\"%s\" to \"%s\"/\"%s\" (%s)", cfrom, pfrom, cto, pto, @@ -831,7 +831,7 @@ int cg_attach(const char *controller, const char *path, pid_t pid) { return r; if (pid == 0) - pid = getpid(); + pid = getpid_cached(); xsprintf(c, PID_FMT "\n", pid); @@ -1004,7 +1004,7 @@ int cg_get_xattr(const char *controller, const char *path, const char *name, voi int cg_pid_get_path(const char *controller, pid_t pid, char **path) { _cleanup_fclose_ FILE *f = NULL; char line[LINE_MAX]; - const char *fs, *controller_str = NULL; + const char *fs, *controller_str; size_t cs = 0; int unified; @@ -1111,7 +1111,6 @@ int cg_install_release_agent(const char *controller, const char *agent) { return r; sc = strstrip(contents); - if (isempty(sc)) { r = write_string_file(fs, agent, 0); if (r < 0) diff --git a/src/basic/def.h b/src/basic/def.h index cce32da1e..d30b4a106 100644 --- a/src/basic/def.h +++ b/src/basic/def.h @@ -69,10 +69,8 @@ #endif #define UNIX_SYSTEM_BUS_ADDRESS "unix:path=/var/run/dbus/system_bus_socket" -#define KERNEL_SYSTEM_BUS_ADDRESS "kernel:path=/sys/fs/kdbus/0-system/bus" -#define DEFAULT_SYSTEM_BUS_ADDRESS KERNEL_SYSTEM_BUS_ADDRESS ";" UNIX_SYSTEM_BUS_ADDRESS +#define DEFAULT_SYSTEM_BUS_ADDRESS UNIX_SYSTEM_BUS_ADDRESS #define UNIX_USER_BUS_ADDRESS_FMT "unix:path=%s/bus" -#define KERNEL_USER_BUS_ADDRESS_FMT "kernel:path=/sys/fs/kdbus/"UID_FMT"-user/bus" #define PLYMOUTH_SOCKET { \ .un.sun_family = AF_UNIX, \ diff --git a/src/basic/escape.c b/src/basic/escape.c index d43bdaebf..2587ca8d1 100644 --- a/src/basic/escape.c +++ b/src/basic/escape.c @@ -314,7 +314,7 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi /* Undoes C style string escaping, and optionally prefixes it. */ - pl = prefix ? strlen(prefix) : 0; + pl = strlen_ptr(prefix); r = new(char, pl+length+1); if (!r) diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 9afec9366..d12b5036b 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -283,7 +283,7 @@ int same_fd(int a, int b) { return true; /* Try to use kcmp() if we have it. */ - pid = getpid(); + pid = getpid_cached(); r = kcmp(pid, pid, KCMP_FILE, a, b); if (r == 0) return true; diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 7bafe9038..95459819a 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -825,29 +825,29 @@ static void write_env_var(FILE *f, const char *v) { p = strchr(v, '='); if (!p) { /* Fallback */ - fputs(v, f); - fputc('\n', f); + fputs_unlocked(v, f); + fputc_unlocked('\n', f); return; } p++; - fwrite(v, 1, p-v, f); + fwrite_unlocked(v, 1, p-v, f); if (string_has_cc(p, NULL) || chars_intersect(p, WHITESPACE SHELL_NEED_QUOTES)) { - fputc('\"', f); + fputc_unlocked('\"', f); for (; *p; p++) { if (strchr(SHELL_NEED_ESCAPE, *p)) - fputc('\\', f); + fputc_unlocked('\\', f); - fputc(*p, f); + fputc_unlocked(*p, f); } - fputc('\"', f); + fputc_unlocked('\"', f); } else - fputs(p, f); + fputs_unlocked(p, f); - fputc('\n', f); + fputc_unlocked('\n', f); } int write_env_file(const char *fname, char **l) { @@ -1408,7 +1408,7 @@ int open_serialization_fd(const char *ident) { if (fd < 0) { const char *path; - path = getpid() == 1 ? "/run/systemd" : "/tmp"; + path = getpid_cached() == 1 ? "/run/systemd" : "/tmp"; fd = open_tmpfile_unlinkable(path, O_RDWR|O_CLOEXEC); if (fd < 0) return fd; diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 33624354f..f7e9f329d 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -312,7 +312,7 @@ int fd_warn_permissions(const char *path, int fd) { if (st.st_mode & 0002) log_warning("Configuration file %s is marked world-writable. Please remove world writability permission bits. Proceeding anyway.", path); - if (getpid() == 1 && (st.st_mode & 0044) != 0044) + if (getpid_cached() == 1 && (st.st_mode & 0044) != 0044) log_warning("Configuration file %s is marked world-inaccessible. This has no effect as configuration data is accessible via APIs without restrictions. Proceeding anyway.", path); return 0; diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c index 2d6e377f0..db3167665 100644 --- a/src/basic/hexdecoct.c +++ b/src/basic/hexdecoct.c @@ -569,7 +569,7 @@ static int base64_append_width(char **prefix, int plen, lines = (len + width - 1) / width; - slen = sep ? strlen(sep) : 0; + slen = strlen_ptr(sep); t = realloc(*prefix, plen + 1 + slen + (indent + width + 1) * lines); if (!t) return -ENOMEM; diff --git a/src/basic/log.c b/src/basic/log.c index 3924ed71f..82db00ed2 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -86,7 +86,7 @@ void log_close_console(void) { if (console_fd < 0) return; - if (getpid() == 1) { + if (getpid_cached() == 1) { if (console_fd >= 3) safe_close(console_fd); @@ -142,7 +142,7 @@ static int create_log_socket(int type) { /* We need a blocking fd here since we'd otherwise lose messages way too early. However, let's not hang forever in the unlikely case of a deadlock. */ - if (getpid() == 1) + if (getpid_cached() == 1) timeval_store(&tv, 10 * USEC_PER_MSEC); else timeval_store(&tv, 10 * USEC_PER_SEC); @@ -254,7 +254,7 @@ int log_open(void) { } if (!IN_SET(log_target, LOG_TARGET_AUTO, LOG_TARGET_SAFE) || - getpid() == 1 || + getpid_cached() == 1 || isatty(STDERR_FILENO) <= 0) { #if 0 /// elogind does not support logging to systemd-journald @@ -382,7 +382,7 @@ static int write_to_console( if (writev(console_fd, iovec, n) < 0) { - if (errno == EIO && getpid() == 1) { + if (errno == EIO && getpid_cached() == 1) { /* If somebody tried to kick us from our * console tty (via vhangup() or suchlike), @@ -435,7 +435,7 @@ static int write_to_syslog( if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0) return -EINVAL; - xsprintf(header_pid, "["PID_FMT"]: ", getpid()); + xsprintf(header_pid, "["PID_FMT"]: ", getpid_cached()); IOVEC_SET_STRING(iovec[0], header_priority); IOVEC_SET_STRING(iovec[1], header_time); @@ -480,7 +480,7 @@ static int write_to_kmsg( return 0; xsprintf(header_priority, "<%i>", level); - xsprintf(header_pid, "["PID_FMT"]: ", getpid()); + xsprintf(header_pid, "["PID_FMT"]: ", getpid_cached()); IOVEC_SET_STRING(iovec[0], header_priority); IOVEC_SET_STRING(iovec[1], program_invocation_short_name); @@ -1211,7 +1211,7 @@ int log_syntax_internal( va_end(ap); if (unit) - unit_fmt = getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s"; + unit_fmt = getpid_cached() == 1 ? "UNIT=%s" : "USER_UNIT=%s"; return log_struct_internal( LOG_REALM_PLUS_LEVEL(LOG_REALM_SYSTEMD, level), diff --git a/src/basic/log.h b/src/basic/log.h index 9c796e9f1..d3d6e6e73 100644 --- a/src/basic/log.h +++ b/src/basic/log.h @@ -249,7 +249,7 @@ void log_assert_failed_return_realm( #define log_notice(...) log_full(LOG_NOTICE, __VA_ARGS__) #define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__) #define log_error(...) log_full(LOG_ERR, __VA_ARGS__) -#define log_emergency(...) log_full(getpid() == 1 ? LOG_EMERG : LOG_ERR, __VA_ARGS__) +#define log_emergency(...) log_full(getpid_cached() == 1 ? LOG_EMERG : LOG_ERR, __VA_ARGS__) /* Logging triggered by an errno-like error */ #define log_debug_errno(error, ...) log_full_errno(LOG_DEBUG, error, __VA_ARGS__) @@ -257,7 +257,7 @@ void log_assert_failed_return_realm( #define log_notice_errno(error, ...) log_full_errno(LOG_NOTICE, error, __VA_ARGS__) #define log_warning_errno(error, ...) log_full_errno(LOG_WARNING, error, __VA_ARGS__) #define log_error_errno(error, ...) log_full_errno(LOG_ERR, error, __VA_ARGS__) -#define log_emergency_errno(error, ...) log_full_errno(getpid() == 1 ? LOG_EMERG : LOG_ERR, error, __VA_ARGS__) +#define log_emergency_errno(error, ...) log_full_errno(getpid_cached() == 1 ? LOG_EMERG : LOG_ERR, error, __VA_ARGS__) #ifdef LOG_TRACE # define log_trace(...) log_debug(__VA_ARGS__) diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c index 011355962..f808ecb72 100644 --- a/src/basic/parse-util.c +++ b/src/basic/parse-util.c @@ -61,7 +61,7 @@ int parse_pid(const char *s, pid_t* ret_pid) { if ((unsigned long) pid != ul) return -ERANGE; - if (pid <= 0) + if (!pid_is_valid(pid)) return -ERANGE; *ret_pid = pid; diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 6e8554626..4993de886 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -850,7 +850,7 @@ bool is_main_thread(void) { static thread_local int cached = 0; if (_unlikely_(cached == 0)) - cached = getpid() == gettid() ? 1 : -1; + cached = getpid_cached() == gettid() ? 1 : -1; return cached > 0; } @@ -915,7 +915,7 @@ const char* personality_to_string(unsigned long p) { void valgrind_summary_hack(void) { #ifdef HAVE_VALGRIND_VALGRIND_H - if (getpid() == 1 && RUNNING_ON_VALGRIND) { + if (getpid_cached() == 1 && RUNNING_ON_VALGRIND) { pid_t pid; pid = raw_clone(SIGCHLD); if (pid < 0) @@ -959,6 +959,68 @@ int ioprio_parse_priority(const char *s, int *ret) { return 0; } +/* The cached PID, possible values: + * + * == UNSET [0] → cache not initialized yet + * == BUSY [-1] → some thread is initializing it at the moment + * any other → the cached PID + */ + +#define CACHED_PID_UNSET ((pid_t) 0) +#define CACHED_PID_BUSY ((pid_t) -1) + +static pid_t cached_pid = CACHED_PID_UNSET; + +static void reset_cached_pid(void) { + /* Invoked in the child after a fork(), i.e. at the first moment the PID changed */ + cached_pid = CACHED_PID_UNSET; +} + +/* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc + * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against + * libpthread, as it is part of glibc anyway. */ +extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle); +extern void* __dso_handle __attribute__ ((__weak__)); + +pid_t getpid_cached(void) { + pid_t current_value; + + /* getpid_cached() is much like getpid(), but caches the value in local memory, to avoid having to invoke a + * system call each time. This restores glibc behaviour from before 2.24, when getpid() was unconditionally + * cached. Starting with 2.24 getpid() started to become prohibitively expensive when used for detecting when + * objects were used across fork()s. With this caching the old behaviour is somewhat restored. + * + * https://bugzilla.redhat.com/show_bug.cgi?id=1443976 + * https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1d2bc2eae969543b89850e35e532f3144122d80a + */ + + current_value = __sync_val_compare_and_swap(&cached_pid, CACHED_PID_UNSET, CACHED_PID_BUSY); + + switch (current_value) { + + case CACHED_PID_UNSET: { /* Not initialized yet, then do so now */ + pid_t new_pid; + + new_pid = getpid(); + + if (__register_atfork(NULL, NULL, reset_cached_pid, __dso_handle) != 0) { + /* OOM? Let's try again later */ + cached_pid = CACHED_PID_UNSET; + return new_pid; + } + + cached_pid = new_pid; + return new_pid; + } + + case CACHED_PID_BUSY: /* Somebody else is currently initializing */ + return getpid(); + + default: /* Properly initialized */ + return current_value; + } +} + static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime", diff --git a/src/basic/process-util.h b/src/basic/process-util.h index 13888929b..fec60c4af 100644 --- a/src/basic/process-util.h +++ b/src/basic/process-util.h @@ -138,5 +138,11 @@ static inline bool ioprio_priority_is_valid(int i) { return i >= 0 && i < IOPRIO_BE_NR; } +static inline bool pid_is_valid(pid_t p) { + return p > 0; +} + int ioprio_parse_priority(const char *s, int *ret); #endif // 0 + +pid_t getpid_cached(void); diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h index db3a73197..a85045d11 100644 --- a/src/basic/socket-util.h +++ b/src/basic/socket-util.h @@ -27,9 +27,11 @@ #include #include #include +#include #include #include "macro.h" +#include "missing.h" #include "util.h" union sockaddr_union { @@ -45,6 +47,8 @@ union sockaddr_union { struct sockaddr_ll ll; struct sockaddr_vm vm; #endif // 0 + /* Ensure there is enough space to store Infiniband addresses */ + uint8_t ll_buffer[offsetof(struct sockaddr_ll, sll_addr) + CONST_MAX(ETH_ALEN, INFINIBAND_ALEN)]; }; #if 0 /// UNNEEDED by elogind @@ -158,6 +162,23 @@ int flush_accept(int fd); struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t length); #endif // 0 +/* + * Certain hardware address types (e.g Infiniband) do not fit into sll_addr + * (8 bytes) and run over the structure. This macro returns the correct size that + * must be passed to kernel. + */ +#define SOCKADDR_LL_LEN(sa) \ + ({ \ + const struct sockaddr_ll *_sa = &(sa); \ + size_t _mac_len = sizeof(_sa->sll_addr); \ + assert(_sa->sll_family == AF_PACKET); \ + if (be16toh(_sa->sll_hatype) == ARPHRD_ETHER) \ + _mac_len = MAX(_mac_len, (size_t) ETH_ALEN); \ + if (be16toh(_sa->sll_hatype) == ARPHRD_INFINIBAND) \ + _mac_len = MAX(_mac_len, (size_t) INFINIBAND_ALEN); \ + offsetof(struct sockaddr_ll, sll_addr) + _mac_len; \ + }) + /* Covers only file system and abstract AF_UNIX socket addresses, but not unnamed socket addresses. */ #define SOCKADDR_UN_LEN(sa) \ ({ \ diff --git a/src/basic/string-util.c b/src/basic/string-util.c index 5172ac775..a2569a5b0 100644 --- a/src/basic/string-util.c +++ b/src/basic/string-util.c @@ -215,7 +215,7 @@ char *strnappend(const char *s, const char *suffix, size_t b) { } char *strappend(const char *s, const char *suffix) { - return strnappend(s, suffix, suffix ? strlen(suffix) : 0); + return strnappend(s, suffix, strlen_ptr(suffix)); } char *strjoin_real(const char *x, ...) { @@ -711,7 +711,7 @@ char *strextend(char **x, ...) { assert(x); - l = f = *x ? strlen(*x) : 0; + l = f = strlen_ptr(*x); va_start(ap, x); for (;;) { diff --git a/src/basic/string-util.h b/src/basic/string-util.h index 46df7e42c..a28ef9c4f 100644 --- a/src/basic/string-util.h +++ b/src/basic/string-util.h @@ -208,3 +208,10 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(char *, string_free_erase); #define _cleanup_string_free_erase_ _cleanup_(string_free_erasep) bool string_is_safe(const char *p) _pure_; + +static inline size_t strlen_ptr(const char *s) { + if (!s) + return 0; + + return strlen(s); +} diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 6cf623d51..35c1a68df 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -1232,7 +1232,7 @@ bool colors_enabled(void) { val = getenv_bool("SYSTEMD_COLORS"); if (val >= 0) enabled = val; - else if (getpid() == 1) + else if (getpid_cached() == 1) /* PID1 outputs to the console without holding it open all the time */ enabled = !getenv_terminal_is_dumb(); else diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c index fb30c2527..5d0069c93 100644 --- a/src/basic/unit-name.c +++ b/src/basic/unit-name.c @@ -611,7 +611,6 @@ const char* unit_dbus_interface_from_type(UnitType t) { static const char *const table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "org.freedesktop.systemd1.Service", [UNIT_SOCKET] = "org.freedesktop.systemd1.Socket", - [UNIT_BUSNAME] = "org.freedesktop.systemd1.BusName", [UNIT_TARGET] = "org.freedesktop.systemd1.Target", [UNIT_DEVICE] = "org.freedesktop.systemd1.Device", [UNIT_MOUNT] = "org.freedesktop.systemd1.Mount", @@ -843,7 +842,6 @@ bool slice_name_is_valid(const char *name) { static const char* const unit_type_table[_UNIT_TYPE_MAX] = { [UNIT_SERVICE] = "service", [UNIT_SOCKET] = "socket", - [UNIT_BUSNAME] = "busname", [UNIT_TARGET] = "target", [UNIT_DEVICE] = "device", [UNIT_MOUNT] = "mount", @@ -889,19 +887,6 @@ static const char* const automount_state_table[_AUTOMOUNT_STATE_MAX] = { DEFINE_STRING_TABLE_LOOKUP(automount_state, AutomountState); -static const char* const busname_state_table[_BUSNAME_STATE_MAX] = { - [BUSNAME_DEAD] = "dead", - [BUSNAME_MAKING] = "making", - [BUSNAME_REGISTERED] = "registered", - [BUSNAME_LISTENING] = "listening", - [BUSNAME_RUNNING] = "running", - [BUSNAME_SIGTERM] = "sigterm", - [BUSNAME_SIGKILL] = "sigkill", - [BUSNAME_FAILED] = "failed", -}; - -DEFINE_STRING_TABLE_LOOKUP(busname_state, BusNameState); - static const char* const device_state_table[_DEVICE_STATE_MAX] = { [DEVICE_DEAD] = "dead", [DEVICE_TENTATIVE] = "tentative", diff --git a/src/basic/unit-name.h b/src/basic/unit-name.h index bba9a4e80..67cd64785 100644 --- a/src/basic/unit-name.h +++ b/src/basic/unit-name.h @@ -28,7 +28,6 @@ typedef enum UnitType { UNIT_SERVICE = 0, UNIT_SOCKET, - UNIT_BUSNAME, UNIT_TARGET, UNIT_DEVICE, UNIT_MOUNT, @@ -74,19 +73,6 @@ typedef enum AutomountState { _AUTOMOUNT_STATE_INVALID = -1 } AutomountState; -typedef enum BusNameState { - BUSNAME_DEAD, - BUSNAME_MAKING, - BUSNAME_REGISTERED, - BUSNAME_LISTENING, - BUSNAME_RUNNING, - BUSNAME_SIGTERM, - BUSNAME_SIGKILL, - BUSNAME_FAILED, - _BUSNAME_STATE_MAX, - _BUSNAME_STATE_INVALID = -1 -} BusNameState; - /* We simply watch devices, we cannot plug/unplug them. That * simplifies the state engine greatly */ typedef enum DeviceState { @@ -346,9 +332,6 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_; const char* automount_state_to_string(AutomountState i) _const_; AutomountState automount_state_from_string(const char *s) _pure_; -const char* busname_state_to_string(BusNameState i) _const_; -BusNameState busname_state_from_string(const char *s) _pure_; - const char* device_state_to_string(DeviceState i) _const_; DeviceState device_state_from_string(const char *s) _pure_; diff --git a/src/basic/util.c b/src/basic/util.c index cd7f0e42d..c95e17f57 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -224,7 +224,7 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa /* Spawns a temporary TTY agent, making sure it goes away when * we go away */ - parent_pid = getpid(); + parent_pid = getpid_cached(); /* First we temporarily block all signals, so that the new * child has them blocked initially. This way, we can be sure diff --git a/src/basic/virt.c b/src/basic/virt.c index a8f1652d2..36bfd2429 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -423,7 +423,7 @@ int detect_container(void) { goto finish; } - if (getpid() == 1) { + if (getpid_cached() == 1) { /* If we are PID 1 we can just check our own environment variable, and that's authoritative. */ e = getenv("container"); -- cgit v1.2.3