1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-28 20:25:25 +03:00

Revert "Trivial typo fixes and code refactorings (#5191)"

Let's do a merge to preserve all the commit messages.

This reverts commit 785d345145.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-02-01 10:26:50 -05:00
parent 785d345145
commit a6c5909665
9 changed files with 57 additions and 73 deletions

View File

@ -1647,7 +1647,7 @@ static EFI_STATUS image_start(EFI_HANDLE parent_image, const Config *config, con
loaded_image->LoadOptionsSize = (StrLen(loaded_image->LoadOptions)+1) * sizeof(CHAR16); loaded_image->LoadOptionsSize = (StrLen(loaded_image->LoadOptions)+1) * sizeof(CHAR16);
#ifdef SD_BOOT_LOG_TPM #ifdef SD_BOOT_LOG_TPM
/* Try to log any options to the TPM, especially to catch manually edited options */ /* Try to log any options to the TPM, escpecially to catch manually edited options */
err = tpm_log_event(SD_TPM_PCR, err = tpm_log_event(SD_TPM_PCR,
(EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions, (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
loaded_image->LoadOptionsSize, loaded_image->LoadOptions); loaded_image->LoadOptionsSize, loaded_image->LoadOptions);

View File

@ -100,7 +100,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
cmdline = line; cmdline = line;
#ifdef SD_BOOT_LOG_TPM #ifdef SD_BOOT_LOG_TPM
/* Try to log any options to the TPM, especially manually edited options */ /* Try to log any options to the TPM, escpecially manually edited options */
err = tpm_log_event(SD_TPM_PCR, err = tpm_log_event(SD_TPM_PCR,
(EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions, (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
loaded_image->LoadOptionsSize, loaded_image->LoadOptions); loaded_image->LoadOptionsSize, loaded_image->LoadOptions);

View File

@ -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 * child then writes the UID mapping, under full privileges. The parent waits for the child to finish and
* continues execution normally. */ * continues execution normally. */
if (uid != 0 && uid_is_valid(uid)) { if (uid != 0 && uid_is_valid(uid))
r = asprintf(&uid_map, asprintf(&uid_map,
"0 0 1\n" /* Map root → root */ "0 0 1\n" /* Map root → root */
UID_FMT " " UID_FMT " 1\n", /* Map $UID → $UID */ UID_FMT " " UID_FMT " 1\n", /* Map $UID → $UID */
uid, uid); uid, uid);
if (r < 0) else
return -ENOMEM;
} else {
uid_map = strdup("0 0 1\n"); /* The case where the above is the same */ uid_map = strdup("0 0 1\n"); /* The case where the above is the same */
if (!uid_map) if (!uid_map)
return -ENOMEM; return -ENOMEM;
}
if (gid != 0 && gid_is_valid(gid)) { if (gid != 0 && gid_is_valid(gid))
r = asprintf(&gid_map, asprintf(&gid_map,
"0 0 1\n" /* Map root → root */ "0 0 1\n" /* Map root → root */
GID_FMT " " GID_FMT " 1\n", /* Map $GID → $GID */ GID_FMT " " GID_FMT " 1\n", /* Map $GID → $GID */
gid, gid); gid, gid);
if (r < 0) else
return -ENOMEM;
} else {
gid_map = strdup("0 0 1\n"); /* The case where the above is the same */ gid_map = strdup("0 0 1\n"); /* The case where the above is the same */
if (!gid_map) if (!gid_map)
return -ENOMEM; return -ENOMEM;
}
/* Create a communication channel so that the parent can tell the child when it finished creating the user /* Create a communication channel so that the parent can tell the child when it finished creating the user
* namespace. */ * 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]) { int exec_context_named_iofds(Unit *unit, const ExecContext *c, const ExecParameters *p, int named_iofds[3]) {
unsigned i, targets; unsigned i, targets;
const char* stdio_fdname[3]; const char *stdio_fdname[3];
assert(c); assert(c);
assert(p); 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); stdio_fdname[i] = exec_context_fdname(c, i);
for (i = 0; i < p->n_fds && targets > 0; i++) for (i = 0; i < p->n_fds && targets > 0; i++)
if (named_iofds[STDIN_FILENO] < 0 && 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])) {
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]; named_iofds[STDIN_FILENO] = p->fds[i];
targets--; 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]; named_iofds[STDOUT_FILENO] = p->fds[i];
targets--; 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]; named_iofds[STDERR_FILENO] = p->fds[i];
targets--; targets--;
} }
return targets == 0 ? 0 : -ENOENT; return (targets == 0 ? 0 : -ENOENT);
} }
int exec_context_load_environment(Unit *unit, const ExecContext *c, char ***l) { int exec_context_load_environment(Unit *unit, const ExecContext *c, char ***l) {

View File

@ -66,26 +66,29 @@ static bool ignore_proc(pid_t pid, bool warn_rootfs) {
if (count <= 0) if (count <= 0)
return true; 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 */ * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons */
if (c != '@') if (c == '@' && warn_rootfs) {
return false;
if (warn_rootfs &&
pid_from_same_root_fs(pid) == 0) {
_cleanup_free_ char *comm = NULL; _cleanup_free_ char *comm = NULL;
r = pid_from_same_root_fs(pid);
if (r < 0)
return true;
get_process_comm(pid, &comm); get_process_comm(pid, &comm);
log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is " if (r)
"running from the root file system, and thus likely to block re-mounting of the " log_notice("Process " PID_FMT " (%s) has been marked to be excluded from killing. It is "
"root file system to read-only. Please consider moving it into an initrd file " "running from the root file system, and thus likely to block re-mounting of the "
"system instead.", pid, strna(comm)); "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) { static void wait_for_children(Set *pids, sigset_t *mask) {

View File

@ -232,7 +232,7 @@ static void timer_dump(Unit *u, FILE *f, const char *prefix) {
if (v->base == TIMER_CALENDAR) { if (v->base == TIMER_CALENDAR) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;
(void) calendar_spec_to_string(v->calendar_spec, &p); calendar_spec_to_string(v->calendar_spec, &p);
fprintf(f, fprintf(f,
"%s%s: %s\n", "%s%s: %s\n",

View File

@ -594,7 +594,7 @@ static int help(void) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
struct crypt_device *cd = NULL; struct crypt_device *cd = NULL;
int r = -EINVAL; int r;
if (argc <= 1) { if (argc <= 1) {
r = help(); r = help();
@ -603,6 +603,7 @@ int main(int argc, char *argv[]) {
if (argc < 3) { if (argc < 3) {
log_error("This program requires at least two arguments."); log_error("This program requires at least two arguments.");
r = -EINVAL;
goto finish; goto finish;
} }
@ -749,6 +750,7 @@ int main(int argc, char *argv[]) {
} else { } else {
log_error("Unknown verb %s.", argv[1]); log_error("Unknown verb %s.", argv[1]);
r = -EINVAL;
goto finish; goto finish;
} }

View File

@ -3087,18 +3087,13 @@ int journal_file_open(
} }
} }
if (fname) { if (fname)
f->path = strdup(fname); f->path = strdup(fname);
if (!f->path) { else /* If we don't know the path, fill in something explanatory and vaguely useful */
r = -ENOMEM; asprintf(&f->path, "/proc/self/%i", fd);
goto fail; if (!f->path) {
} r = -ENOMEM;
} else { goto fail;
/* If we don't know the path, fill in something explanatory and vaguely useful */
if (asprintf(&f->path, "/proc/self/%i", fd) < 0) {
r = -ENOMEM;
goto fail;
}
} }
f->chain_cache = ordered_hashmap_new(&uint64_hash_ops); f->chain_cache = ordered_hashmap_new(&uint64_hash_ops);

View File

@ -2396,9 +2396,13 @@ static int method_set_wall_message(
if (r == 0) if (r == 0)
return 1; /* Will call us back */ return 1; /* Will call us back */
r = free_and_strdup(&m->wall_message, empty_to_null(wall_message)); if (isempty(wall_message))
if (r < 0) m->wall_message = mfree(m->wall_message);
return log_oom(); else {
r = free_and_strdup(&m->wall_message, wall_message);
if (r < 0)
return log_oom();
}
m->enable_wall_messages = enable_wall_messages; m->enable_wall_messages = enable_wall_messages;

View File

@ -73,7 +73,7 @@ static void show_pid_array(
for (i = 0; i < n_pids; i++) { for (i = 0; i < n_pids; i++) {
_cleanup_free_ char *t = NULL; _cleanup_free_ char *t = NULL;
(void) get_process_cmdline(pids[i], n_columns, true, &t); get_process_cmdline(pids[i], n_columns, true, &t);
if (extra) if (extra)
printf("%s%s ", prefix, special_glyph(TRIANGULAR_BULLET)); printf("%s%s ", prefix, special_glyph(TRIANGULAR_BULLET));