From: Franck Bui Date: Fri, 23 Jul 2021 05:27:19 +0000 (+0200) Subject: logind: action* parameters can't be NULL in verify_shutdown_creds() X-Git-Tag: v250-rc1~927 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=878e32b614dd9442c43cd40d2324a39b1c0dfff4;p=thirdparty%2Fsystemd.git logind: action* parameters can't be NULL in verify_shutdown_creds() "action", "action_multiple_sessions" and "action_ignore_inhibit" can't be NULL in practice so let's simplify a bit the code. No functional change. --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index 19c3f9bd6e2..999a6095199 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1791,6 +1791,9 @@ static int verify_shutdown_creds( assert(message); assert(w >= 0); assert(w <= _INHIBIT_WHAT_MAX); + assert(action); + assert(action_multiple_sessions); + assert(action_ignore_inhibit); r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds); if (r < 0) @@ -1808,7 +1811,7 @@ static int verify_shutdown_creds( blocked = manager_is_inhibited(m, w, INHIBIT_BLOCK, NULL, false, true, uid, NULL); interactive = flags & SD_LOGIND_INTERACTIVE; - if (multiple_sessions && action_multiple_sessions) { + if (multiple_sessions) { r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action_multiple_sessions, NULL, interactive, UID_INVALID, &m->polkit_registry, error); if (r < 0) return r; @@ -1822,16 +1825,14 @@ static int verify_shutdown_creds( return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Access denied to root due to active block inhibitor"); - if (action_ignore_inhibit) { - r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action_ignore_inhibit, NULL, interactive, UID_INVALID, &m->polkit_registry, error); - if (r < 0) - return r; - if (r == 0) - return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ - } + r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action_ignore_inhibit, NULL, interactive, UID_INVALID, &m->polkit_registry, error); + if (r < 0) + return r; + if (r == 0) + return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */ } - if (!multiple_sessions && !blocked && action) { + if (!multiple_sessions && !blocked) { r = bus_verify_polkit_async(message, CAP_SYS_BOOT, action, NULL, interactive, UID_INVALID, &m->polkit_registry, error); if (r < 0) return r;