main.c revision a0a3844815b0f346dba03f41245c620f432e462f
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen This file is part of systemd.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen Copyright 2010 Lennart Poettering
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen systemd is free software; you can redistribute it and/or modify it
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen under the terms of the GNU Lesser General Public License as published by
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen the Free Software Foundation; either version 2.1 of the License, or
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen (at your option) any later version.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen systemd is distributed in the hope that it will be useful, but
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen Lesser General Public License for more details.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen You should have received a copy of the GNU Lesser General Public License
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic ManagerRunningAs arg_running_as = _MANAGER_RUNNING_AS_INVALID;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_dump_core = true;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_crash_shell = false;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_confirm_spawn = false;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_show_status = true;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_sysv_console = true;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_mount_auto = true;
21d73c87b09ec2b8642424bc714ce9af3da4fc40Lennart Poetteringstatic bool arg_swap_auto = true;
21d73c87b09ec2b8642424bc714ce9af3da4fc40Lennart Poetteringstatic char **arg_default_controllers = NULL;
21d73c87b09ec2b8642424bc714ce9af3da4fc40Lennart Poetteringstatic char ***arg_join_controllers = NULL;
21d73c87b09ec2b8642424bc714ce9af3da4fc40Lennart Poetteringstatic ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
a2a416f768e2aa7db5b975cd50eb19237cac9cceLennart Poetteringstatic ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
a2a416f768e2aa7db5b975cd50eb19237cac9cceLennart Poetteringstatic usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Caught <%s>, not dumping core.", signal_to_string(sig));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* We want to wait for the core process, hence let's enable SIGCHLD */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Caught <%s>, cannot fork for core dump: %s", signal_to_string(sig), strerror(errno));
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering else if (pid == 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* Enable default signal handler for core dump */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(sigaction(sig, &sa, NULL) == 0);
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen /* Don't limit the core dump size */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* Just to be sure... */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* Raise the signal again */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_not_reached("We shouldn't be here...");
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen /* Order things nicely. */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = wait_for_terminate(pid, &status)) < 0)
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen log_error("Caught <%s>, waitpid() failed: %s", signal_to_string(sig), strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Caught <%s>, core dump failed.", signal_to_string(sig));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Caught <%s>, dumped core as pid %lu.", signal_to_string(sig), (unsigned long) pid);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_info("Executing crash shell in 10s...");
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* Let the kernel reap children for us */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering sa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT|SA_RESTART;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering assert_se(sigaction(SIGCHLD, &sa, NULL) == 0);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to fork off crash shell: %s", strerror(errno));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering else if (pid == 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((fd = acquire_terminal("/dev/console", false, true, true)) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to acquire terminal: %s", strerror(-fd));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to duplicate terminal fd: %s", strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("execl() failed: %s", strerror(errno));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_info("Successfully spawned crash shell as pid %lu.", (unsigned long) pid);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void install_crash_handler(void) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering sigaction_many(&sa, SIGNALS_CRASH_HANDLER, -1);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* If we are init, we connect stdin/stdout/stderr to /dev/null
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * and make sure we don't have a controlling tty. */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to open /dev/console: %s", strerror(-tty_fd));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* We don't want to force text mode.
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen * plymouth may be showing pictures already from initrd. */
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen log_error("Failed to reset /dev/console: %s", strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic int set_default_unit(const char *u) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (!(c = strdup(u)))
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic int parse_proc_cmdline_word(const char *word) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering static const char * const rlmap[] = {
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen else if (startswith(word, "systemd.log_target=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (log_set_target_from_string(word + 19) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse log target %s. Ignoring.", word + 19);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.log_level=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (log_set_max_level_from_string(word + 18) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse log level %s. Ignoring.", word + 18);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.log_color=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (log_show_color_from_string(word + 18) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse log color setting %s. Ignoring.", word + 18);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.log_location=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (log_show_location_from_string(word + 21) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse log location setting %s. Ignoring.", word + 21);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.dump_core=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse dump core switch %s. Ignoring.", word + 18);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.crash_shell=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse crash shell switch %s. Ignoring.", word + 20);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.confirm_spawn=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse confirm spawn switch %s. Ignoring.", word + 22);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.crash_chvt=")) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to parse crash chvt switch %s. Ignoring.", word + 19);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering } else if (startswith(word, "systemd.show_status=")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("Failed to parse show status switch %s. Ignoring.", word + 20);
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering } else if (startswith(word, "systemd.default_standard_output=")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering if ((r = exec_output_from_string(word + 32)) < 0)
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("Failed to parse default standard output switch %s. Ignoring.", word + 32);
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering } else if (startswith(word, "systemd.default_standard_error=")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering if ((r = exec_output_from_string(word + 31)) < 0)
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("Failed to parse default standard error switch %s. Ignoring.", word + 31);
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering } else if (startswith(word, "systemd.setenv=")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("unsetenv failed %s. Ignoring.", strerror(errno));
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("setenv failed %s. Ignoring.", strerror(errno));
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering } else if (startswith(word, "systemd.sysv_console=")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("Failed to parse SysV console switch %s. Ignoring.", word + 20);
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering } else if (startswith(word, "systemd.")) {
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering log_warning("Unknown kernel switch %s. Ignoring.", word);
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.unit=UNIT Default unit to start\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.dump_core=0|1 Dump core on crash\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.crash_shell=0|1 Run shell on crash\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.crash_chvt=N Change to VT #N on crash\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.confirm_spawn=0|1 Confirm every process spawn\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.show_status=0|1 Show status updates on the console during bootup\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.sysv_console=0|1 Connect output of SysV scripts to console\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.log_target=console|kmsg|journal|journal-or-kmsg|syslog|syslog-or-kmsg|null\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering " Log target\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.log_level=LEVEL Log level\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.log_color=0|1 Highlight important log messages\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.log_location=0|1 Include code location in log messages\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering "systemd.default_standard_output=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n"
8d3d7072e609ef0e0fb37e1d19a29307d58146c3Michal Schmidt " Set default log output for services\n"
8d3d7072e609ef0e0fb37e1d19a29307d58146c3Michal Schmidt "systemd.default_standard_error=null|tty|syslog|syslog+console|kmsg|kmsg+console|journal|journal+console\n"
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering " Set default log error output for services\n");
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering /* SysV compatibility */
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering for (i = 0; i < ELEMENTSOF(rlmap); i += 2)
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen unsigned ncpus = 0;
edc501d4674dadc304d45a7e1c5b69e207eb8cd4Lennart Poettering FOREACH_WORD_QUOTED(w, l, rvalue, state) {
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen if (!(t = strndup(w, l)))
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("[%s:%u] Failed to parse CPU affinity: %s", filename, line, rvalue);
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering CPU_SET_S(cpu, CPU_ALLOC_SIZE(ncpus), c);
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering if (sched_setaffinity(0, CPU_ALLOC_SIZE(ncpus), c) < 0)
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering log_warning("Failed to set CPU affinity: %m");
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poetteringstatic void strv_free_free(char ***l) {
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering for (i = l; *i; i++)
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poetteringstatic void free_join_controllers(void) {
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering unsigned n = 0;
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering FOREACH_WORD_QUOTED(w, length, rvalue, state) {
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering for (a = arg_join_controllers; *a; a++) {
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersenstatic int parse_config_file(void) {
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "Manager", "LogLevel", config_parse_level2, 0, NULL },
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "Manager", "LogTarget", config_parse_target, 0, NULL },
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "Manager", "LogColor", config_parse_color, 0, NULL },
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "Manager", "LogLocation", config_parse_location, 0, NULL },
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "Manager", "DumpCore", config_parse_bool, 0, &arg_dump_core },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "CrashShell", config_parse_bool, 0, &arg_crash_shell },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "ShowStatus", config_parse_bool, 0, &arg_show_status },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "SysVConsole", config_parse_bool, 0, &arg_sysv_console },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "CrashChVT", config_parse_int, 0, &arg_crash_chvt },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "CPUAffinity", config_parse_cpu_affinity2, 0, NULL },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "MountAuto", config_parse_bool, 0, &arg_mount_auto },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "SwapAuto", config_parse_bool, 0, &arg_swap_auto },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "DefaultControllers", config_parse_strv, 0, &arg_default_controllers },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "DefaultStandardOutput", config_parse_output, 0, &arg_default_std_output },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "DefaultStandardError", config_parse_output, 0, &arg_default_std_error },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "JoinControllers", config_parse_join_controllers, 0, &arg_join_controllers },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "RuntimeWatchdogSec", config_parse_usec, 0, &arg_runtime_watchdog },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "Manager", "ShutdownWatchdogSec", config_parse_usec, 0, &arg_shutdown_watchdog },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen const char *fn;
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek fn = arg_running_as == MANAGER_SYSTEM ? SYSTEM_CONFIG_FILE : USER_CONFIG_FILE;
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek log_warning("Failed to open configuration file '%s': %m", fn);
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek r = config_parse(fn, f, "Manager\0", config_item_table_lookup, (void*) items, false, NULL);
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek log_warning("Failed to parse configuration file: %s", strerror(-r));
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmekstatic int parse_proc_cmdline(void) {
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek /* Don't read /proc/cmdline if we are in a container, since
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek * that is only relevant for the host system */
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek if (detect_container(NULL) > 0)
4713135eae4f7b6b670a98476fe413edfa1d9f41Zbigniew Jędrzejewski-Szmek if ((r = read_one_line_file("/proc/cmdline", &line)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poetteringstatic int parse_argv(int argc, char *argv[]) {
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "log-level", required_argument, NULL, ARG_LOG_LEVEL },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "log-target", required_argument, NULL, ARG_LOG_TARGET },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "log-color", optional_argument, NULL, ARG_LOG_COLOR },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "log-location", optional_argument, NULL, ARG_LOG_LOCATION },
bda2c408f8a739c19161818bcc842107f60652a2Tom Gundersen { "unit", required_argument, NULL, ARG_UNIT },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "dump-configuration-items", no_argument, NULL, ARG_DUMP_CONFIGURATION_ITEMS },
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering { "dump-core", no_argument, NULL, ARG_DUMP_CORE },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "crash-shell", no_argument, NULL, ARG_CRASH_SHELL },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "confirm-spawn", no_argument, NULL, ARG_CONFIRM_SPAWN },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "show-status", optional_argument, NULL, ARG_SHOW_STATUS },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "sysv-console", optional_argument, NULL, ARG_SYSV_CONSOLE },
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering { "deserialize", required_argument, NULL, ARG_DESERIALIZE },
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek { "introspect", optional_argument, NULL, ARG_INTROSPECT },
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen { "default-standard-output", required_argument, NULL, ARG_DEFAULT_STD_OUTPUT, },
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen { "default-standard-error", required_argument, NULL, ARG_DEFAULT_STD_ERROR, },
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen while ((c = getopt_long(argc, argv, "hDbsz:", options, NULL)) >= 0)
822db23cfa98a9fbc48f41e11caafb6f1017e052Lennart Poettering if ((r = log_set_max_level_from_string(optarg)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to parse log level %s.", optarg);
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering if ((r = log_set_target_from_string(optarg)) < 0) {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering log_error("Failed to parse log target %s.", optarg);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = log_show_color_from_string(optarg)) < 0) {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_error("Failed to parse log color setting %s.", optarg);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = log_show_location_from_string(optarg)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to parse log location setting %s.", optarg);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = exec_output_from_string(optarg)) < 0) {
a38d99451f2bf8026ec51aee91662292e823c6a8Lennart Poettering log_error("Failed to parse default standard output setting %s.", optarg);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = exec_output_from_string(optarg)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to parse default standard error output setting %s.", optarg);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering if ((r = set_default_unit(optarg)) < 0) {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering log_error("Failed to set default unit %s: %s", optarg, strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering arg_action = ACTION_DUMP_CONFIGURATION_ITEMS;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_error("Failed to show status boolean %s.", optarg);
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_error("Failed to SysV console boolean %s.", optarg);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering if ((r = safe_atoi(optarg, &fd)) < 0 || fd < 0) {
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering log_error("Failed to parse deserialize option %s.", optarg);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to open serialization fd: %m");
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering const char * const * i = NULL;
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering for (i = bus_interface_table; *i; i += 2)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering fputs(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_error("Unknown interface %s.", optarg);
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering /* Just to eat away the sysvinit kernel
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * cmdline args without getopt() error
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * messages that we'll parse in
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * parse_proc_cmdline_word() or ignore. */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering /* Hmm, when we aren't run as init system
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * let's complain about excess arguments */
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering /* All /proc/cmdline arguments the kernel didn't
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * understand it passed to us. We're not really
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * interested in that usually since /proc/cmdline is
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * more interesting and complete. With one exception:
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * if we are run in a container /proc/cmdline is not
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering * relevant for the container, hence we rely on argv[]
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * instead. */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = parse_proc_cmdline_word(*a)) < 0)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic int help(void) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "Starts up and maintains the system or user services.\n\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " -h --help Show this help\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --test Determine startup sequence, dump it and exit\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --dump-configuration-items Dump understood unit configuration items\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --introspect[=INTERFACE] Extract D-Bus interface data\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --unit=UNIT Set default unit\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --system Run a system instance, even if PID != 1\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --user Run a user instance\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --dump-core Dump core on crash\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --crash-shell Run shell on crash\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --confirm-spawn Ask for confirmation when spawning processes\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --show-status[=0|1] Show status updates on the console during bootup\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --sysv-console[=0|1] Connect output of SysV scripts to console\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --log-target=TARGET Set log target (console, journal, syslog, kmsg, journal-or-kmsg, syslog-or-kmsg, null)\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --log-level=LEVEL Set log level (debug, info, notice, warning, err, crit, alert, emerg)\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --log-color[=0|1] Highlight important log messages\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --log-location[=0|1] Include code location in log messages\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --default-standard-output= Set default standard output for services\n"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering " --default-standard-error= Set default standard error output for services\n",
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringstatic int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds) {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering /* Make sure nothing is really destructed when we shut down */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = manager_open_serialization(m, &f)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to create serialization file: %s", strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to allocate fd set: %s", strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = manager_serialize(m, f, fds)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to serialize state: %s", strerror(-r));
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_error("Failed to rewind serialization fd: %m");
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = fd_cloexec(fileno(f), false)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to disable O_CLOEXEC for serialization: %s", strerror(-r));
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if ((r = fdset_cloexec(fds, false)) < 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_error("Failed to disable O_CLOEXEC for serialization fds: %s", strerror(-r));
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringstatic struct dual_timestamp* parse_initrd_timestamp(struct dual_timestamp *t) {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering const char *e;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering unsigned long long a, b;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic void test_mtab(void) {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering /* Check that /etc/mtab is a symlink */
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (readlink_malloc("/etc/mtab", &p) >= 0) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering b = streq(p, "/proc/self/mounts") || streq(p, "/proc/mounts");
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("/etc/mtab is not a symlink or not pointing to /proc/self/mounts. "
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "This is not supported anymore. "
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "Please make sure to replace this file by a symlink to avoid incorrect or misleading mount(8) output.");
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringstatic void test_usr(void) {
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering /* Check that /usr is not a separate fs */
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering log_warning("/usr appears to be on its own filesytem and is not already mounted. This is not a supported setup. "
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering "Some things will probably break (sometimes even silently) in mysterious ways. "
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poettering "Consult http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken for more information.");
1716f6dcf54d4c181c2e2558e3d5414f54c8d9caLennart Poetteringstatic void test_cgroups(void) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_warning("CONFIG_CGROUPS was not set when your kernel was compiled. "
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "Systems without control groups are not supported. "
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "We will now sleep for 10s, and then continue boot-up. "
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering "Expect breakage and please do not file bugs. "
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering "Instead fix your kernel and enable CONFIG_CGROUPS. "
5cb36f41f01cf4b1f4395abfffd1b33116591e58Lennart Poettering "Consult http://0pointer.de/blog/projects/cgroups-vs-cgroups.html for more information.");
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering dual_timestamp initrd_timestamp = { 0ULL, 0ULL };
2c27fbca2d88214bd305272308a370a962818f1eLennart Poettering if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering /* This is compatibility support for SysV, where
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering * calling init as a user is identical to telinit. */
2c27fbca2d88214bd305272308a370a962818f1eLennart Poettering log_error("Failed to exec " SYSTEMCTL_BINARY_PATH ": %m");
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering /* Determine if this is a reexecution or normal bootup. We do
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * the full command line parsing much later, so let's just
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * have a quick peek here. */
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering /* If we get started via the /sbin/init symlink then we are
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering called 'init'. After a subsequent reexecution we are then
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering called 'systemd'. That is confusing, hence let's call us
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering systemd right-away. */
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering log_show_color(isatty(STDERR_FILENO) > 0);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering log_set_target(detect_container(NULL) > 0 ? LOG_TARGET_JOURNAL : LOG_TARGET_JOURNAL_OR_KMSG);
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering log_error("Failed to apply local time delta, ignoring: %s", strerror(-r));
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering log_info("RTC configured in localtime, applying delta of %i minutes to system time.", min);
e1c959948c0e31d6997bcdfbabfbd077784b2baeLennart Poettering /* Initialize default unit */
e1c959948c0e31d6997bcdfbabfbd077784b2baeLennart Poettering if (set_default_unit(SPECIAL_DEFAULT_TARGET) < 0)
e1c959948c0e31d6997bcdfbabfbd077784b2baeLennart Poettering /* By default, mount "cpu" and "cpuacct" together */
e1c959948c0e31d6997bcdfbabfbd077784b2baeLennart Poettering arg_join_controllers[0] = strv_new("cpu", "cpuacct", NULL);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering /* Mount /proc, /sys and friends, so that /proc/cmdline and
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * /proc/$PID/fd is available. */
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering if (geteuid() == 0 && !getenv("SYSTEMD_SKIP_API_MOUNTS")) {
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering /* Reset all signal handlers. */
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering assert_se(reset_all_signal_handlers() == 0);
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering /* If we are init, we can block sigkill. Yay. */
eb60f9cd4e93ff5016dc1b5486fd1b7e1565fd92Lennart Poettering if (arg_action == ACTION_TEST && geteuid() == 0) {
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering log_error("Don't run test mode as root.");
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering log_error("Cannot be run in a chroot() environment.");
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering } else if (arg_action == ACTION_DUMP_CONFIGURATION_ITEMS) {
556a22945fcc88ca27ae7ecc46c9bb2727e37895Lennart Poettering assert_se(arg_action == ACTION_RUN || arg_action == ACTION_TEST);
556a22945fcc88ca27ae7ecc46c9bb2727e37895Lennart Poettering /* Close logging fds, in order not to confuse fdset below */
556a22945fcc88ca27ae7ecc46c9bb2727e37895Lennart Poettering /* Remember open file descriptors for later deserialization */
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering log_error("Failed to allocate fd set: %s", strerror(-r));
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering assert_se(fdset_remove(fds, fileno(serialization)) >= 0);
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poettering /* Set up PATH unless it is already set */
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin",
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering /* Parse the data passed to us. We leave this
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * variables set, but the manager later on will not
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * pass them on to our children. */
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering parse_initrd_timestamp(&initrd_timestamp);
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering /* Unset some environment variables passed in from the
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * kernel that don't really make sense for us. */
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering /* When we are invoked by a shell, these might be set,
ec2c5e4398f9d65e5dfe61530f2556224733d1e6Lennart Poettering * but make little sense to pass on */
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering /* When we are invoked by a tool chroot-like such as
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering * nspawn, these might be set, but make little sense
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering * to pass on */
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering /* All other variables are left as is, so that clients
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering * can still read them via /proc/1/environ */
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering /* Move out of the way, so that we won't block unmounts */
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering /* Become a session leader if we aren't one yet. */
a407657425a3e47fd2b559cd3bc800f791303f63Lennart Poettering /* Disable the umask logic */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* Make sure D-Bus doesn't fiddle with the SIGPIPE handlers */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering dbus_connection_set_change_sigpipe(FALSE);
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering /* Reset the console, but only if this is really init and we
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering * are freshly booted */
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering if (arg_running_as == MANAGER_SYSTEM && arg_action == ACTION_RUN) {
902bb5d8abb2a7d258741828d212ca549ab16950Lennart Poettering console_setup(getpid() == 1 && !is_reexec);
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering /* Open the logging devices, if possible and necessary */
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering /* Make sure we leave a core dump without panicing the
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering if (geteuid() == 0 && !getenv("SYSTEMD_SKIP_API_MOUNTS")) {
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering r = mount_cgroup_controllers(arg_join_controllers);
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering log_full(arg_running_as == MANAGER_SYSTEM ? LOG_INFO : LOG_DEBUG,
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering PACKAGE_STRING " running in %s mode. (" SYSTEMD_FEATURES "; " DISTRIBUTION ")", manager_running_as_to_string(arg_running_as));
locale_setup();
kmod_setup();
test_mtab();
test_usr();
test_cgroups();
goto finish;
#ifdef HAVE_SYSV_COMPAT
if (fds) {
if (serialization) {
goto finish;
goto finish;
goto finish;
goto finish;
goto finish;
r = manager_loop(m);
goto finish;
switch (m->exit_code) {
case MANAGER_EXIT:
goto finish;
case MANAGER_RELOAD:
r = manager_reload(m);
case MANAGER_REEXECUTE:
goto finish;
reexecute = true;
goto finish;
case MANAGER_REBOOT:
case MANAGER_POWEROFF:
case MANAGER_HALT:
case MANAGER_KEXEC: {
goto finish;
manager_free(m);
label_finish();
if (reexecute) {
if (arg_dump_core)
if (arg_crash_shell)
if (arg_confirm_spawn)
if (arg_show_status)
#ifdef HAVE_SYSV_COMPAT
if (arg_sysv_console)
watchdog_close(true);
if (serialization)
if (fds)
if (shutdown_verb) {
const char * command_line[] = {
char **env_block;
watchdog_close(false);
char_array_0(e);
watchdog_close(true);
freeze();
return retval;