X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fmain.c;h=58780990c8de4a1aa105d3daff0a45f0adf431e3;hb=a5d87bf0eaf718afe62fb0b18c2f526c6e4375fc;hp=4c2be261f5130393be24cf8345ac729cdc2b1a7d;hpb=78a825f216d39ee0295b00647b059d45467e1d02;p=elogind.git diff --git a/src/core/main.c b/src/core/main.c index 4c2be261f..58780990c 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -35,14 +35,6 @@ #include "manager.h" #include "log.h" -#include "mount-setup.h" -#include "hostname-setup.h" -#include "loopback-setup.h" -#include "kmod-setup.h" -#include "locale-setup.h" -#include "selinux-setup.h" -#include "ima-setup.h" -#include "machine-id-util.h" #include "load-fragment.h" #include "fdset.h" #include "special.h" @@ -56,6 +48,16 @@ #include "virt.h" #include "watchdog.h" +#include "mount-setup.h" +#include "loopback-setup.h" +#include "kmod-setup.h" +#include "hostname-setup.h" +#include "machine-id-setup.h" +#include "locale-setup.h" +#include "hwclock.h" +#include "selinux-setup.h" +#include "ima-setup.h" + static enum { ACTION_RUN, ACTION_HELP, @@ -75,8 +77,6 @@ static bool arg_show_status = true; #ifdef HAVE_SYSV_COMPAT static bool arg_sysv_console = true; #endif -static bool arg_mount_auto = true; -static bool arg_swap_auto = true; static char **arg_default_controllers = NULL; static char ***arg_join_controllers = NULL; static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL; @@ -657,8 +657,6 @@ static int parse_config_file(void) { #endif { "Manager", "CrashChVT", config_parse_int, 0, &arg_crash_chvt }, { "Manager", "CPUAffinity", config_parse_cpu_affinity2, 0, NULL }, - { "Manager", "MountAuto", config_parse_bool, 0, &arg_mount_auto }, - { "Manager", "SwapAuto", config_parse_bool, 0, &arg_swap_auto }, { "Manager", "DefaultControllers", config_parse_strv, 0, &arg_default_controllers }, { "Manager", "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output }, { "Manager", "DefaultStandardError", config_parse_output, 0, &arg_default_std_error }, @@ -762,9 +760,9 @@ static int parse_argv(int argc, char *argv[]) { { "test", no_argument, NULL, ARG_TEST }, { "help", no_argument, NULL, 'h' }, { "dump-configuration-items", no_argument, NULL, ARG_DUMP_CONFIGURATION_ITEMS }, - { "dump-core", no_argument, NULL, ARG_DUMP_CORE }, - { "crash-shell", no_argument, NULL, ARG_CRASH_SHELL }, - { "confirm-spawn", no_argument, NULL, ARG_CONFIRM_SPAWN }, + { "dump-core", optional_argument, NULL, ARG_DUMP_CORE }, + { "crash-shell", optional_argument, NULL, ARG_CRASH_SHELL }, + { "confirm-spawn", optional_argument, NULL, ARG_CONFIRM_SPAWN }, { "show-status", optional_argument, NULL, ARG_SHOW_STATUS }, #ifdef HAVE_SYSV_COMPAT { "sysv-console", optional_argument, NULL, ARG_SYSV_CONSOLE }, @@ -873,39 +871,49 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_DUMP_CORE: - arg_dump_core = true; + r = optarg ? parse_boolean(optarg) : 1; + if (r < 0) { + log_error("Failed to parse dump core boolean %s.", optarg); + return r; + } + arg_dump_core = r; break; case ARG_CRASH_SHELL: - arg_crash_shell = true; + r = optarg ? parse_boolean(optarg) : 1; + if (r < 0) { + log_error("Failed to parse crash shell boolean %s.", optarg); + return r; + } + arg_crash_shell = r; break; case ARG_CONFIRM_SPAWN: - arg_confirm_spawn = true; + r = optarg ? parse_boolean(optarg) : 1; + if (r < 0) { + log_error("Failed to parse confirm spawn boolean %s.", optarg); + return r; + } + arg_confirm_spawn = r; break; case ARG_SHOW_STATUS: - - if (optarg) { - if ((r = parse_boolean(optarg)) < 0) { - log_error("Failed to show status boolean %s.", optarg); - return r; - } - arg_show_status = r; - } else - arg_show_status = true; + r = optarg ? parse_boolean(optarg) : 1; + if (r < 0) { + log_error("Failed to parse show status boolean %s.", optarg); + return r; + } + arg_show_status = r; break; + #ifdef HAVE_SYSV_COMPAT case ARG_SYSV_CONSOLE: - - if (optarg) { - if ((r = parse_boolean(optarg)) < 0) { - log_error("Failed to SysV console boolean %s.", optarg); - return r; - } - arg_sysv_console = r; - } else - arg_sysv_console = true; + r = optarg ? parse_boolean(optarg) : 1; + if (r < 0) { + log_error("Failed to parse SysV console boolean %s.", optarg); + return r; + } + arg_sysv_console = r; break; #endif @@ -1016,9 +1024,9 @@ static int help(void) { " --unit=UNIT Set default unit\n" " --system Run a system instance, even if PID != 1\n" " --user Run a user instance\n" - " --dump-core Dump core on crash\n" - " --crash-shell Run shell on crash\n" - " --confirm-spawn Ask for confirmation when spawning processes\n" + " --dump-core[=0|1] Dump core on crash\n" + " --crash-shell[=0|1] Run shell on crash\n" + " --confirm-spawn[=0|1] Ask for confirmation when spawning processes\n" " --show-status[=0|1] Show status updates on the console during bootup\n" #ifdef HAVE_SYSV_COMPAT " --sysv-console[=0|1] Connect output of SysV scripts to console\n" @@ -1210,7 +1218,7 @@ int main(int argc, char *argv[]) { if (getpid() == 1) { arg_running_as = MANAGER_SYSTEM; - log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_CONSOLE : LOG_TARGET_JOURNAL_OR_KMSG); + log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_JOURNAL : LOG_TARGET_JOURNAL_OR_KMSG); if (!is_reexec) { if (selinux_setup(&loaded_policy) < 0) @@ -1221,7 +1229,7 @@ int main(int argc, char *argv[]) { log_open(); - if (label_init() < 0) + if (label_init(NULL) < 0) goto finish; if (!is_reexec) @@ -1349,6 +1357,12 @@ int main(int argc, char *argv[]) { unsetenv("SHLVL"); unsetenv("_"); + /* When we are invoked by a tool chroot-like such as + * nspawn, these might be set, but make little sense + * to pass on */ + unsetenv("USER"); + unsetenv("LOGNAME"); + /* All other variables are left as is, so that clients * can still read them via /proc/1/environ */ } @@ -1420,8 +1434,6 @@ int main(int argc, char *argv[]) { #ifdef HAVE_SYSV_COMPAT m->sysv_console = arg_sysv_console; #endif - m->mount_auto = arg_mount_auto; - m->swap_auto = arg_swap_auto; m->default_std_output = arg_default_std_output; m->default_std_error = arg_default_std_error; m->runtime_watchdog = arg_runtime_watchdog;