X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmain.c;h=fb34e4d3d19982ff286541ea8e4f7d8d298e7657;hb=ea18a4b57e2bb94af7b3ecb7abdaec40e9f485f0;hp=064445d17e00f30887240c1b159af3d0fae262df;hpb=b8d0ffc21f9c237cdeef49b1873b47df1a0a1543;p=elogind.git diff --git a/src/core/main.c b/src/core/main.c index 064445d17..fb34e4d3d 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -166,7 +166,7 @@ noreturn static void crash(int sig) { else if (status.si_code != CLD_DUMPED) log_error("Caught <%s>, core dump failed.", signal_to_string(sig)); else - log_error("Caught <%s>, dumped core as pid %lu.", signal_to_string(sig), (unsigned long) pid); + log_error("Caught <%s>, dumped core as pid "PID_FMT".", signal_to_string(sig), pid); } } @@ -197,7 +197,7 @@ noreturn static void crash(int sig) { _exit(1); } - log_info("Successfully spawned crash shell as pid %lu.", (unsigned long) pid); + log_info("Successfully spawned crash shell as pid "PID_FMT".", pid); } log_info("Freezing execution."); @@ -599,17 +599,12 @@ static int config_parse_join_controllers(const char *unit, for (a = arg_join_controllers; *a; a++) { if (strv_overlap(*a, l)) { - char **c; - - c = strv_merge(*a, l); - if (!c) { + if (strv_extend_strv(&l, *a) < 0) { strv_free(l); strv_free_free(t); return log_oom(); } - strv_free(l); - l = c; } else { char **c; @@ -1480,8 +1475,11 @@ int main(int argc, char *argv[]) { if (in_initrd()) log_info("Running in initial RAM disk."); - } else - log_debug(PACKAGE_STRING " running in user mode. (" SYSTEMD_FEATURES ")"); + } else { + _cleanup_free_ char *t = uid_to_name(getuid()); + log_debug(PACKAGE_STRING " running in user mode for user "PID_FMT"/%s. (" SYSTEMD_FEATURES ")", + getuid(), t); + } if (arg_running_as == SYSTEMD_SYSTEM && !skip_setup) { if (arg_show_status || plymouth_running()) @@ -1853,10 +1851,11 @@ finish: shutdown_verb, NULL }; - char **env_block; + _cleanup_strv_free_ char **env_block = NULL; + env_block = strv_copy(environ); if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) { - char e[32]; + char *e; /* If we reboot let's set the shutdown * watchdog and tell the shutdown binary to @@ -1864,15 +1863,11 @@ finish: watchdog_set_timeout(&arg_shutdown_watchdog); watchdog_close(false); - /* Tell the binary how often to ping */ - snprintf(e, sizeof(e), "WATCHDOG_USEC=%llu", (unsigned long long) arg_shutdown_watchdog); - char_array_0(e); - - env_block = strv_append(environ, e); - } else { - env_block = strv_copy(environ); + /* Tell the binary how often to ping, ignore failure */ + if (asprintf(&e, "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog) > 0) + strv_push(&env_block, e); + } else watchdog_close(true); - } /* Avoid the creation of new processes forked by the * kernel; at this point, we will not listen to the @@ -1881,7 +1876,6 @@ finish: cg_uninstall_release_agent(SYSTEMD_CGROUP_CONTROLLER); execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block); - free(env_block); log_error("Failed to execute shutdown binary, freezing: %m"); }