1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

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.
This commit is contained in:
Lennart Poettering 2012-11-09 15:54:22 +01:00
parent 43f9cc65c2
commit bece1f5215

View File

@ -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);