]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: introduce a proper error if op is blocked by inhibitor lock 37975/head
authorLennart Poettering <lennart@poettering.net>
Thu, 26 Jun 2025 09:33:26 +0000 (11:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 Jun 2025 13:21:01 +0000 (15:21 +0200)
We map it client side to EACCES, because that's what systemctl wants for
its logic.

See: #34091

src/libsystemd/sd-bus/bus-common-errors.c
src/libsystemd/sd-bus/bus-common-errors.h
src/login/logind-dbus.c

index 812e75a302317956c43d47249969f4b15e78a9d3..f0fc09f8a919227337a976ae7eaab39b730fd200 100644 (file)
@@ -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),
index ad6b45ae3971c128846f4131292afde5b478eb1b..36676e83db509b32208d6480b3fd829dc0ee95e5 100644 (file)
@@ -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"
index d0560a27c915a1b17881cd035840d36c237c52e8..eefd7b0f0d06288a11b0c30740e2b07cffb0142c 100644 (file)
@@ -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. */