1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

systemctl: correctly proceed to immediate shutdown if scheduling fails

Actually check the return code from logind_schedule_shutdown() and proceed to
immediate shutdown if that fails. Negative return codes can be returned if
systemctl is compiled without logind support, or if logind otherwise failed
(either too old, disabled/masked, or it is incomplete
systemd-shim/systemd-service implementation).

(cherry picked from commit 940bec70bb29b105acefd540cd4c7b0b29571de1)
(cherry picked from commit 85236a0150d12e9c43ec9733fefdbd8415edb89b)
This commit is contained in:
Dimitri John Ledkov 2018-09-11 10:41:56 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 6824ba9723
commit be4248baf8

View File

@ -8617,8 +8617,10 @@ static int halt_main(void) {
if (r < 0)
return r;
if (arg_when > 0)
return logind_schedule_shutdown();
/* Delayed shutdown requested, and was successful */
if (arg_when > 0 && logind_schedule_shutdown() == 0)
return 0;
/* no delay, or logind failed or is not at all available */
if (geteuid() != 0) {
if (arg_dry_run || arg_force > 0) {