1 From 67d936e46cedfa3f9621946ac02156e8c15990e3 Mon Sep 17 00:00:00 2001
2 From: Dan Williams <dcbw@redhat.com>
3 Date: Wed, 01 Sep 2010 22:20:57 +0000
4 Subject: polkit: fix for polkit >= 0.97 (bgo #628105)
7 diff --git a/configure.ac b/configure.ac
8 index a0c65e7..af4bd09 100644
11 @@ -64,6 +64,10 @@ case $with_polkit in
12 AC_DEFINE(WITH_POLKIT, 1, [Define if you want to use PolicyKit])
13 AC_SUBST(POLKIT_CFLAGS)
16 + # Check for polkit_authority_get_sync()
17 + AC_CHECK_LIB([polkit-gobject-1], [polkit_authority_get_sync], ac_have_pk_auth_get_sync="1", ac_have_pk_auth_get_sync="0")
18 + AC_DEFINE_UNQUOTED(HAVE_POLKIT_AUTHORITY_GET_SYNC, $ac_have_pk_auth_get_sync, [Define if you have a polkit with polkit_authority_get_sync()])
22 diff --git a/src/mm-auth-provider-polkit.c b/src/mm-auth-provider-polkit.c
23 index c457eaf..2cd4a8a 100644
24 --- a/src/mm-auth-provider-polkit.c
25 +++ b/src/mm-auth-provider-polkit.c
28 #include <polkit/polkit.h>
31 #include "mm-auth-request-polkit.h"
32 #include "mm-auth-provider-polkit.h"
34 @@ -72,19 +73,39 @@ real_create_request (MMAuthProvider *provider,
36 /*****************************************************************************/
38 +/* Fix for polkit 0.97 and later */
39 +#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
40 +static inline PolkitAuthority *
41 +polkit_authority_get_sync (GCancellable *cancellable, GError **error)
43 + PolkitAuthority *authority;
45 + authority = polkit_authority_get ();
47 + g_set_error (error, 0, 0, "failed to get the PolicyKit authority");
53 mm_auth_provider_polkit_init (MMAuthProviderPolkit *self)
55 MMAuthProviderPolkitPrivate *priv = MM_AUTH_PROVIDER_POLKIT_GET_PRIVATE (self);
56 + GError *error = NULL;
58 - priv->authority = polkit_authority_get ();
59 + priv->authority = polkit_authority_get_sync (NULL, &error);
60 if (priv->authority) {
61 priv->auth_changed_id = g_signal_connect (priv->authority,
63 G_CALLBACK (pk_authority_changed_cb),
66 - g_warning ("%s: failed to create PolicyKit authority.", __func__);
68 + g_warning ("%s: failed to create PolicyKit authority: (%d) %s",
70 + error ? error->code : -1,
71 + error && error->message ? error->message : "(unknown)");
72 + g_clear_error (&error);