ACK. This made me spot a minor related bug though, but it's not introduced by this patch so we can fix it in a followup commit.
On Mon, Jul 18, 2011 at 9:16 AM, Roman Rakus rrakus@redhat.com wrote:
Since polkit 0.97 is polkit_authority_get_type_sync available. For older versions we need to use polkit_authority_get_type function.
Signed-off-by: Roman Rakus rrakus@redhat.com
src/CMakeLists.txt | 3 +++ src/include/config.h.in | 1 + src/lib/mh_dbus_common.c | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0a9914..227e89c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,6 +115,9 @@ else(WITH-DBUS STREQUAL "ON") endif(NOT polkit_FOUND) endif(WITH-DBUS STREQUAL "ON")
+SET(CMAKE_REQUIRED_LIBRARIES ${polkit_LIBRARIES}) +check_function_exists (polkit_authority_get_sync HAVE_PK_GET_SYNC)
## qpid if(WITH-QMF) # Defines diff --git a/src/include/config.h.in b/src/include/config.h.in index 9253178..6231970 100644 --- a/src/include/config.h.in +++ b/src/include/config.h.in @@ -4,3 +4,4 @@ #cmakedefine HAVE_RESOLV_H 1 #cmakedefine HAVE_TIME 1 #cmakedefine HAVE_G_LIST_FREE_FULL 1 +#cmakedefine HAVE_PK_GET_SYNC 1 diff --git a/src/lib/mh_dbus_common.c b/src/lib/mh_dbus_common.c index a58c8a1..89405ed 100644 --- a/src/lib/mh_dbus_common.c +++ b/src/lib/mh_dbus_common.c @@ -56,6 +56,13 @@ check_authorization(const gchar *action, GError** error, } err = NULL; subject = polkit_system_bus_name_new(dbus_g_method_get_sender(context)); +#ifndef HAVE_PK_GET_SYNC
- authority = polkit_authority_get();
- if(!authority) {
- g_printerr("Error in obtaining authority\n");
There is a memory leak here and in the equivalent error handling return path in the #else section. A g_object_unref() is needed on subject.
- return FALSE;
- }
+#else authority = polkit_authority_get_sync(NULL, &err); if (err != NULL) { g_printerr("Error in obtaining authority: %s\n", err->message); @@ -64,7 +71,7 @@ check_authorization(const gchar *action, GError** error, g_error_free(err); return FALSE; }
+#endif result = polkit_authority_check_authorization_sync(authority, subject, action, NULL, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, NULL, -- 1.7.6
Matahari mailing list Matahari@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/matahari