]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: correctly proceed to immediate shutdown if scheduling fails 10061/head
authorDimitri John Ledkov <xnox@ubuntu.com>
Tue, 11 Sep 2018 09:41:56 +0000 (10:41 +0100)
committerDimitri John Ledkov <xnox@ubuntu.com>
Tue, 11 Sep 2018 09:41:56 +0000 (10:41 +0100)
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).

src/systemctl/systemctl.c

index c91363f9d7320d17c9d261757b4bee5880a84b54..8094a6aa9f84b6d658100c73374f4d969f4e7b39 100644 (file)
@@ -8576,8 +8576,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) {