From a0e635f455aaa6aa6d2fa9ddbbaa4f71706abddc Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 4 Apr 2009 16:37:08 -0400 Subject: [PATCH] ifupdown: inherit from NMSysconfigConnection to get PolicyKit authorization --- .../plugins/ifupdown/nm-ifupdown-connection.c | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c index 0b37e738a5..275771f34b 100644 --- a/system-settings/plugins/ifupdown/nm-ifupdown-connection.c +++ b/system-settings/plugins/ifupdown/nm-ifupdown-connection.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -33,8 +34,8 @@ #include "parser.h" G_DEFINE_TYPE (NMIfupdownConnection, - nm_ifupdown_connection, - NM_TYPE_EXPORTED_CONNECTION) + nm_ifupdown_connection, + NM_TYPE_SYSCONFIG_CONNECTION) #define NM_IFUPDOWN_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IFUPDOWN_CONNECTION, NMIfupdownConnectionPrivate)) @@ -49,14 +50,6 @@ enum { }; -static void -service_get_secrets (NMExportedConnection *exported, - const gchar *setting_name, - const gchar **hints, - gboolean request_new, - DBusGMethodInvocation *context); - - NMIfupdownConnection* nm_ifupdown_connection_new (if_block *block) { @@ -87,6 +80,33 @@ do_delete (NMExportedConnection *exported, GError **err) return FALSE; } +static void +service_get_secrets (NMExportedConnection *exported, + const gchar *setting_name, + const gchar **hints, + gboolean request_new, + DBusGMethodInvocation *context) +{ + GError *error = NULL; + + PLUGIN_PRINT ("SCPlugin-Ifupdown", "get_secrets for setting_name:'%s')", setting_name); + + /* FIXME: Only wifi secrets are supported for now */ + if (strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) { + g_set_error (&error, + NM_SYSCONFIG_SETTINGS_ERROR, + NM_SYSCONFIG_SETTINGS_ERROR_GENERAL, + "%s.%d - security setting name not supported '%s'.", + __FILE__, __LINE__, setting_name); + PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message); + dbus_g_method_return_error (context, error); + g_error_free (error); + return; + } + + NM_EXPORTED_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->service_get_secrets (exported, setting_name, hints, request_new, context); +} + /* GObject */ static void nm_ifupdown_connection_init (NMIfupdownConnection *connection) @@ -192,27 +212,3 @@ nm_ifupdown_connection_class_init (NMIfupdownConnectionClass *ifupdown_connectio G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); } -static void -service_get_secrets (NMExportedConnection *exported, - const gchar *setting_name, - const gchar **hints, - gboolean request_new, - DBusGMethodInvocation *context) -{ - GError *error = NULL; - - PLUGIN_PRINT ("SCPlugin-Ifupdown", "get_secrets for setting_name:'%s')", setting_name); - - /* FIXME: Only wifi secrets are supported for now */ - if (!strcmp (setting_name, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)) - NM_EXPORTED_CONNECTION_CLASS (nm_ifupdown_connection_parent_class)->service_get_secrets (exported, setting_name, hints, request_new, context); - else { - g_set_error (&error, NM_SETTING_WIRELESS_SECURITY_ERROR, 1, - "%s.%d - security setting name not supported '%s'.", - __FILE__, __LINE__, setting_name); - PLUGIN_PRINT ("SCPlugin-Ifupdown", "%s", error->message); - dbus_g_method_return_error (context, error); - g_error_free (error); - } -} -