chiark / gitweb /
console: rework automatic getty on kernel console logic again
[elogind.git] / src / main.c
index 54fc0540ac92ed148e2fcd530b8d0de5d1196893..53a455b5059fb3413ab9767a373b58379e487a1e 100644 (file)
@@ -64,9 +64,9 @@ static int arg_crash_chvt = -1;
 static bool arg_confirm_spawn = false;
 static bool arg_show_status = true;
 static bool arg_sysv_console = true;
-static bool arg_mount_on_plug = true;
-static bool arg_swap_on_plug = true;
 static bool arg_mount_auto = true;
+static bool arg_swap_auto = true;
+static char *arg_console = NULL;
 
 static FILE* serialization = NULL;
 
@@ -336,6 +336,26 @@ static int parse_proc_cmdline_word(const char *word) {
                          "systemd.log_color=0|1                    Highlight important log messages\n"
                          "systemd.log_location=0|1                 Include code location in log messages\n");
 
+        } else if (startswith(word, "console=")) {
+                const char *k;
+                size_t l;
+                char *w = NULL;
+
+                k = word + 8;
+                l = strcspn(k, ",");
+
+                /* Ignore the console setting if set to a VT */
+                if (l < 4 ||
+                    !startswith(k, "tty") ||
+                    k[3+strspn(k+3, "0123456789")] != 0) {
+
+                        if (!(w = strndup(k, l)))
+                                return -ENOMEM;
+                }
+
+                free(arg_console);
+                arg_console = w;
+
         } else if (streq(word, "quiet")) {
                 arg_show_status = false;
                 arg_sysv_console = false;
@@ -485,9 +505,8 @@ static int parse_config_file(void) {
                 { "SysVConsole", config_parse_bool,         &arg_sysv_console,  "Manager" },
                 { "CrashChVT",   config_parse_int,          &arg_crash_chvt,    "Manager" },
                 { "CPUAffinity", config_parse_cpu_affinity, NULL,               "Manager" },
-                { "MountOnPlug", config_parse_bool,         &arg_mount_on_plug, "Manager" },
-                { "SwapOnPlug",  config_parse_bool,         &arg_swap_on_plug,  "Manager" },
                 { "MountAuto",   config_parse_bool,         &arg_mount_auto,    "Manager" },
+                { "SwapAuto",    config_parse_bool,         &arg_swap_auto,     "Manager" },
                 { NULL, NULL, NULL, NULL }
         };
 
@@ -992,9 +1011,11 @@ int main(int argc, char *argv[]) {
         m->confirm_spawn = arg_confirm_spawn;
         m->show_status = arg_show_status;
         m->sysv_console = arg_sysv_console;
-        m->mount_on_plug = arg_mount_on_plug;
-        m->swap_on_plug = arg_swap_on_plug;
         m->mount_auto = arg_mount_auto;
+        m->swap_auto = arg_swap_auto;
+
+        if (arg_console)
+                manager_set_console(m, arg_console);
 
         if ((r = manager_startup(m, serialization, fds)) < 0)
                 log_error("Failed to fully start up daemon: %s", strerror(-r));
@@ -1093,9 +1114,12 @@ finish:
                 manager_free(m);
 
         free(arg_default_unit);
+        free(arg_console);
 
         dbus_shutdown();
 
+        label_finish();
+
         if (reexecute) {
                 const char *args[15];
                 unsigned i = 0;
@@ -1160,7 +1184,5 @@ finish:
         if (getpid() == 1)
                 freeze();
 
-        label_finish();
-
         return retval;
 }