From f0e8055cf95df36b41ee4f0412eef49ce634e93b Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 13 Aug 2010 13:18:58 -0500 Subject: [PATCH] core: fix builds with polkit >= 0.97 polkit_authority_get() is deprecated, should use polkit_authority_get_sync() instead. --- configure.ac | 5 ++++- src/nm-manager.c | 9 ++++++++- src/system-settings/nm-polkit-helpers.h | 8 +++++++- src/system-settings/nm-sysconfig-connection.c | 2 +- src/system-settings/nm-sysconfig-settings.c | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index aecfa8888..511359cdf 100644 --- a/configure.ac +++ b/configure.ac @@ -255,9 +255,12 @@ AC_SUBST(UUID_CFLAGS) AC_SUBST(UUID_LIBS) PKG_CHECK_MODULES(POLKIT, polkit-gobject-1) - AC_SUBST(POLKIT_CFLAGS) +# Check for polkit_authority_get_sync() +AC_CHECK_LIB([polkit-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()]) + AC_ARG_WITH(crypto, AS_HELP_STRING([--with-crypto=nss | gnutls], [Cryptography library to use for certificate and key operations]),ac_crypto=$withval, ac_crypto=nss) with_nss=no diff --git a/src/nm-manager.c b/src/nm-manager.c index 524b0becf..647991b21 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -19,6 +19,8 @@ * Copyright (C) 2007 - 2010 Red Hat, Inc. */ +#include + #include #include #include @@ -56,6 +58,11 @@ #include "nm-settings-system-interface.h" #include "nm-manager-auth.h" +/* Fix for polkit 0.97 and later */ +#if !HAVE_POLKIT_AUTHORITY_GET_SYNC +#define polkit_authority_get_sync polkit_authority_get +#endif + #define NM_AUTOIP_DBUS_SERVICE "org.freedesktop.nm_avahi_autoipd" #define NM_AUTOIP_DBUS_IFACE "org.freedesktop.nm_avahi_autoipd" @@ -4278,7 +4285,7 @@ nm_manager_init (NMManager *manager) } else nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy"); - priv->authority = polkit_authority_get (); + priv->authority = polkit_authority_get_sync (); if (priv->authority) { priv->auth_changed_id = g_signal_connect (priv->authority, "changed", diff --git a/src/system-settings/nm-polkit-helpers.h b/src/system-settings/nm-polkit-helpers.h index c26fcc2c9..c4f3de2f3 100644 --- a/src/system-settings/nm-polkit-helpers.h +++ b/src/system-settings/nm-polkit-helpers.h @@ -16,14 +16,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * (C) Copyright 2008 Novell, Inc. - * (C) Copyright 2008 Red Hat, Inc. + * (C) Copyright 2008 - 2010 Red Hat, Inc. */ #ifndef NM_POLKIT_HELPERS_H #define NM_POLKIT_HELPERS_H +#include #include +/* Fix for polkit 0.97 and later */ +#if !HAVE_POLKIT_AUTHORITY_GET_SYNC +#define polkit_authority_get_sync polkit_authority_get +#endif + #define NM_SYSCONFIG_POLICY_ACTION_CONNECTION_MODIFY "org.freedesktop.network-manager-settings.system.modify" #define NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_PROTECTED "org.freedesktop.network-manager-settings.system.wifi.share.protected" #define NM_SYSCONFIG_POLICY_ACTION_WIFI_SHARE_OPEN "org.freedesktop.network-manager-settings.system.wifi.share.open" diff --git a/src/system-settings/nm-sysconfig-connection.c b/src/system-settings/nm-sysconfig-connection.c index f46895acc..adb9897b9 100644 --- a/src/system-settings/nm-sysconfig-connection.c +++ b/src/system-settings/nm-sysconfig-connection.c @@ -613,7 +613,7 @@ nm_sysconfig_connection_init (NMSysconfigConnection *self) { NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self); - priv->authority = polkit_authority_get (); + priv->authority = polkit_authority_get_sync (); if (!priv->authority) { nm_log_err (LOGD_SYS_SET, "%s: error creating PolicyKit authority"); } diff --git a/src/system-settings/nm-sysconfig-settings.c b/src/system-settings/nm-sysconfig-settings.c index 4bcfb04bc..3ab387d54 100644 --- a/src/system-settings/nm-sysconfig-settings.c +++ b/src/system-settings/nm-sysconfig-settings.c @@ -1508,7 +1508,7 @@ nm_sysconfig_settings_init (NMSysconfigSettings *self) priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL); - priv->authority = polkit_authority_get (); + priv->authority = polkit_authority_get_sync (); if (priv->authority) { priv->auth_changed_id = g_signal_connect (priv->authority, "changed",