polkit: fix for polkit >= 0.97 (bgo #628105)
This commit is contained in:
@@ -64,6 +64,10 @@ case $with_polkit in
|
|||||||
AC_DEFINE(WITH_POLKIT, 1, [Define if you want to use PolicyKit])
|
AC_DEFINE(WITH_POLKIT, 1, [Define if you want to use PolicyKit])
|
||||||
AC_SUBST(POLKIT_CFLAGS)
|
AC_SUBST(POLKIT_CFLAGS)
|
||||||
AC_SUBST(POLKIT_LIBS)
|
AC_SUBST(POLKIT_LIBS)
|
||||||
|
|
||||||
|
# Check for polkit_authority_get_sync()
|
||||||
|
AC_CHECK_LIB([polkit-gobject-1], [polkit_authority_get_sync], ac_have_pk_auth_get_sync="1", ac_have_pk_auth_get_sync="0")
|
||||||
|
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()])
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
with_polkit=no
|
with_polkit=no
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include <polkit/polkit.h>
|
#include <polkit/polkit.h>
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
#include "mm-auth-request-polkit.h"
|
#include "mm-auth-request-polkit.h"
|
||||||
#include "mm-auth-provider-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
|
static void
|
||||||
mm_auth_provider_polkit_init (MMAuthProviderPolkit *self)
|
mm_auth_provider_polkit_init (MMAuthProviderPolkit *self)
|
||||||
{
|
{
|
||||||
MMAuthProviderPolkitPrivate *priv = MM_AUTH_PROVIDER_POLKIT_GET_PRIVATE (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) {
|
if (priv->authority) {
|
||||||
priv->auth_changed_id = g_signal_connect (priv->authority,
|
priv->auth_changed_id = g_signal_connect (priv->authority,
|
||||||
"changed",
|
"changed",
|
||||||
G_CALLBACK (pk_authority_changed_cb),
|
G_CALLBACK (pk_authority_changed_cb),
|
||||||
self);
|
self);
|
||||||
} else
|
} else {
|
||||||
g_warning ("%s: failed to create PolicyKit authority.", __func__);
|
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
|
static void
|
||||||
|
Reference in New Issue
Block a user