main: properly handle -b boot option

This commit is contained in:
Lennart Poettering 2011-03-10 23:01:42 +01:00
parent 90102b22ba
commit 099663ff8c
2 changed files with 25 additions and 7 deletions

8
TODO
View File

@ -20,10 +20,16 @@ F15:
* save/restore tool for SysV as requested by FPC * 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: 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 no [Install] section and stored in /lib enabled by "systemctl is-enabled"
* consider services with any kind of link in /etc/systemd/system enabled * consider services with any kind of link in /etc/systemd/system enabled

View File

@ -226,6 +226,8 @@ static int parse_proc_cmdline_word(const char *word) {
static const char * const rlmap[] = { static const char * const rlmap[] = {
"emergency", SPECIAL_EMERGENCY_TARGET, "emergency", SPECIAL_EMERGENCY_TARGET,
"-b", SPECIAL_EMERGENCY_TARGET,
"b", SPECIAL_EMERGENCY_TARGET,
"single", SPECIAL_RESCUE_TARGET, "single", SPECIAL_RESCUE_TARGET,
"-s", SPECIAL_RESCUE_TARGET, "-s", 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(argc >= 1);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "hD", options, NULL)) >= 0) while ((c = getopt_long(argc, argv, "hDbsz:", options, NULL)) >= 0)
switch (c) { switch (c) {
@ -800,19 +802,29 @@ static int parse_argv(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG); log_set_max_level(LOG_DEBUG);
break; break;
case '?': case 'b':
return -EINVAL; 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: default:
log_error("Unknown option code %c", c); if (getpid() != 1) {
return -EINVAL; log_error("Unknown option code %c", c);
return -EINVAL;
}
break;
} }
/* PID 1 will get the kernel arguments as parameters, which we /* PID 1 will get the kernel arguments as parameters, which we
* ignore and unconditionally read from * ignore and unconditionally read from
* /proc/cmdline. However, we need to ignore those arguments * /proc/cmdline. However, we need to ignore those arguments
* here. */ * here. */
if (arg_running_as != MANAGER_SYSTEM && optind < argc) { if (getpid() != 1 && optind < argc) {
log_error("Excess arguments."); log_error("Excess arguments.");
return -EINVAL; return -EINVAL;
} }