summaryrefslogtreecommitdiff
path: root/src/polkit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/polkit.c')
-rw-r--r--src/polkit.c19
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: