diff options
Diffstat (limited to 'src/systemctl/systemctl-start-special.c')
-rw-r--r-- | src/systemctl/systemctl-start-special.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c index d23ce36..95cf00f 100644 --- a/src/systemctl/systemctl-start-special.c +++ b/src/systemctl/systemctl-start-special.c @@ -155,14 +155,16 @@ int verb_start_special(int argc, char *argv[], void *userdata) { return r; } - if (a == ACTION_REBOOT) { - if (arg_reboot_argument) { - r = update_reboot_parameter_and_warn(arg_reboot_argument, false); - if (r < 0) - return r; - } + if (arg_reboot_argument && IN_SET(a, ACTION_HALT, ACTION_POWEROFF, ACTION_REBOOT, ACTION_KEXEC)) { + /* If we are going through an action that involves systemd-shutdown, let's set the reboot + * parameter, even if it's not a regular reboot. After all we nowadays send the string to + * our supervisor via sd_notify() too. */ + r = update_reboot_parameter_and_warn(arg_reboot_argument, /* keep= */ false); + if (r < 0) + return r; + } - } else if (a == ACTION_KEXEC) { + if (a == ACTION_KEXEC) { r = load_kexec_kernel(); if (r < 0 && arg_force >= 1) log_notice("Failed to load kexec kernel, continuing without."); @@ -221,13 +223,19 @@ int verb_start_special(int argc, char *argv[], void *userdata) { case ACTION_HYBRID_SLEEP: case ACTION_SUSPEND_THEN_HIBERNATE: + /* For sleep operations, do not automatically fall back to low-level operation for + * errors other than logind not available. There's a high chance that logind did + * some extra sanity check and that didn't pass. */ r = logind_reboot(a); - if (r >= 0 || IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS)) + if (r >= 0 || (r != -ENOSYS && arg_force == 0)) return r; arg_no_block = true; break; + case ACTION_SLEEP: + return logind_reboot(a); + case ACTION_EXIT: /* Since exit is so close in behaviour to power-off/reboot, let's also make * it asynchronous, in order to not confuse the user needlessly with unexpected |