[systemd-commits] src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Fri Nov 9 06:55:44 PST 2012


 src/shared/polkit.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

New commits:
commit bece1f5215b4ff147e000255d07f6b3cc777f15b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Nov 9 15:54:22 2012 +0100

    dbus: when verifying PK privs, bypass PK if uid=0 of client
    
    This reduces the number of roundtrips when the client is privileged and
    makes the PK dep optional for root clients.

diff --git a/src/shared/polkit.c b/src/shared/polkit.c
index 14e27cd..9ed6ff2 100644
--- a/src/shared/polkit.c
+++ b/src/shared/polkit.c
@@ -46,6 +46,7 @@ int verify_polkit(
         DBusMessageIter iter_msg, iter_struct, iter_array, iter_dict, iter_variant;
         int r;
         dbus_bool_t authorized = FALSE, challenge = FALSE;
+        unsigned long ul;
 
         assert(c);
         assert(request);
@@ -54,6 +55,14 @@ int verify_polkit(
         if (!sender)
                 return -EINVAL;
 
+        ul = dbus_bus_get_unix_user(c, sender, error);
+        if (ul == (unsigned) -1)
+                return -EINVAL;
+
+        /* Shortcut things for root, to avoid the PK roundtrip and dependency */
+        if (ul == 0)
+                return 1;
+
         pid_raw = bus_get_unix_process_id(c, sender, error);
         if (pid_raw == 0)
                 return -EINVAL;
@@ -144,7 +153,6 @@ int verify_polkit(
                 r = -EPERM;
 
 finish:
-
         if (m)
                 dbus_message_unref(m);
 



More information about the systemd-commits mailing list