diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-01 10:26:50 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-02-01 10:26:50 -0500 |
commit | a6c59096650be6653eb0b3590fb4ea3292337e6a (patch) | |
tree | 7e8d1d9ff89f50266c222e9fafd86d97a2542ce6 /src/core | |
parent | 785d345145bbd06c8f1c75c6a0b119c4e8f411db (diff) |
Revert "Trivial typo fixes and code refactorings (#5191)"
Let's do a merge to preserve all the commit messages.
This reverts commit 785d345145bbd06c8f1c75c6a0b119c4e8f411db.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/execute.c | 62 | ||||
-rw-r--r-- | src/core/killall.c | 29 | ||||
-rw-r--r-- | src/core/timer.c | 2 |
3 files changed, 38 insertions, 55 deletions
diff --git a/src/core/execute.c b/src/core/execute.c index 47cc4311c1..d0faba5a85 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1685,31 +1685,25 @@ static int setup_private_users(uid_t uid, gid_t gid) { * child then writes the UID mapping, under full privileges. The parent waits for the child to finish and * continues execution normally. */ - if (uid != 0 && uid_is_valid(uid)) { - r = asprintf(&uid_map, - "0 0 1\n" /* Map root → root */ - UID_FMT " " UID_FMT " 1\n", /* Map $UID → $UID */ - uid, uid); - if (r < 0) - return -ENOMEM; - } else { + if (uid != 0 && uid_is_valid(uid)) + asprintf(&uid_map, + "0 0 1\n" /* Map root → root */ + UID_FMT " " UID_FMT " 1\n", /* Map $UID → $UID */ + uid, uid); + else uid_map = strdup("0 0 1\n"); /* The case where the above is the same */ - if (!uid_map) - return -ENOMEM; - } + if (!uid_map) + return -ENOMEM; - if (gid != 0 && gid_is_valid(gid)) { - r = asprintf(&gid_map, - "0 0 1\n" /* Map root → root */ - GID_FMT " " GID_FMT " 1\n", /* Map $GID → $GID */ - gid, gid); - if (r < 0) - return -ENOMEM; - } else { + if (gid != 0 && gid_is_valid(gid)) + asprintf(&gid_map, + "0 0 1\n" /* Map root → root */ + GID_FMT " " GID_FMT " 1\n", /* Map $GID → $GID */ + gid, gid); + else gid_map = strdup("0 0 1\n"); /* The case where the above is the same */ - if (!gid_map) - return -ENOMEM; - } + if (!gid_map) + return -ENOMEM; /* Create a communication channel so that the parent can tell the child when it finished creating the user * namespace. */ @@ -3102,7 +3096,7 @@ const char* exec_context_fdname(const ExecContext *c, int fd_index) { int exec_context_named_iofds(Unit *unit, const ExecContext *c, const ExecParameters *p, int named_iofds[3]) { unsigned i, targets; - const char* stdio_fdname[3]; + const char *stdio_fdname[3]; assert(c); assert(p); @@ -3115,32 +3109,18 @@ int exec_context_named_iofds(Unit *unit, const ExecContext *c, const ExecParamet stdio_fdname[i] = exec_context_fdname(c, i); for (i = 0; i < p->n_fds && targets > 0; i++) - if (named_iofds[STDIN_FILENO] < 0 && - c->std_input == EXEC_INPUT_NAMED_FD && - stdio_fdname[STDIN_FILENO] && - streq(p->fd_names[i], stdio_fdname[STDIN_FILENO])) { - + if (named_iofds[STDIN_FILENO] < 0 && c->std_input == EXEC_INPUT_NAMED_FD && stdio_fdname[STDIN_FILENO] && streq(p->fd_names[i], stdio_fdname[STDIN_FILENO])) { named_iofds[STDIN_FILENO] = p->fds[i]; targets--; - - } else if (named_iofds[STDOUT_FILENO] < 0 && - c->std_output == EXEC_OUTPUT_NAMED_FD && - stdio_fdname[STDOUT_FILENO] && - streq(p->fd_names[i], stdio_fdname[STDOUT_FILENO])) { - + } else if (named_iofds[STDOUT_FILENO] < 0 && c->std_output == EXEC_OUTPUT_NAMED_FD && stdio_fdname[STDOUT_FILENO] && streq(p->fd_names[i], stdio_fdname[STDOUT_FILENO])) { named_iofds[STDOUT_FILENO] = p->fds[i]; targets--; - - } else if (named_iofds[STDERR_FILENO] < 0 && - c->std_error == EXEC_OUTPUT_NAMED_FD && - stdio_fdname[STDERR_FILENO] && - streq(p->fd_names[i], stdio_fdname[STDERR_FILENO])) { - + } else if (named_iofds[STDERR_FILENO] < 0 && c->std_error == EXEC_OUTPUT_NAMED_FD && stdio_fdname[STDERR_FILENO] && streq(p->fd_names[i], stdio_fdname[STDERR_FILENO])) { named_iofds[STDERR_FILENO] = p->fds[i]; targets--; } - return targets == 0 ? 0 : -ENOENT; + return (targets == 0 ? 0 : -ENOENT); } int exec_context_load_environment(Unit *unit, const ExecContext *c, char ***l) { diff --git a/src/core/killall.c b/src/core/killall.c index 7a9df546ee..b3aa22adc5 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -66,26 +66,29 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) { if (count <= 0) return true; - /* Processes with argv[0][0] = '@' we ignore from the killing spree. + /* Processes with argv[0][0] = '@' we ignore from the killing + * spree. * * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons */ - if (c != '@') - return false; - - if (warn_rootfs && - pid_from_same_root_fs(pid) == 0) { - + if (c == '@' && warn_rootfs) { _cleanup_free_ char *comm = NULL; + r = pid_from_same_root_fs(pid); + if (r < 0) + return true; + get_process_comm(pid, &comm); - log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is " - "running from the root file system, and thus likely to block re-mounting of the " - "root file system to read-only. Please consider moving it into an initrd file " - "system instead.", pid, strna(comm)); - } + if (r) + log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is " + "running from the root file system, and thus likely to block re-mounting of the " + "root file system to read-only. Please consider moving it into an initrd file " + "system instead.", pid, strna(comm)); + return true; + } else if (c == '@') + return true; - return true; + return false; } static void wait_for_children(Set *pids, sigset_t *mask) { diff --git a/src/core/timer.c b/src/core/timer.c index d7441d638f..5ee14669d2 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -232,7 +232,7 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) { if (v->base == TIMER_CALENDAR) { _cleanup_free_ char *p = NULL; - (void) calendar_spec_to_string(v->calendar_spec, &p); + calendar_spec_to_string(v->calendar_spec, &p); fprintf(f, "%s%s: %s\n", |