From: Yu Watanabe Date: Fri, 17 May 2024 17:07:34 +0000 (+0900) Subject: core: refuse invalid emergency actions for SuccessAction= and friends in user service... X-Git-Tag: v256-rc3~35^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a2d9539f08fde4436048ba449d50ce75f1f0624;p=thirdparty%2Fsystemd.git core: refuse invalid emergency actions for SuccessAction= and friends in user service manager Especially, soft-reboot is not supported by user service manager. Fixes a bug in 13ffc60749df0ca7c76cfcac317b41a05679b364 and 3cf848f6cd2151ccff89073bffb102f966d64ced. --- diff --git a/man/systemd.unit.xml b/man/systemd.unit.xml index e7288e81ad2..e19e8e1c40d 100644 --- a/man/systemd.unit.xml +++ b/man/systemd.unit.xml @@ -1083,9 +1083,8 @@ , , , , , , and . In system mode, all options are - allowed. In user mode, only , , - , and are - allowed. Both options default to . + allowed. In user mode, only , , and + are allowed. Both options default to . If is set, no action will be triggered. causes a reboot following the normal shutdown procedure (i.e. equivalent to systemctl diff --git a/src/core/emergency-action.c b/src/core/emergency-action.c index 30833209666..dbda6e54573 100644 --- a/src/core/emergency-action.c +++ b/src/core/emergency-action.c @@ -14,14 +14,14 @@ static const char* const emergency_action_table[_EMERGENCY_ACTION_MAX] = { [EMERGENCY_ACTION_NONE] = "none", + [EMERGENCY_ACTION_EXIT] = "exit", + [EMERGENCY_ACTION_EXIT_FORCE] = "exit-force", [EMERGENCY_ACTION_REBOOT] = "reboot", [EMERGENCY_ACTION_REBOOT_FORCE] = "reboot-force", [EMERGENCY_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate", [EMERGENCY_ACTION_POWEROFF] = "poweroff", [EMERGENCY_ACTION_POWEROFF_FORCE] = "poweroff-force", [EMERGENCY_ACTION_POWEROFF_IMMEDIATE] = "poweroff-immediate", - [EMERGENCY_ACTION_EXIT] = "exit", - [EMERGENCY_ACTION_EXIT_FORCE] = "exit-force", [EMERGENCY_ACTION_SOFT_REBOOT] = "soft-reboot", [EMERGENCY_ACTION_SOFT_REBOOT_FORCE] = "soft-reboot-force", [EMERGENCY_ACTION_KEXEC] = "kexec", @@ -216,7 +216,7 @@ int parse_emergency_action( if (x < 0) return -EINVAL; - if (runtime_scope != RUNTIME_SCOPE_SYSTEM && x != EMERGENCY_ACTION_NONE && x < _EMERGENCY_ACTION_FIRST_USER_ACTION) + if (runtime_scope != RUNTIME_SCOPE_SYSTEM && x > _EMERGENCY_ACTION_LAST_USER_ACTION) return -EOPNOTSUPP; *ret = x; diff --git a/src/core/emergency-action.h b/src/core/emergency-action.h index 33e0ec6ffc5..6bec47511d6 100644 --- a/src/core/emergency-action.h +++ b/src/core/emergency-action.h @@ -7,15 +7,15 @@ typedef enum EmergencyAction { EMERGENCY_ACTION_NONE, + EMERGENCY_ACTION_EXIT, + EMERGENCY_ACTION_EXIT_FORCE, + _EMERGENCY_ACTION_LAST_USER_ACTION = EMERGENCY_ACTION_EXIT_FORCE, EMERGENCY_ACTION_REBOOT, EMERGENCY_ACTION_REBOOT_FORCE, EMERGENCY_ACTION_REBOOT_IMMEDIATE, EMERGENCY_ACTION_POWEROFF, EMERGENCY_ACTION_POWEROFF_FORCE, EMERGENCY_ACTION_POWEROFF_IMMEDIATE, - EMERGENCY_ACTION_EXIT, - _EMERGENCY_ACTION_FIRST_USER_ACTION = EMERGENCY_ACTION_EXIT, - EMERGENCY_ACTION_EXIT_FORCE, EMERGENCY_ACTION_SOFT_REBOOT, EMERGENCY_ACTION_SOFT_REBOOT_FORCE, EMERGENCY_ACTION_KEXEC,