]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: move telinit execcing out of parse_argv()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 7 Feb 2021 16:35:06 +0000 (17:35 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 8 Feb 2021 11:17:24 +0000 (12:17 +0100)
With this change, parse_argv() does parsing, without any real actions.
Fully untested ;)

src/systemctl/systemctl-compat-telinit.c
src/systemctl/systemctl-compat-telinit.h
src/systemctl/systemctl.c
src/systemctl/systemctl.h

index f67361ea906b853222b2c6d6a4577f1b20dc2139..f0e9ca8d7948c922d53b869ffca424cb4cca98bb 100644 (file)
@@ -1,9 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <getopt.h>
+#include <unistd.h>
 
 #include "alloc-util.h"
 #include "pretty-print.h"
+#include "rlimit-util.h"
 #include "systemctl-compat-telinit.h"
 #include "systemctl-daemon-reload.h"
 #include "systemctl-start-unit.h"
@@ -150,3 +152,11 @@ int reload_with_fallback(void) {
 
         return 0;
 }
+
+int exec_telinit(char *argv[]) {
+        (void) rlimit_nofile_safe();
+        execv(TELINIT, argv);
+
+        return log_error_errno(SYNTHETIC_ERRNO(EIO),
+                               "Couldn't find an alternative telinit implementation to spawn.");
+}
index 1a2bcd440523b8068a12eae8f7302efad47b37ec..783c3878a0e1148b12e461fa8f59d2b52313bcee 100644 (file)
@@ -4,3 +4,4 @@
 int telinit_parse_argv(int argc, char *argv[]);
 int start_with_fallback(void);
 int reload_with_fallback(void);
+int exec_telinit(char *argv[]);
index f60187e43a909542467241fecf9dd2fa30e0207f..cb901881c965fa8959fe3e301c189aacfe153874 100644 (file)
@@ -973,11 +973,8 @@ static int parse_argv(int argc, char *argv[]) {
                                 /* Hmm, so some other init system is running, we need to forward this request
                                  * to it. */
 
-                                (void) rlimit_nofile_safe();
-                                execv(TELINIT, argv);
-
-                                return log_error_errno(SYNTHETIC_ERRNO(EIO),
-                                                       "Couldn't find an alternative telinit implementation to spawn.");
+                                arg_action = ACTION_TELINIT;
+                                return 1;
                         }
 
                 } else if (strstr(program_invocation_short_name, "runlevel")) {
@@ -1143,6 +1140,10 @@ static int run(int argc, char *argv[]) {
                 r = runlevel_main();
                 break;
 
+        case ACTION_TELINIT:
+                r = exec_telinit(argv);
+                break;
+
         case ACTION_EXIT:
         case ACTION_SUSPEND:
         case ACTION_HIBERNATE:
index 34650ebb4435d1bd4d58a6fc182d927f35aba334..f7ee358ce1280afe9ff595d02cb32e4b2c5e109c 100644 (file)
@@ -29,6 +29,7 @@ enum action {
         ACTION_RELOAD,
         ACTION_REEXEC,
         ACTION_RUNLEVEL,
+        ACTION_TELINIT,
         ACTION_CANCEL_SHUTDOWN,
         _ACTION_MAX,
         _ACTION_INVALID = -1