Skip to content

Commit 38d55bf

Browse files
committed
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.
1 parent 5ed7347 commit 38d55bf

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/systemctl/systemctl-compat-halt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ int halt_main(void) {
156156
}
157157
if (r >= 0)
158158
return r;
159-
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
160-
/* Requested operation is not supported on the local system or already in
159+
if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
160+
/* Requested operation requires auth, is not supported on the local system or already in
161161
* progress */
162162
return r;
163163
/* on all other errors, try low-level operation */

src/systemctl/systemctl-logind.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ int logind_schedule_shutdown(void) {
330330

331331
r = bus_call_method(bus, bus_login_mgr, "ScheduleShutdown", &error, NULL, "st", action, arg_when);
332332
if (r < 0)
333-
return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r));
333+
return log_warning_errno(r, "Failed to schedule shutdown: %s", bus_error_message(&error, r));
334334

335335
if (!arg_quiet)
336336
logind_show_shutdown();

src/systemctl/systemctl-start-special.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ int start_special(int argc, char *argv[], void *userdata) {
213213
r = logind_reboot(a);
214214
if (r >= 0)
215215
return r;
216-
if (IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
217-
/* Requested operation is not supported or already in progress */
216+
if (IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
217+
/* Requested operation requires auth, is not supported or already in progress */
218218
return r;
219219

220220
/* On all other errors, try low-level operation. In order to minimize the difference

0 commit comments

Comments
 (0)