1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-24 02:03:54 +03:00

systemctl: move telinit execcing out of parse_argv()

With this change, parse_argv() does parsing, without any real actions.
Fully untested ;)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-02-07 17:35:06 +01:00
parent 54d04cd1e7
commit ea71b4604b
4 changed files with 18 additions and 5 deletions

View 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.");
}

View 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[]);

View 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:

View File

@ -29,6 +29,7 @@ enum action {
ACTION_RELOAD,
ACTION_REEXEC,
ACTION_RUNLEVEL,
ACTION_TELINIT,
ACTION_CANCEL_SHUTDOWN,
_ACTION_MAX,
_ACTION_INVALID = -1