diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-02-11 00:13:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-02-11 00:13:10 +0100 |
commit | 89f134406af6a4b4c7493f624a89dcd654b48e81 (patch) | |
tree | b6fd1211fe1c7ee28df1ccd4fbd921509b8342ac /src/polkit.c | |
parent | 4c2b0e4e423fe73fafef10a5efa6fb778784cebc (diff) |
logind: introduce CanReboot/CanPowerOff bus calls
Diffstat (limited to 'src/polkit.c')
-rw-r--r-- | src/polkit.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/polkit.c b/src/polkit.c index 5b67480fe5..3acbdc6135 100644 --- a/src/polkit.c +++ b/src/polkit.c @@ -82,6 +82,7 @@ int verify_polkit( DBusMessage *request, const char *action, bool interactive, + bool *_challenge, DBusError *error) { DBusMessage *m = NULL, *reply = NULL; @@ -94,7 +95,7 @@ int verify_polkit( uint64_t starttime_u64; DBusMessageIter iter_msg, iter_struct, iter_array, iter_dict, iter_variant; int r; - dbus_bool_t authorized = FALSE; + dbus_bool_t authorized = FALSE, challenge = FALSE; assert(c); assert(request); @@ -176,7 +177,21 @@ int verify_polkit( dbus_message_iter_get_basic(&iter_struct, &authorized); - r = authorized ? 0 : -EPERM; + if (!dbus_message_iter_next(&iter_struct) || + dbus_message_iter_get_arg_type(&iter_struct) != DBUS_TYPE_BOOLEAN) { + r = -EIO; + goto finish; + } + + dbus_message_iter_get_basic(&iter_struct, &challenge); + + if (authorized) + r = 1; + else if (_challenge) { + *_challenge = !!challenge; + r = 0; + } else + r = -EPERM; finish: |