]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: also ignore ENOENT in checking inhibitors
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Dec 2024 04:36:32 +0000 (13:36 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 28 Dec 2024 12:00:22 +0000 (12:00 +0000)
Fixes a bug caused by 804874d26ac73e0af07c4c5d7165c95372f03f6d.
Follow-up for a1417e5563acb73a0accdc12b3af91e4ec1c7f46.
Fixes #35757.

src/systemctl/systemctl-logind.c

index e54067397aa09564ee618897c5a5186e84685e62..495cccd828efa2297daf9129c5b775c1ca03f85e 100644 (file)
@@ -152,9 +152,9 @@ int logind_check_inhibitors(enum action a) {
                 return 0;
 
         r = acquire_bus_full(BUS_FULL, /* graceful = */ true, &bus);
-        if (r == -ECONNREFUSED && geteuid() == 0)
-                return 0; /* When D-Bus is not running, allow root to force a shutdown. E.g. when running at
-                           * the emergency console. */
+        if (ERRNO_IS_NEG_DISCONNECT(r) && geteuid() == 0)
+                return 0; /* When D-Bus is not running (ECONNREFUSED) or D-Bus socket is not created (ENOENT),
+                           * allow root to force a shutdown. E.g. when running at the emergency console. */
         if (r < 0)
                 return r;