aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLudwig Nussel <ludwig.nussel@suse.de>2021-12-20 18:05:50 +0100
committerLudwig Nussel <ludwig.nussel@suse.de>2022-01-25 17:43:13 +0100
commit38d55bf2641f345445cb4e6a5e5e808555591db2 (patch)
treee367da67c0851fb7ead347fc68b72fd0d557b2c0
parentlogind: refactor (diff)
downloadsystemd-38d55bf2641f345445cb4e6a5e5e808555591db2.tar.xz
systemd-38d55bf2641f345445cb4e6a5e5e808555591db2.zip
systemctl: shutdown don't fallback on auth fail
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.
-rw-r--r--src/systemctl/systemctl-compat-halt.c4
-rw-r--r--src/systemctl/systemctl-logind.c2
-rw-r--r--src/systemctl/systemctl-start-special.c4
3 files changed, 5 insertions, 5 deletions
diff --git a/src/systemctl/systemctl-compat-halt.c b/src/systemctl/systemctl-compat-halt.c
index 7d95d34d542..a7d3ffadf42 100644
--- a/src/systemctl/systemctl-compat-halt.c
+++ b/src/systemctl/systemctl-compat-halt.c
@@ -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 */
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index 9eae59ca310..9bf24ed5549 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -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();
diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c
index 6ece700a9bf..08eefc473e9 100644
--- a/src/systemctl/systemctl-start-special.c
+++ b/src/systemctl/systemctl-start-special.c
@@ -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