787d6d
From 1d63577410cde215c04921d62f435259a6b258d7 Mon Sep 17 00:00:00 2001
787d6d
From: Ludwig Nussel <ludwig.nussel@suse.de>
787d6d
Date: Mon, 20 Dec 2021 18:05:50 +0100
787d6d
Subject: [PATCH] systemctl: shutdown don't fallback on auth fail
787d6d
787d6d
For shutdowns don't fall back to starting the target directly if talking
787d6d
to logind failed with auth failure. That would just lead to another
787d6d
polkit auth attempt.
787d6d
787d6d
(cherry picked from commit 38d55bf2641f345445cb4e6a5e5e808555591db2)
787d6d
787d6d
Related: #2053273
787d6d
---
787d6d
 src/systemctl/systemctl.c | 10 +++++-----
787d6d
 1 file changed, 5 insertions(+), 5 deletions(-)
787d6d
787d6d
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
787d6d
index 4bedb52f2a..199f736f7f 100644
787d6d
--- a/src/systemctl/systemctl.c
787d6d
+++ b/src/systemctl/systemctl.c
787d6d
@@ -3675,8 +3675,8 @@ static int start_special(int argc, char *argv[], void *userdata) {
787d6d
                         r = logind_reboot(a);
787d6d
                         if (r >= 0)
787d6d
                                 return r;
787d6d
-                        if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
787d6d
-                                /* requested operation is not supported or already in progress */
787d6d
+                        if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
787d6d
+                                /* Requested operation requires auth, is not supported or already in progress */
787d6d
                                 return r;
787d6d
 
787d6d
                         /* On all other errors, try low-level operation. In order to minimize the difference between
787d6d
@@ -8644,7 +8644,7 @@ static int logind_schedule_shutdown(void) {
787d6d
                         action,
787d6d
                         arg_when);
787d6d
         if (r < 0)
787d6d
-                return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r));
787d6d
+                return log_warning_errno(r, "Failed to schedule shutdown: %s", bus_error_message(&error, r));
787d6d
 
787d6d
         if (!arg_quiet)
787d6d
                 log_info("Shutdown scheduled for %s, use 'shutdown -c' to cancel.", format_timestamp(date, sizeof(date), arg_when));
787d6d
@@ -8670,8 +8670,8 @@ static int halt_main(void) {
787d6d
         }
787d6d
         if (r >= 0)
787d6d
                 return r;
787d6d
-        if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
787d6d
-                /* Requested operation is not supported on the local system or already in
787d6d
+        if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
787d6d
+                /* Requested operation requires auth, is not supported on the local system or already in
787d6d
                  * progress */
787d6d
                 return r;
787d6d
         /* on all other errors, try low-level operation */