| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 
 | From: Ioanna Alifieraki <ioanna-maria.alifieraki@canonical.com>
Date: Thu, 17 Dec 2020 14:52:07 +0000
Subject: systemctl: do not shutdown immediately on scheduled shutdown
When, for whatever reason, a scheduled shutdown fails to be set, systemd
will proceed with immediate shutdown without allowing the user to react.
This is counterintuitive because when a scheduled shutdown is issued,
it means the user wants to shutdown at a specified time in the future,
not immediately. This patch prevents the immediate shutdown and informs
the user that no action will be taken.
Fixes: #17575
---
 src/systemctl/systemctl-compat-halt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/systemctl/systemctl-compat-halt.c b/src/systemctl/systemctl-compat-halt.c
index 4f6e304..520e794 100644
--- a/src/systemctl/systemctl-compat-halt.c
+++ b/src/systemctl/systemctl-compat-halt.c
@@ -155,9 +155,11 @@ int halt_main(void) {
 
         if (arg_force == 0) {
                 /* always try logind first */
-                if (arg_when > 0)
+                if (arg_when > 0) {
                         r = logind_schedule_shutdown(arg_action);
-                else {
+                        if (r < 0)
+                                return r;
+                } else {
                         r = logind_check_inhibitors(arg_action);
                         if (r < 0)
                                 return r;
 |