diff options
-rw-r--r-- | src/basic/copy.c | 6 | ||||
-rw-r--r-- | src/basic/exit-status.c | 3 | ||||
-rw-r--r-- | src/basic/fileio.c | 7 | ||||
-rw-r--r-- | src/basic/process-util.c | 52 | ||||
-rw-r--r-- | src/core/automount.c | 2 | ||||
-rw-r--r-- | src/core/service.c | 5 | ||||
-rw-r--r-- | src/network/networkd-netdev-tunnel.c | 10 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 6 | ||||
-rw-r--r-- | src/udev/udevd.c | 2 | ||||
-rw-r--r-- | tmpfiles.d/systemd.conf.m4 | 2 |
10 files changed, 71 insertions, 24 deletions
diff --git a/src/basic/copy.c b/src/basic/copy.c index 230e7e4d3f..e2d356d676 100644 --- a/src/basic/copy.c +++ b/src/basic/copy.c @@ -24,6 +24,7 @@ #include "util.h" #include "btrfs-util.h" +#include "strv.h" #include "copy.h" #define COPY_BUFFER_SIZE (16*1024) @@ -262,10 +263,13 @@ static int fd_copy_directory( (void) copy_xattr(dirfd(d), fdt); } - FOREACH_DIRENT(de, d, return -errno) { + FOREACH_DIRENT_ALL(de, d, return -errno) { struct stat buf; int q; + if (STR_IN_SET(de->d_name, ".", "..")) + continue; + if (fstatat(dirfd(d), de->d_name, &buf, AT_SYMLINK_NOFOLLOW) < 0) { r = -errno; continue; diff --git a/src/basic/exit-status.c b/src/basic/exit-status.c index 5ab36825c0..fcff753ada 100644 --- a/src/basic/exit-status.c +++ b/src/basic/exit-status.c @@ -151,6 +151,9 @@ const char* exit_status_to_string(ExitStatus status, ExitStatusLevel level) { case EXIT_BUS_ENDPOINT: return "BUS_ENDPOINT"; + + case EXIT_SMACK_PROCESS_LABEL: + return "SMACK_PROCESS_LABEL"; } } diff --git a/src/basic/fileio.c b/src/basic/fileio.c index d592bf5ac9..2216853777 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -786,7 +786,7 @@ int executable_is_script(const char *path, char **interpreter) { */ int get_status_field(const char *filename, const char *pattern, char **field) { _cleanup_free_ char *status = NULL; - char *t; + char *t, *f; size_t len; int r; @@ -820,9 +820,10 @@ int get_status_field(const char *filename, const char *pattern, char **field) { len = strcspn(t, WHITESPACE); - *field = strndup(t, len); - if (!*field) + f = strndup(t, len); + if (!f) return -ENOMEM; + *field = f; return 0; } diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 2c05f2fee4..61f188467f 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -43,7 +43,10 @@ int get_process_state(pid_t pid) { assert(pid >= 0); p = procfs_file_alloca(pid, "stat"); + r = read_one_line_file(p, &line); + if (r == -ENOENT) + return -ESRCH; if (r < 0) return r; @@ -87,8 +90,11 @@ int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char * p = procfs_file_alloca(pid, "cmdline"); f = fopen(p, "re"); - if (!f) + if (!f) { + if (errno == ENOENT) + return -ESRCH; return -errno; + } if (max_length == 0) { size_t len = 0, allocated = 0; @@ -182,8 +188,11 @@ int is_kernel_thread(pid_t pid) { p = procfs_file_alloca(pid, "cmdline"); f = fopen(p, "re"); - if (!f) + if (!f) { + if (errno == ENOENT) + return -ESRCH; return -errno; + } count = fread(&c, 1, 1, f); eof = feof(f); @@ -199,13 +208,18 @@ int is_kernel_thread(pid_t pid) { int get_process_capeff(pid_t pid, char **capeff) { const char *p; + int r; assert(capeff); assert(pid >= 0); p = procfs_file_alloca(pid, "status"); - return get_status_field(p, "\nCapEff:", capeff); + r = get_status_field(p, "\nCapEff:", capeff); + if (r == -ENOENT) + return -ESRCH; + + return r; } static int get_process_link_contents(const char *proc_file, char **name) { @@ -215,8 +229,10 @@ static int get_process_link_contents(const char *proc_file, char **name) { assert(name); r = readlink_malloc(proc_file, name); + if (r == -ENOENT) + return -ESRCH; if (r < 0) - return r == -ENOENT ? -ESRCH : r; + return r; return 0; } @@ -253,8 +269,11 @@ static int get_process_id(pid_t pid, const char *field, uid_t *uid) { p = procfs_file_alloca(pid, "status"); f = fopen(p, "re"); - if (!f) + if (!f) { + if (errno == ENOENT) + return -ESRCH; return -errno; + } FOREACH_LINE(line, f, return -errno) { char *l; @@ -316,8 +335,11 @@ int get_process_environ(pid_t pid, char **env) { p = procfs_file_alloca(pid, "environ"); f = fopen(p, "re"); - if (!f) + if (!f) { + if (errno == ENOENT) + return -ESRCH; return -errno; + } while ((c = fgetc(f)) != EOF) { if (!GREEDY_REALLOC(outcome, allocated, sz + 5)) @@ -329,10 +351,13 @@ int get_process_environ(pid_t pid, char **env) { sz += cescape_char(c, outcome + sz); } - if (sz == 0) - return -ENOENT; + if (!outcome) { + outcome = strdup(""); + if (!outcome) + return -ENOMEM; + } else + outcome[sz] = '\0'; - outcome[sz] = '\0'; *env = outcome; outcome = NULL; @@ -355,6 +380,8 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) { p = procfs_file_alloca(pid, "stat"); r = read_one_line_file(p, &line); + if (r == -ENOENT) + return -ESRCH; if (r < 0) return r; @@ -475,8 +502,11 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value) { path = procfs_file_alloca(pid, "environ"); f = fopen(path, "re"); - if (!f) + if (!f) { + if (errno == ENOENT) + return -ESRCH; return -errno; + } l = strlen(field); r = 0; @@ -535,7 +565,7 @@ bool pid_is_alive(pid_t pid) { return false; r = get_process_state(pid); - if (r == -ENOENT || r == 'Z') + if (r == -ESRCH || r == 'Z') return false; return true; diff --git a/src/core/automount.c b/src/core/automount.c index 90b331f70e..342dd8f0a9 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -672,7 +672,7 @@ static int automount_start_expire(Automount *a) { assert(a); - timeout = now(CLOCK_MONOTONIC) + MAX(a->timeout_idle_usec/10, USEC_PER_SEC); + timeout = now(CLOCK_MONOTONIC) + MAX(a->timeout_idle_usec/3, USEC_PER_SEC); if (a->expire_event_source) { r = sd_event_source_set_time(a->expire_event_source, timeout); diff --git a/src/core/service.c b/src/core/service.c index 39a2507b6f..b790ec98be 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -401,7 +401,6 @@ static int service_add_fd_store_set(Service *s, FDSet *fds) { r = service_add_fd_store(s, fd); if (r < 0) return log_unit_error_errno(UNIT(s), r, "Couldn't add fd to fd store: %m"); - if (r > 0) { log_unit_debug(UNIT(s), "Added fd to fd store."); fd = -1; @@ -576,8 +575,10 @@ static int service_add_extras(Service *s) { return r; r = unit_watch_bus_name(UNIT(s), s->bus_name); + if (r == -EEXIST) + return log_unit_error_errno(UNIT(s), r, "Two services allocated for the same bus name %s, refusing operation.", s->bus_name); if (r < 0) - return r; + return log_unit_error_errno(UNIT(s), r, "Cannot watch bus name %s: %m", s->bus_name); } if (UNIT(s)->default_dependencies) { diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c index ecf0604c4b..1af234aba3 100644 --- a/src/network/networkd-netdev-tunnel.c +++ b/src/network/networkd-netdev-tunnel.c @@ -185,6 +185,16 @@ static int netdev_ip6gre_fill_message_create(NetDev *netdev, Link *link, sd_netl if (r < 0) return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_TTL attribute: %m"); + if (t->ipv6_flowlabel != _NETDEV_IPV6_FLOWLABEL_INVALID) { + r = sd_netlink_message_append_u32(m, IFLA_GRE_FLOWINFO, t->ipv6_flowlabel); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_FLOWINFO attribute: %m"); + } + + r = sd_netlink_message_append_u32(m, IFLA_GRE_FLAGS, t->flags); + if (r < 0) + return log_netdev_error_errno(netdev, r, "Could not append IFLA_GRE_FLAGS attribute: %m"); + return r; } diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 3428109da4..65b9a5071b 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1785,15 +1785,13 @@ static int setup_pts(const char *dest) { #ifdef HAVE_SELINUX if (arg_selinux_apifs_context) (void) asprintf(&options, - "newinstance,ptmxmode=0666,mode=620,uid=" UID_FMT ",gid=" GID_FMT ",context=\"%s\"", - arg_uid_shift, + "newinstance,ptmxmode=0666,mode=620,gid=" GID_FMT ",context=\"%s\"", arg_uid_shift + TTY_GID, arg_selinux_apifs_context); else #endif (void) asprintf(&options, - "newinstance,ptmxmode=0666,mode=620,uid=" UID_FMT ",gid=" GID_FMT, - arg_uid_shift, + "newinstance,ptmxmode=0666,mode=620,gid=" GID_FMT, arg_uid_shift + TTY_GID); if (!options) diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 945845d72c..d0b8bad48e 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1436,7 +1436,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "c:de:DtN:hV", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "c:de:Dt:N:hV", options, NULL)) >= 0) { int r; switch (c) { diff --git a/tmpfiles.d/systemd.conf.m4 b/tmpfiles.d/systemd.conf.m4 index b447b01f58..d9d51af929 100644 --- a/tmpfiles.d/systemd.conf.m4 +++ b/tmpfiles.d/systemd.conf.m4 @@ -35,7 +35,7 @@ z /var/log/journal 2755 root systemd-journal - - z /var/log/journal/%m 2755 root systemd-journal - - m4_ifdef(`HAVE_ACL',`` a+ /var/log/journal/%m - - - - d:group:adm:r-x,d:group:wheel:r-x -A+ /var/log/journal/%m - - - - group:adm:r-x,group:wheel:r-x +a+ /var/log/journal/%m - - - - group:adm:r-x,group:wheel:r-x '')m4_dnl d /var/lib/systemd 0755 root root - |