systemctl: certainly ignore ENOENT in checking inhibitors

Fixes a bug caused by 804874d26a.

Follow-up for 084f361b50 and
a1417e5563.

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

Fixes #35757 and #35806.
This commit is contained in:
Yu Watanabe
2025-01-02 21:15:02 +09:00
committed by Luca Boccassi
parent 76d80cc343
commit 66f379b63d

View 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)