From: Luca Boccassi Date: Tue, 3 Sep 2024 23:02:46 +0000 (+0100) Subject: systemctl: keep ignoring sessions on shutdown as root X-Git-Tag: v257-rc1~117^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2f9c199d100e0393c1909b00df4800b3ec0ca5c;p=thirdparty%2Fsystemd.git systemctl: keep ignoring sessions on shutdown as root The change was supposed to be about respecting inhibitors, but it was extended to also error out when there are active user sessions, which was not intentional. Previously systemctl skipped all checks if the caller was root or root-equivalent. Restore the previous behaviour and again avoid blocking systemctl reboot by root if there are active sessions, as long as there are no active inhibitors. Fixes https://github.com/systemd/systemd/issues/34086 Follow-up for 804874d26ac73e0af07c4c5d7165c95372f03f6d --- diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c index e4ef7cf9154..fc64e60c64b 100644 --- a/src/systemctl/systemctl-logind.c +++ b/src/systemctl/systemctl-logind.c @@ -204,6 +204,10 @@ int logind_check_inhibitors(enum action a) { if (r < 0) return bus_log_parse_error(r); + /* root respects inhibitors since v257 but keeps ignoring sessions by default */ + if (arg_check_inhibitors < 0 && c == 0 && geteuid() == 0) + return 0; + /* Check for current sessions */ sd_get_sessions(&sessions); STRV_FOREACH(s, sessions) {