chiark / gitweb /
main: fix typo in kernel cmdline parameters help
[elogind.git] / src / main.c
index 15bd2e4d1562bf14ad2089811e4845ae3ab05b41..7dad015e3034ed86ad23508d1270185b5c86162b 100644 (file)
@@ -333,7 +333,7 @@ static int parse_proc_cmdline_word(const char *word) {
 #ifdef HAVE_SYSV_COMPAT
                          "systemd.sysv_console=0|1                 Connect output of SysV scripts to console\n"
 #endif
-                         "systemd.log_target=console|kmsg|syslog|syslog-org-kmsg|null\n"
+                         "systemd.log_target=console|kmsg|syslog|syslog-or-kmsg|null\n"
                          "                                         Log target\n"
                          "systemd.log_level=LEVEL                  Log level\n"
                          "systemd.log_color=0|1                    Highlight important log messages\n"
@@ -889,6 +889,7 @@ int main(int argc, char *argv[]) {
         int r, retval = EXIT_FAILURE;
         FDSet *fds = NULL;
         bool reexecute = false;
+        const char *shutdown_verb = NULL;
 
         if (getpid() != 1 && strstr(program_invocation_short_name, "init")) {
                 /* This is compatbility support for SysV, where
@@ -972,6 +973,13 @@ int main(int argc, char *argv[]) {
                "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                arg_running_as == MANAGER_SYSTEM);
 
+        /* Unset some environment variables passed in from the kernel
+         * that don't really make sense for us. */
+        if (arg_running_as == MANAGER_SYSTEM) {
+                unsetenv("HOME");
+                unsetenv("TERM");
+        }
+
         /* Move out of the way, so that we won't block unmounts */
         assert_se(chdir("/")  == 0);
 
@@ -1127,6 +1135,23 @@ int main(int argc, char *argv[]) {
                         log_notice("Reexecuting.");
                         goto finish;
 
+                case MANAGER_REBOOT:
+                case MANAGER_POWEROFF:
+                case MANAGER_HALT:
+                case MANAGER_KEXEC: {
+                        static const char * const table[_MANAGER_EXIT_CODE_MAX] = {
+                                [MANAGER_REBOOT] = "reboot",
+                                [MANAGER_POWEROFF] = "poweroff",
+                                [MANAGER_HALT] = "halt",
+                                [MANAGER_KEXEC] = "kexec"
+                        };
+
+                        assert_se(shutdown_verb = table[m->exit_code]);
+
+                        log_notice("Shutting down.");
+                        goto finish;
+                }
+
                 default:
                         assert_not_reached("Unknown exit code.");
                 }
@@ -1206,6 +1231,17 @@ finish:
         if (fds)
                 fdset_free(fds);
 
+        if (shutdown_verb) {
+                const char * command_line[] = {
+                        SYSTEMD_SHUTDOWN_BINARY_PATH,
+                        shutdown_verb,
+                        NULL
+                };
+
+                execv(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line);
+                log_error("Failed to execute shutdown binary, freezing: %m");
+        }
+
         if (getpid() == 1)
                 freeze();