summaryrefslogtreecommitdiff
path: root/src/mm-auth-provider-polkit.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-09-01 17:20:57 -0500
committerDan Williams <dcbw@redhat.com>2010-09-01 17:20:57 -0500
commit67d936e46cedfa3f9621946ac02156e8c15990e3 (patch)
treed35fb061bf6df2a805afdd338fbe50aefd2b1b35 /src/mm-auth-provider-polkit.c
parentf3024b46b495ea81563d712059ca6fc0c40ea7c8 (diff)
downloadModemManager-67d936e46cedfa3f9621946ac02156e8c15990e3.tar.gz
polkit: fix for polkit >= 0.97 (bgo #628105)
Diffstat (limited to 'src/mm-auth-provider-polkit.c')
-rw-r--r--src/mm-auth-provider-polkit.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mm-auth-provider-polkit.c b/src/mm-auth-provider-polkit.c
index c457eaf49..2cd4a8ab8 100644
--- a/src/mm-auth-provider-polkit.c
+++ b/src/mm-auth-provider-polkit.c
@@ -15,6 +15,7 @@
#include <polkit/polkit.h>
+#include <config.h>
#include "mm-auth-request-polkit.h"
#include "mm-auth-provider-polkit.h"
@@ -72,19 +73,39 @@ real_create_request (MMAuthProvider *provider,
/*****************************************************************************/
+/* Fix for polkit 0.97 and later */
+#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
+static inline PolkitAuthority *
+polkit_authority_get_sync (GCancellable *cancellable, GError **error)
+{
+ PolkitAuthority *authority;
+
+ authority = polkit_authority_get ();
+ if (!authority)
+ g_set_error (error, 0, 0, "failed to get the PolicyKit authority");
+ return authority;
+}
+#endif
+
static void
mm_auth_provider_polkit_init (MMAuthProviderPolkit *self)
{
MMAuthProviderPolkitPrivate *priv = MM_AUTH_PROVIDER_POLKIT_GET_PRIVATE (self);
+ GError *error = NULL;
- priv->authority = polkit_authority_get ();
+ priv->authority = polkit_authority_get_sync (NULL, &error);
if (priv->authority) {
priv->auth_changed_id = g_signal_connect (priv->authority,
"changed",
G_CALLBACK (pk_authority_changed_cb),
self);
- } else
- g_warning ("%s: failed to create PolicyKit authority.", __func__);
+ } else {
+ g_warning ("%s: failed to create PolicyKit authority: (%d) %s",
+ __func__,
+ error ? error->code : -1,
+ error && error->message ? error->message : "(unknown)");
+ g_clear_error (&error);
+ }
}
static void