]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: ensure the stronger inhibitor currently in place is taken into account 34969/head
authorLuca Boccassi <luca.boccassi@gmail.com>
Fri, 1 Nov 2024 14:39:51 +0000 (14:39 +0000)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 1 Nov 2024 15:43:14 +0000 (15:43 +0000)
src/login/logind-inhibit.c

index 27ad8f16526bf7673a54e49d9d3770bd903e2b05..887bfb7eaf01335089fec7e87a9eafabf874aad5 100644 (file)
@@ -404,9 +404,9 @@ bool manager_is_inhibited(
                 bool ignore_inactive,
                 bool ignore_uid,
                 uid_t uid,
-                Inhibitor **offending) {
+                Inhibitor **ret_offending) {
 
-        Inhibitor *i;
+        Inhibitor *i, *offending = NULL;
         struct dual_timestamp ts = DUAL_TIMESTAMP_NULL;
         bool inhibited = false;
 
@@ -437,13 +437,17 @@ bool manager_is_inhibited(
 
                 inhibited = true;
 
-                if (offending)
-                        *offending = i;
+                /* Stronger inhibitor wins */
+                if (!offending || (i->mode < offending->mode))
+                        offending = i;
         }
 
         if (since)
                 *since = ts;
 
+        if (ret_offending)
+                *ret_offending = offending;
+
         return inhibited;
 }