From: Lennart Poettering Date: Thu, 10 Mar 2011 22:01:42 +0000 (+0100) Subject: main: properly handle -b boot option X-Git-Tag: v21~121 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=099663ff8c117303af369a4d412dafed0c5614c2;p=systemd main: properly handle -b boot option --- diff --git a/TODO b/TODO index 93597821..f2e3be41 100644 --- a/TODO +++ b/TODO @@ -20,10 +20,16 @@ F15: * save/restore tool for SysV as requested by FPC -* optionally create watched directories in .path units +* bind mounts are ignored + +* SIGALRM in systemctl + +* 0595f9a1c182a84581749823ef47c5f292e545f9 is borked, freezes shutdown Features: +* optionally create watched directories in .path units + * consider services with no [Install] section and stored in /lib enabled by "systemctl is-enabled" * consider services with any kind of link in /etc/systemd/system enabled diff --git a/src/main.c b/src/main.c index 6d1fd7d5..5d37f804 100644 --- a/src/main.c +++ b/src/main.c @@ -226,6 +226,8 @@ static int parse_proc_cmdline_word(const char *word) { static const char * const rlmap[] = { "emergency", SPECIAL_EMERGENCY_TARGET, + "-b", SPECIAL_EMERGENCY_TARGET, + "b", SPECIAL_EMERGENCY_TARGET, "single", SPECIAL_RESCUE_TARGET, "-s", SPECIAL_RESCUE_TARGET, "s", SPECIAL_RESCUE_TARGET, @@ -624,7 +626,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 1); assert(argv); - while ((c = getopt_long(argc, argv, "hD", options, NULL)) >= 0) + while ((c = getopt_long(argc, argv, "hDbsz:", options, NULL)) >= 0) switch (c) { @@ -800,19 +802,29 @@ static int parse_argv(int argc, char *argv[]) { log_set_max_level(LOG_DEBUG); break; - case '?': - return -EINVAL; + case 'b': + case 's': + case 'z': + /* Just to eat away the sysvinit kernel + * cmdline args without getopt() error + * messages that we'll parse in + * parse_proc_cmdline_word() or ignore. */ + case '?': default: - log_error("Unknown option code %c", c); - return -EINVAL; + if (getpid() != 1) { + log_error("Unknown option code %c", c); + return -EINVAL; + } + + break; } /* 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 (arg_running_as != MANAGER_SYSTEM && optind < argc) { + if (getpid() != 1 && optind < argc) { log_error("Excess arguments."); return -EINVAL; }