From 00886e06e8dbb9449cef1f4ab1fdc53a212162f7 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Tue, 8 Feb 2022 11:23:04 +0100 Subject: [PATCH] systemctl: use action_table for scheduling shutdown The fall-through to reboot doesn't seem to make sense. It won't happen in the current code. Filtering the actions on client side is not needed either as the server will refuse unsupported operations anyway. --- src/systemctl/systemctl-logind.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c index d502a7edcf7..897d936abaa 100644 --- a/src/systemctl/systemctl-logind.c +++ b/src/systemctl/systemctl-logind.c @@ -304,24 +304,9 @@ int logind_schedule_shutdown(void) { if (r < 0) return r; - switch (arg_action) { - case ACTION_HALT: - action = "halt"; - break; - case ACTION_POWEROFF: - action = "poweroff"; - break; - case ACTION_KEXEC: - action = "kexec"; - break; - case ACTION_EXIT: - action = "exit"; - break; - case ACTION_REBOOT: - default: - action = "reboot"; - break; - } + action = action_table[arg_action].verb; + if (!action) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Scheduling not supported for this action."); if (arg_dry_run) action = strjoina("dry-", action); -- 2.47.3