]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
polkit: move asserts up, so that they cover all reply codepaths 28736/head
authorLennart Poettering <lennart@poettering.net>
Wed, 9 Aug 2023 08:51:40 +0000 (10:51 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Aug 2023 09:02:51 +0000 (11:02 +0200)
src/shared/bus-polkit.c

index 383ebd9edef899806e4a7ea56c68f89d0ebf0139..0ae0073a8210df9e30895f4662b0c0c94d31b515 100644 (file)
@@ -253,6 +253,11 @@ static int async_polkit_read_reply(sd_bus_message *reply, AsyncPolkitQuery *q) {
         assert(reply);
         assert(q);
 
+        /* Processing of a PolicyKit checks is canceled on the first auth. error. */
+        assert(!q->denied_action);
+        assert(!q->error_action);
+        assert(!sd_bus_error_is_set(&q->error));
+
         assert(q->action);
         a = TAKE_PTR(q->action);
 
@@ -270,7 +275,6 @@ static int async_polkit_read_reply(sd_bus_message *reply, AsyncPolkitQuery *q) {
 
                 /* Treat no PK available as access denied */
                 q->denied_action = TAKE_PTR(a);
-
                 return 0;
         }
 
@@ -280,12 +284,6 @@ static int async_polkit_read_reply(sd_bus_message *reply, AsyncPolkitQuery *q) {
         if (r < 0)
                 return r;
 
-        /* It's currently expected that processing of a DBus message shall be interrupted on the first
-         * auth. error */
-        assert(!q->denied_action);
-        assert(!q->error_action);
-        assert(!sd_bus_error_is_set(&q->error));
-
         if (authorized)
                 LIST_PREPEND(authorized, q->authorized_actions, TAKE_PTR(a));
         else if (challenge) {