From 93445c2e8952485ac818d9ea03fa6b21179ef0f7 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 1 Nov 2024 14:39:51 +0000 Subject: [PATCH] logind: ensure the stronger inhibitor currently in place is taken into account --- src/login/logind-inhibit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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; } -- 2.47.3