]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-polkit: treat various well-known PK errors as denied
authorLennart Poettering <lennart@poettering.net>
Tue, 16 Jan 2024 11:53:39 +0000 (12:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Jan 2024 12:59:49 +0000 (13:59 +0100)
Various recognizable errors from

https://www.freedesktop.org/software/polkit/docs/latest/eggdbus-interface-org.freedesktop.PolicyKit1.Authority.html#eggdbus-errordomain-org.freedesktop.PolicyKit1.Error.

should be considered access failures, hence treat them like that.

src/shared/bus-polkit.c

index ff905d147f82c6f4a859bba01d5407fe963dd07b..8564eccce175524f86d37d6dd46f5b21033e64da 100644 (file)
@@ -280,8 +280,13 @@ static int async_polkit_read_reply(sd_bus_message *reply, AsyncPolkitQuery *q) {
 
                 e = sd_bus_message_get_error(reply);
 
-                if (bus_error_is_unknown_service(e))
-                        /* Treat no PK available as access denied */
+                if (bus_error_is_unknown_service(e) ||
+                    sd_bus_error_has_names(
+                                    e,
+                                    "org.freedesktop.PolicyKit1.Error.Failed",
+                                    "org.freedesktop.PolicyKit1.Error.Cancelled",
+                                    "org.freedesktop.PolicyKit1.Error.NotAuthorized"))
+                        /* Treat no PK available as access denied. Also treat some of the well-known PK errors as such. */
                         q->denied_action = TAKE_PTR(a);
                 else {
                         /* Save error from polkit reply, so it can be returned when the same authorization