Since polkit 0.97 is polkit_authority_get_type_sync available. For older
versions we need to use polkit_authority_get_type function.
Use check for version.
Signed-off-by: Roman Rakus <rrakus(a)redhat.com>
---
src/CMakeLists.txt | 8 ++++++++
src/include/config.h.in | 1 +
src/lib/mh_dbus_common.c | 9 ++++++++-
3 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e0a9914..1662f6a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -90,6 +90,10 @@ if(WITH-DBUS STREQUAL "ON")
pkg_check_modules(dbus-glib REQUIRED dbus-glib-1)
pkg_check_modules(polkit REQUIRED polkit-gobject-1)
+ if(NOT polkit_VERSION VERSION_LESS "0.97")
+ inherit_value(HAVE_PK_GET_SYNC 1)
+ endif(NOT polkit_VERSION VERSION_LESS "0.97")
+
if(NOT dbus-glib_FOUND)
message(FATAL_ERROR "dbus-glib headers/libraries not found.")
endif(NOT dbus-glib_FOUND)
@@ -104,6 +108,10 @@ else(WITH-DBUS STREQUAL "ON")
pkg_check_modules(dbus-glib dbus-glib-1)
pkg_check_modules(polkit polkit-gobject-1)
+ if(NOT polkit_VERSION VERSION_LESS "0.97")
+ inherit_value(HAVE_PK_GET_SYNC 1)
+ endif(NOT polkit_VERSION VERSION_LESS "0.97")
+
if(NOT dbus-glib_FOUND)
message(STATUS "dbus-glib headers/libraries not found => DBus
disabled")
set(WITH-DBUS "OFF")
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");
+ 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.4.2