chiark / gitweb /
build-sys: detect Gentoo
[elogind.git] / main.c
diff --git a/main.c b/main.c
index 5b23c937b7386e69db20551c3942574d6b248c93..0128787d1471db38ae1c5d61d5abc0e0f55fbbdb 100644 (file)
--- a/main.c
+++ b/main.c
@@ -463,6 +463,15 @@ static int parse_argv(int argc, char *argv[]) {
                         return -EINVAL;
                 }
 
+        /* PID 1 will get the kernel arguments as parameters, which we
+         * ignore and unconditionally read from
+         * /proc/cmdline. However, we need to ignore those arguments
+         * here. */
+        if (running_as != MANAGER_INIT && optind < argc) {
+                log_error("Excess arguments.");
+                return -EINVAL;
+        }
+
         return 0;
 }
 
@@ -615,7 +624,7 @@ int main(int argc, char *argv[]) {
 
         /* Reset the console, but only if this is really init and we
          * are freshly booted */
-        if (running_as == MANAGER_INIT)
+        if (running_as == MANAGER_INIT && action == ACTION_RUN)
                 console_setup(getpid() == 1 && !serialization);
 
         /* Make sure D-Bus doesn't fiddle with the SIGPIPE handlers */