systemctl: do not shutdown immediately on scheduled shutdown
authorIoanna Alifieraki <ioanna-maria.alifieraki@canonical.com>
Thu, 17 Dec 2020 14:52:07 +0000 (14:52 +0000)
committerMichael Biebl <biebl@debian.org>
Sun, 2 Oct 2022 19:23:49 +0000 (20:23 +0100)
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
Gbp-Pq: Topic debian
Gbp-Pq: Name systemctl-do-not-shutdown-immediately-on-scheduled-shutdo.patch

src/systemctl/systemctl-compat-halt.c

index 8a0e4e62943d85658580542d611ff55dbe454aaf..7eeec9a45dc6186ab9b7b61411e08a0e20ae1ed5 100644 (file)
@@ -148,9 +148,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();
-                else {
+                        if (r < 0)
+                                return r;
+                } else {
                         r = logind_check_inhibitors(arg_action);
                         if (r < 0)
                                 return r;