From: Luca Boccassi Date: Fri, 1 Nov 2024 14:39:51 +0000 (+0000) Subject: logind: ensure the stronger inhibitor currently in place is taken into account X-Git-Tag: v257-rc1~52^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F34969%2Fhead;p=thirdparty%2Fsystemd.git logind: ensure the stronger inhibitor currently in place is taken into account --- diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 27ad8f16526..887bfb7eaf0 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -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; }