X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fpolkit.c;h=07d18e7d5fafbe932ee56814cf7457e3784706e6;hb=68fb08920b2162b48cf0fa8dd98b021327b42896;hp=5b67480fe5d295067a9f5061b8abc41d913a4efe;hpb=f401e48c2db22ff9d1a05885b5599bebf19c2707;p=elogind.git diff --git a/src/polkit.c b/src/polkit.c index 5b67480fe..07d18e7d5 100644 --- a/src/polkit.c +++ b/src/polkit.c @@ -6,16 +6,16 @@ Copyright 2011 Lennart Poettering systemd is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. systemd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. + Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with systemd; If not, see . ***/ @@ -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: