]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: certainly ignore ENOENT in checking inhibitors
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 2 Jan 2025 12:15:02 +0000 (21:15 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 2 Jan 2025 14:15:09 +0000 (14:15 +0000)
Fixes a bug caused by 804874d26ac73e0af07c4c5d7165c95372f03f6d.

Follow-up for 084f361b509cbffe7ffd5ab6085469f76f799fe5 and
a1417e5563acb73a0accdc12b3af91e4ec1c7f46.

Note, ERRNO_IS_NEG_DISCONNECT() includes ENONET rather than ENOENT...
So, ENOENT needs to be handled explicitly.

Fixes #35757 and #35806.

src/systemctl/systemctl-logind.c

index 495cccd828efa2297daf9129c5b775c1ca03f85e..0df669f484e974d6306f303e250ee9e4752e2e79 100644 (file)
@@ -152,7 +152,7 @@ int logind_check_inhibitors(enum action a) {
                 return 0;
 
         r = acquire_bus_full(BUS_FULL, /* graceful = */ true, &bus);
-        if (ERRNO_IS_NEG_DISCONNECT(r) && geteuid() == 0)
+        if ((ERRNO_IS_NEG_DISCONNECT(r) || r == -ENOENT) && 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)