[Spice-devel] [PATCH spice-gtk 1/3] Lower polkit requirement to 0.96

Marc-André Lureau marcandre.lureau at gmail.com
Thu Jan 12 05:54:58 PST 2012


---
 configure.ac                           |    5 ++++-
 gtk/spice-client-glib-usb-acl-helper.c |   15 +++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5788532..10ec21b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,7 +336,7 @@ else
   if test "x$enable_polkit" = "xno"; then
     AM_CONDITIONAL(WITH_POLKIT, false)
   else
-    PKG_CHECK_MODULES(POLKIT, polkit-gobject-1)
+    PKG_CHECK_MODULES(POLKIT, polkit-gobject-1 >= 0.96)
     AC_CHECK_HEADER([acl/libacl.h],,
                     AC_MSG_ERROR([cannot find headers for libacl]))
     AC_CHECK_LIB([acl], [acl_get_file], [ACL_LIBS=-lacl] [AC_SUBST(ACL_LIBS)],
@@ -345,6 +345,9 @@ else
     AM_CONDITIONAL(WITH_POLKIT, true)
     POLICYDIR=`${PKG_CONFIG} polkit-gobject-1 --variable=policydir`
     AC_SUBST(POLICYDIR)
+    # 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()])
   fi
 fi
 
diff --git a/gtk/spice-client-glib-usb-acl-helper.c b/gtk/spice-client-glib-usb-acl-helper.c
index 311404e..53f4e9a 100644
--- a/gtk/spice-client-glib-usb-acl-helper.c
+++ b/gtk/spice-client-glib-usb-acl-helper.c
@@ -257,6 +257,21 @@ static void stdin_read_complete(GObject *src, GAsyncResult *res, gpointer data)
     }
 }
 
+/* Fix for polkit 0.97 and later */
+#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
+static 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
+
 int main(void)
 {
     pid_t parent_pid;
-- 
1.7.7.5



More information about the Spice-devel mailing list