systemctl: also ignore ENOENT in checking inhibitors

Fixes a bug caused by 804874d26a.
Follow-up for a1417e5563.
Fixes #35757.
This commit is contained in:
Yu Watanabe
2024-12-28 13:36:32 +09:00
committed by Luca Boccassi
parent 156f90cf62
commit 084f361b50

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