]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: shutdown don't fallback on auth fail
authorLudwig Nussel <ludwig.nussel@suse.de>
Mon, 20 Dec 2021 17:05:50 +0000 (18:05 +0100)
committerLudwig Nussel <ludwig.nussel@suse.de>
Tue, 25 Jan 2022 16:43:13 +0000 (17:43 +0100)
For shutdowns don't fall back to starting the target directly if talking
to logind failed with auth failure. That would just lead to another
polkit auth attempt.

src/systemctl/systemctl-compat-halt.c
src/systemctl/systemctl-logind.c
src/systemctl/systemctl-start-special.c

index 7d95d34d542e44cae44471a9127ff0d72327b070..a7d3ffadf421d7d3807fdbd677c9e1e2098ba197 100644 (file)
@@ -156,8 +156,8 @@ int halt_main(void) {
         }
         if (r >= 0)
                 return r;
-        if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
-                /* Requested operation is not supported on the local system or already in
+        if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
+                /* Requested operation requires auth, is not supported on the local system or already in
                  * progress */
                 return r;
         /* on all other errors, try low-level operation */
index 9eae59ca31050675dcd39bb515be8bced35fface..9bf24ed5549aca109522f5ac355e200fa3481aa2 100644 (file)
@@ -330,7 +330,7 @@ int logind_schedule_shutdown(void) {
 
         r = bus_call_method(bus, bus_login_mgr, "ScheduleShutdown", &error, NULL, "st", action, arg_when);
         if (r < 0)
-                return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r));
+                return log_warning_errno(r, "Failed to schedule shutdown: %s", bus_error_message(&error, r));
 
         if (!arg_quiet)
                 logind_show_shutdown();
index 6ece700a9bf717bd36ea75c6b0c8c750f5726f3a..08eefc473e9f39cbe6ac632bc8399fdd19b26a6e 100644 (file)
@@ -213,8 +213,8 @@ int start_special(int argc, char *argv[], void *userdata) {
                         r = logind_reboot(a);
                         if (r >= 0)
                                 return r;
-                        if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
-                                /* Requested operation is not supported or already in progress */
+                        if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
+                                /* Requested operation requires auth, is not supported or already in progress */
                                 return r;
 
                         /* On all other errors, try low-level operation. In order to minimize the difference