From: Lennart Poettering Date: Thu, 26 Jun 2025 09:33:26 +0000 (+0200) Subject: logind: introduce a proper error if op is blocked by inhibitor lock X-Git-Tag: v258-rc1~245^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F37975%2Fhead;p=thirdparty%2Fsystemd.git logind: introduce a proper error if op is blocked by inhibitor lock We map it client side to EACCES, because that's what systemctl wants for its logic. See: #34091 --- diff --git a/src/libsystemd/sd-bus/bus-common-errors.c b/src/libsystemd/sd-bus/bus-common-errors.c index 812e75a3023..f0fc09f8a91 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.c +++ b/src/libsystemd/sd-bus/bus-common-errors.c @@ -63,6 +63,7 @@ BUS_ERROR_MAP_ELF_REGISTER const sd_bus_error_map bus_common_errors[] = { SD_BUS_ERROR_MAP(BUS_ERROR_SESSION_BUSY, EBUSY), SD_BUS_ERROR_MAP(BUS_ERROR_NOT_YOUR_DEVICE, EPERM), SD_BUS_ERROR_MAP(BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED, EBADSLT), + SD_BUS_ERROR_MAP(BUS_ERROR_BLOCKED_BY_INHIBITOR_LOCK, EACCES), SD_BUS_ERROR_MAP(BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, EALREADY), SD_BUS_ERROR_MAP(BUS_ERROR_NO_NTP_SUPPORT, EOPNOTSUPP), diff --git a/src/libsystemd/sd-bus/bus-common-errors.h b/src/libsystemd/sd-bus/bus-common-errors.h index ad6b45ae397..36676e83db5 100644 --- a/src/libsystemd/sd-bus/bus-common-errors.h +++ b/src/libsystemd/sd-bus/bus-common-errors.h @@ -63,6 +63,7 @@ #define BUS_ERROR_NOT_YOUR_DEVICE "org.freedesktop.login1.NotYourDevice" #define BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED \ "org.freedesktop.login1.DesignatedMaintenanceTimeNotScheduled" +#define BUS_ERROR_BLOCKED_BY_INHIBITOR_LOCK "org.freedesktop.login1.BlockedByInhibitorLock" #define BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED "org.freedesktop.timedate1.AutomaticTimeSyncEnabled" #define BUS_ERROR_NO_NTP_SUPPORT "org.freedesktop.timedate1.NoNTPSupport" diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index d0560a27c91..eefd7b0f0d0 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2240,8 +2240,8 @@ static int verify_shutdown_creds( if (!FLAGS_SET(flags, SD_LOGIND_SKIP_INHIBITORS) && (offending->mode != INHIBIT_BLOCK_WEAK || (uid == 0 && FLAGS_SET(flags, SD_LOGIND_ROOT_CHECK_INHIBITORS)))) - return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, - "Access denied due to active block inhibitor"); + return sd_bus_error_setf(error, BUS_ERROR_BLOCKED_BY_INHIBITOR_LOCK, + "Operation denied due to active block inhibitor"); /* We want to always ask here, even for root, to only allow bypassing if explicitly allowed * by polkit, unless a weak blocker is used, in which case it will be authorized. */