X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibsystemd%2Fsd-bus%2Fbus-util.c;h=43acf5b9597774f55195c60be2d20705250a676c;hb=fedfcdee6f55c3f183752b7fac4879bf41eed60b;hp=7c6da60ccabc9212287235dc4dcb6551dcd0f673;hpb=d5099efc47d4e6ac60816b5381a5f607ab03f06e;p=elogind.git diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 7c6da60cc..43acf5b95 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -212,13 +212,19 @@ int bus_verify_polkit( #ifdef ENABLE_POLKIT else { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; - int authorized = false, challenge = false; + int authorized = false, challenge = false, c; const char *sender; sender = sd_bus_message_get_sender(call); if (!sender) return -EBADMSG; + c = sd_bus_message_get_allow_interactive_authorization(call); + if (c < 0) + return c; + if (c > 0) + interactive = true; + r = sd_bus_call_method( call->bus, "org.freedesktop.PolicyKit1", @@ -231,7 +237,7 @@ int bus_verify_polkit( "system-bus-name", 1, "name", "s", sender, action, 0, - interactive ? 1 : 0, + !!interactive, ""); if (r < 0) { @@ -334,6 +340,7 @@ int bus_verify_polkit_async( const char *sender; sd_bus_message_handler_t callback; void *userdata; + int c; #endif int r; @@ -375,6 +382,9 @@ int bus_verify_polkit_async( if (authorized) return 1; + if (challenge) + return sd_bus_error_set(error, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, "Interactive authentication required."); + return -EACCES; } #endif @@ -399,6 +409,12 @@ int bus_verify_polkit_async( if (!sender) return -EBADMSG; + c = sd_bus_message_get_allow_interactive_authorization(call); + if (c < 0) + return c; + if (c > 0) + interactive = true; + r = hashmap_ensure_allocated(registry, NULL); if (r < 0) return r; @@ -419,7 +435,7 @@ int bus_verify_polkit_async( "system-bus-name", 1, "name", "s", sender, action, 0, - interactive ? 1 : 0, + !!interactive, NULL); if (r < 0) return r; @@ -631,7 +647,7 @@ int bus_print_property(const char *name, sd_bus_message *property, bool all) { } case SD_BUS_TYPE_BOOLEAN: { - bool b; + int b; r = sd_bus_message_read_basic(property, type, &b); if (r < 0)