core: really fix polkit >= 0.97 this time

This commit is contained in:
Dan Williams 2010-08-17 09:35:41 -05:00
parent 31d5d82cb0
commit 6e7f9b4670
4 changed files with 51 additions and 19 deletions

View file

@ -58,11 +58,6 @@
#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"
@ -150,6 +145,20 @@ static GSList * remove_one_device (NMManager *manager,
static NMDevice *nm_manager_get_device_by_udi (NMManager *manager, const char *udi);
/* Fix for polkit 0.97 and later */
#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
static inline 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
#define SSD_POKE_INTERVAL 120
#define ORIGDEV_TAG "originating-device"
@ -4203,6 +4212,7 @@ nm_manager_init (NMManager *manager)
DBusGConnection *g_connection;
guint id, i;
GFile *file;
GError *error = NULL;
/* Initialize rfkill structures and states */
memset (priv->radio_states, 0, sizeof (priv->radio_states));
@ -4285,14 +4295,18 @@ nm_manager_init (NMManager *manager)
} else
nm_log_warn (LOGD_AUTOIP4, "could not initialize avahi-autoipd D-Bus proxy");
priv->authority = polkit_authority_get_sync ();
priv->authority = polkit_authority_get_sync (NULL, &error);
if (priv->authority) {
priv->auth_changed_id = g_signal_connect (priv->authority,
"changed",
G_CALLBACK (pk_authority_changed_cb),
manager);
} else
nm_log_warn (LOGD_CORE, "failed to create PolicyKit authority.");
} else {
nm_log_warn (LOGD_CORE, "failed to create PolicyKit authority: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
/* Monitor the firmware directory */
if (strlen (KERNEL_FIRMWARE_DIR)) {

View file

@ -25,14 +25,23 @@
#include <config.h>
#include <polkit/polkit.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_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"
#define NM_SYSCONFIG_POLICY_ACTION_HOSTNAME_MODIFY "org.freedesktop.network-manager-settings.system.hostname.modify"
/* Fix for polkit 0.97 and later */
#if !HAVE_POLKIT_AUTHORITY_GET_SYNC
static inline 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
#endif /* NM_POLKIT_HELPERS_H */

View file

@ -16,7 +16,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Novell, Inc.
* (C) Copyright 2008 - 2009 Red Hat, Inc.
* (C) Copyright 2008 - 2010 Red Hat, Inc.
*/
#include <NetworkManager.h>
@ -612,10 +612,14 @@ static void
nm_sysconfig_connection_init (NMSysconfigConnection *self)
{
NMSysconfigConnectionPrivate *priv = NM_SYSCONFIG_CONNECTION_GET_PRIVATE (self);
GError *error = NULL;
priv->authority = polkit_authority_get_sync ();
priv->authority = polkit_authority_get_sync (NULL, NULL);
if (!priv->authority) {
nm_log_err (LOGD_SYS_SET, "%s: error creating PolicyKit authority");
nm_log_warn (LOGD_SYS_SET, "failed to create PolicyKit authority: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
}

View file

@ -1505,16 +1505,21 @@ static void
nm_sysconfig_settings_init (NMSysconfigSettings *self)
{
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
GError *error = NULL;
priv->connections = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
priv->authority = polkit_authority_get_sync ();
priv->authority = polkit_authority_get_sync (NULL, &error);
if (priv->authority) {
priv->auth_changed_id = g_signal_connect (priv->authority,
"changed",
G_CALLBACK (pk_authority_changed_cb),
self);
} else
nm_log_warn (LOGD_SYS_SET, "failed to create PolicyKit authority.");
} else {
nm_log_warn (LOGD_SYS_SET, "failed to create PolicyKit authority: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
g_clear_error (&error);
}
}