summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac17
-rw-r--r--src/up-polkit.c10
2 files changed, 24 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 51933be..a9461f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -150,9 +150,20 @@ PKG_CHECK_MODULES(DBUS_GLIB, [dbus-glib-1 >= 0.76])
AC_SUBST(DBUS_GLIB_CFLAGS)
AC_SUBST(DBUS_GLIB_LIBS)
-PKG_CHECK_MODULES(POLKIT, [polkit-gobject-1 >= 0.91])
-AC_SUBST(POLKIT_CFLAGS)
-AC_SUBST(POLKIT_LIBS)
+# polkit >= 0.97 uses polkit_authority_get_sync() rather than
+# polkit_authority_get
+PKG_CHECK_MODULES(POLKIT, \
+ polkit-gobject-1 >= 0.97,
+ has_new_polkit=yes,
+ has_new_polkit=no)
+if test x$has_new_polkit = xno; then
+ PKG_CHECK_MODULES(POLKIT, \
+ polkit-backend-1 \
+ polkit-gobject-1 >= 0.91)
+else
+ AC_DEFINE(USE_SECURITY_POLKIT_NEW, 1, [if we should use PolicyKit's new API])
+fi
+
PKG_CHECK_MODULES(GIO, [gio-2.0 >= 2.16.1])
AC_SUBST(GIO_CFLAGS)
diff --git a/src/up-polkit.c b/src/up-polkit.c
index 3611afb..d7760dd 100644
--- a/src/up-polkit.c
+++ b/src/up-polkit.c
@@ -240,7 +240,17 @@ up_polkit_init (UpPolkit *polkit)
}
goto out;
}
+
+#ifdef USE_SECURITY_POLKIT_NEW
+ polkit->priv->authority = polkit_authority_get_sync (NULL, &error);
+ if (polkit->priv->authority == NULL) {
+ g_error ("failed to get pokit authority: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+#else
polkit->priv->authority = polkit_authority_get ();
+#endif
out:
return;
}