[network-manager-applet/polkit1] editor: fix retrieval of 802.1x private key passwords



commit 6c32fdcdbb73196e77428ec9ce50925506d78d03
Author: Dan Williams <dcbw redhat com>
Date:   Tue Aug 25 14:39:00 2009 -0500

    editor: fix retrieval of 802.1x private key passwords
    
    Use NMSettingsConnectionInterface to get secrets instead of two
    different codepaths for system and user secrets.  But since
    returning secrets to NM via D-Bus requires decrypting the private
    key (and thus the password isn't required), we still need a way
    to get the actual private key password out of the generic GetSecrets
    handler for NMAGConfConnection.  Hijack the "include_private_passwords"
    argument of nm_gconf_get_keyring_items() to do this for us.

 src/connection-editor/ce-page.c            |  128 ++++++++++-----------------
 src/connection-editor/nm-connection-list.c |  118 ++++++++++++++------------
 src/gconf-helpers/gconf-helpers.c          |   15 ---
 src/gconf-helpers/gconf-helpers.h          |   10 +--
 src/gconf-helpers/nma-gconf-connection.c   |    5 +-
 src/wireless-security/helpers.c            |   25 +-----
 src/wireless-security/ws-wep-key.c         |   41 +--------
 7 files changed, 129 insertions(+), 213 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 3466225..211d897 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -31,15 +31,12 @@
 
 #include <nm-setting-connection.h>
 #include <nm-utils.h>
+#include <nm-settings-connection-interface.h>
 
 #include "ce-page.h"
 #include "nma-marshal.h"
 #include "utils.h"
 
-#define DBUS_TYPE_G_ARRAY_OF_STRING         (dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING))
-#define DBUS_TYPE_G_MAP_OF_VARIANT          (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
-#define DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT   (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_MAP_OF_VARIANT))
-
 G_DEFINE_ABSTRACT_TYPE (CEPage, ce_page, G_TYPE_OBJECT)
 
 enum {
@@ -179,63 +176,47 @@ emit_initialized (CEPage *self, GError *error)
 }
 
 static void
-get_secrets_cb (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
+get_secrets_cb (NMSettingsConnectionInterface *connection,
+                GHashTable *secrets,
+                GError *error,
+                gpointer user_data)
 {
 	CEPage *self = user_data;
-	GError *error = NULL;
-	GHashTable *settings = NULL, *setting_hash;
-	gboolean do_signal = TRUE;
-
-	if (dbus_g_proxy_end_call (proxy, call, &error,
-	                           DBUS_TYPE_G_MAP_OF_MAP_OF_VARIANT, &settings,
-	                           G_TYPE_INVALID)) {
-		/* Update the connection with the new secrets */
-		setting_hash = g_hash_table_lookup (settings, self->setting_name);
-		if (setting_hash) {
-			if (!nm_connection_update_secrets (self->connection,
-			                                   self->setting_name,
-			                                   setting_hash,
-			                                   &error)) {
-				if (!error) {
-					g_set_error (&error, 0, 0, "%s",
-					             _("Failed to update connection secrets due to an unknown error."));
-				}
-			}
-		}
-		g_hash_table_destroy (settings);
-	}
+	GError *update_error = NULL;
+	GHashTable *setting_hash;
 
-	if (do_signal)
+	if (error) {
 		emit_initialized (self, error);
-	g_clear_error (&error);
-}
+		return;
+	}
 
-static gboolean
-internal_request_secrets (CEPage *self, GError **error)
-{
-	DBusGProxyCall *call;
-	GPtrArray *hints = NULL;
+	g_assert (secrets);
 
-	g_return_val_if_fail (self != NULL, FALSE);
-	g_return_val_if_fail (self->proxy != NULL, FALSE);
-	g_return_val_if_fail (self->setting_name != NULL, FALSE);
-
-	hints = g_ptr_array_new ();
-	call = dbus_g_proxy_begin_call_with_timeout (self->proxy, "GetSecrets",
-	                                             get_secrets_cb, self, NULL,
-	                                             10000,
-	                                             G_TYPE_STRING, self->setting_name,
-	                                             DBUS_TYPE_G_ARRAY_OF_STRING, hints,
-	                                             G_TYPE_BOOLEAN, FALSE,
-	                                             G_TYPE_INVALID);
-	g_ptr_array_free (hints, TRUE);
-
-	if (!call) {
-		g_set_error (error, 0, 0, "%s", _("Could not request secrets from the system settings service."));
-		return FALSE;
+	/* Update the connection with the new secrets */
+	setting_hash = g_hash_table_lookup (secrets, self->setting_name);
+
+	/* No secrets? */
+	if (!setting_hash) {
+		emit_initialized (self, NULL);
+		return;
 	}
 
-	return TRUE;
+	if (nm_connection_update_secrets (self->connection,
+	                                  self->setting_name,
+	                                  setting_hash,
+	                                  &update_error)) {
+		/* Success */
+		emit_initialized (self, NULL);
+		return;
+	}
+
+	if (!update_error) {
+		g_set_error_literal (&update_error, 0, 0,
+		                     _("Failed to update connection secrets due to an unknown error."));
+	}
+
+	emit_initialized (self, update_error);
+	g_clear_error (&update_error);
 }
 
 gboolean
@@ -243,46 +224,33 @@ ce_page_initialize (CEPage *self,
                     const char *setting_name,
                     GError **error)
 {
-	DBusGConnection *g_connection;
-	gboolean success = FALSE;
-	NMConnectionScope scope;
-
 	g_return_val_if_fail (self != NULL, FALSE);
 	g_return_val_if_fail (self->connection != NULL, FALSE);
 
-	/* Don't need to request secrets from user connections or from
-	 * settings which are known to not require secrets.
-	 */
-	scope = nm_connection_get_scope (self->connection);
-	if (!setting_name || (scope != NM_CONNECTION_SCOPE_SYSTEM)) {
+	/* Don't need to request secrets for settings which are known not to have any */
+	if (!setting_name) {
 		emit_initialized (self, NULL);
 		return TRUE;
 	}
 
-	g_connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, error);
-	if (!g_connection) {
-		g_set_error (error, 0, 0, "%s", _("Could not connect to D-Bus to request connection secrets."));
-		return FALSE;
+	/* Don't request secrets from a plain NMConnection either, since we only
+	 * use those during add/import where the secrets are already filled in.
+	 */
+	if (!NM_IS_SETTINGS_CONNECTION_INTERFACE (self->connection)) {
+		emit_initialized (self, NULL);
+		return TRUE;
 	}
 
 	if (self->setting_name)
 		g_free (self->setting_name);
 	self->setting_name = g_strdup (setting_name);
 
-	self->proxy = dbus_g_proxy_new_for_name (g_connection,
-	                                         NM_DBUS_SERVICE_SYSTEM_SETTINGS,
-	                                         nm_connection_get_path (self->connection),
-	                                         NM_DBUS_IFACE_SETTINGS_CONNECTION_SECRETS);
-	if (!self->proxy) {
-		g_set_error (error, 0, 0, "%s", _("Could not create D-Bus proxy for connection secrets."));
-		goto out;
-	}
-
-	success = internal_request_secrets (self, error);
-
-out:
-	dbus_g_connection_unref (g_connection);
-	return success;
+	return nm_settings_connection_interface_get_secrets (NM_SETTINGS_CONNECTION_INTERFACE (self->connection),
+	                                                     self->setting_name,
+	                                                     NULL,
+	                                                     FALSE,
+	                                                     get_secrets_cb,
+	                                                     self);
 }
 
 static void
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 1e2b971..6aef00b 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -449,14 +449,14 @@ add_connection (NMConnectionList *self,
 /* Connection updating */
 
 typedef void (*UpdateResultFunc) (NMConnectionList *list,
+                                  NMSettingsConnectionInterface *connection,
                                   GError *error,
                                   gpointer user_data);
 
 typedef struct {
 	NMConnectionList *list;
 	NMConnectionEditor *editor;
-	NMSettingsConnectionInterface *original;
-	NMConnection *modified;
+	NMSettingsConnectionInterface *connection;
 	UpdateResultFunc callback;
 	gpointer callback_data;
 } UpdateInfo;
@@ -464,9 +464,8 @@ typedef struct {
 static void
 update_complete (UpdateInfo *info, GError *error)
 {
-	info->callback (info->list, error, info->callback_data);
-	g_object_unref (info->original);
-	g_object_unref (info->modified);
+	info->callback (info->list, info->connection, error, info->callback_data);
+	g_object_unref (info->connection);
 	g_free (info);
 }
 
@@ -491,7 +490,7 @@ update_add_result_cb (NMConnectionList *list, GError *error, gpointer user_data)
 	}
 
 	/* Now try to remove the original connection */
-	delete_connection (list, info->original, update_remove_result_cb, info);
+	delete_connection (list, info->connection, update_remove_result_cb, info);
 }
 
 static void
@@ -507,48 +506,60 @@ update_cb (NMSettingsConnectionInterface *connection,
 			nm_connection_editor_save_vpn_secrets (info->editor);
 	}
 
+	/* Clear secrets so they don't lay around in memory; they'll get requested
+	 * again anyway next time the connection is edited.
+	 */
+	nm_connection_clear_secrets (NM_CONNECTION (connection));
+
 	update_complete (info, error);
 }
 
 static void
 update_connection (NMConnectionList *list,
                    NMConnectionEditor *editor,
-                   NMSettingsConnectionInterface *original,
+                   NMSettingsConnectionInterface *connection,
+                   NMConnectionScope orig_scope,
                    UpdateResultFunc callback,
                    gpointer user_data)
 {
-	NMConnection *modified = nm_connection_editor_get_connection (editor);
-	NMConnectionScope original_scope;
+	NMConnectionScope new_scope;
 	UpdateInfo *info;
 
 	info = g_malloc0 (sizeof (UpdateInfo));
 	info->list = list;
 	info->editor = editor;
-	info->original = g_object_ref (original);
-	info->modified = g_object_ref (modified);
+	info->connection = g_object_ref (connection);
 	info->callback = callback;
 	info->callback_data = user_data;
 
-	original_scope = nm_connection_get_scope (NM_CONNECTION (original));
-	if (nm_connection_get_scope (modified) == original_scope) {
-		/* The easy part: Connection is updated */
+	new_scope = nm_connection_get_scope (NM_CONNECTION (connection));
+	if (new_scope == orig_scope) {
+		/* The easy part: Connection is just updated and has the same scope */
 		GHashTable *new_settings;
 		GError *error = NULL;
 
-		utils_fill_connection_certs (modified);
-		new_settings = nm_connection_to_hash (modified);
-		utils_clear_filled_connection_certs (modified);
-
-		if (!nm_connection_replace_settings (NM_CONNECTION (original),
-		                                     new_settings,
-		                                     &error)) {
-			callback (list, error, user_data);
-			g_error_free (error);
-		} else {
-			/* Hack; make sure that gconf private values are copied */
-			nm_gconf_copy_private_connection_values (NM_CONNECTION (original), modified);
-			nm_settings_connection_interface_update (original, update_cb, info);
+		/* System connections need the certificates filled because the
+		 * applet private values that we use to store the path to certificates
+		 * and private keys don't go through D-Bus; they are private of course!
+		 */
+		if (new_scope == NM_CONNECTION_SCOPE_SYSTEM) {
+			utils_fill_connection_certs (NM_CONNECTION (connection));
+			new_settings = nm_connection_to_hash (NM_CONNECTION (connection));
+			utils_clear_filled_connection_certs (NM_CONNECTION (connection));
+
+			if (!nm_connection_replace_settings (NM_CONNECTION (connection),
+			                                     new_settings,
+			                                     &error)) {
+				update_complete (info, error);
+				g_error_free (error);
+				return;
+			}
 		}
+
+		/* Update() actually saves the connection settings to backing storage,
+		 * either GConf or over D-Bus.
+		 */
+		nm_settings_connection_interface_update (connection, update_cb, info);
 	} else {
 		/* The hard part: Connection scope changed:
 		 * Add the modified connection to the new settings service, then delete
@@ -624,6 +635,8 @@ really_add_connection (NMConnection *connection,
 
 	editor = nm_connection_editor_new (connection, info->list->system_settings, &error);
 	if (!editor) {
+		g_object_unref (connection);
+
 		error_dialog (info->list_window,
 		              _("Could not edit new connection"),
 		              "%s",
@@ -670,11 +683,12 @@ add_clicked (GtkButton *button, gpointer user_data)
 typedef struct {
 	NMConnectionList *list;
 	NMConnectionEditor *editor;
-	NMSettingsConnectionInterface *original_connection;
+	NMConnectionScope orig_scope;
 } EditInfo;
 
 static void
 connection_updated_cb (NMConnectionList *list,
+                       NMSettingsConnectionInterface *connection,
                        GError *error,
                        gpointer user_data)
 {
@@ -684,13 +698,11 @@ connection_updated_cb (NMConnectionList *list,
 		GtkListStore *store;
 		GtkTreeIter iter;
 
-		store = get_model_for_connection (list, info->original_connection);
+		store = get_model_for_connection (list, connection);
 		g_assert (store);
-		if (get_iter_for_connection (GTK_TREE_MODEL (store), info->original_connection, &iter))
-			update_connection_row (store, &iter, info->original_connection);
+		if (get_iter_for_connection (GTK_TREE_MODEL (store), connection, &iter))
+			update_connection_row (store, &iter, connection);
 	}
-
-	g_object_unref (info->original_connection);
 	g_free (info);
 }
 
@@ -699,8 +711,11 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
 {
 	EditInfo *info = user_data;
 	const char *message = _("An unknown error ocurred.");
+	NMConnection *connection;
 
-	g_hash_table_remove (info->list->editors, info->original_connection);
+	connection = nm_connection_editor_get_connection (editor);
+	g_assert (connection);
+	g_hash_table_remove (info->list->editors, connection);
 
 	if (response == GTK_RESPONSE_NONE) {
 		if (error && error->message)
@@ -711,26 +726,30 @@ edit_done_cb (NMConnectionEditor *editor, gint response, GError *error, gpointer
 	}
 
 	if (response == GTK_RESPONSE_OK) {
-		NMConnection *connection;
 		GError *edit_error = NULL;
 		gboolean success;
 
-		connection = nm_connection_editor_get_connection (editor);
-
 		utils_fill_connection_certs (connection);
 		success = nm_connection_verify (connection, &edit_error);
 		utils_clear_filled_connection_certs (connection);
 
 		if (success) {
-			update_connection (info->list, editor, info->original_connection,
-			                   connection_updated_cb, info);
+			update_connection (info->list,
+			                   editor,
+			                   NM_SETTINGS_CONNECTION_INTERFACE (connection),
+			                   info->orig_scope,
+			                   connection_updated_cb,
+			                   info);
 		} else {
 			g_warning ("%s: invalid connection after update: bug in the "
 			           "'%s' / '%s' invalid: %d",
 			           __func__,
 			           g_type_name (nm_connection_lookup_setting_type_by_quark (edit_error->domain)),
 			           edit_error->message, edit_error->code);
-			connection_updated_cb (info->list, edit_error, info);
+			connection_updated_cb (info->list,
+			                       NM_SETTINGS_CONNECTION_INTERFACE (connection),
+			                       edit_error,
+			                       info);
 			g_error_free (edit_error);
 		}
 	}
@@ -740,7 +759,6 @@ static void
 do_edit (ActionInfo *info)
 {
 	NMSettingsConnectionInterface *connection;
-	NMConnection *duplicated;
 	NMConnectionEditor *editor;
 	EditInfo *edit_info;
 	GError *error = NULL;
@@ -756,10 +774,7 @@ do_edit (ActionInfo *info)
 		return;
 	}
 
-	duplicated = nm_gconf_connection_duplicate (NM_CONNECTION (connection));
-	editor = nm_connection_editor_new (duplicated, info->list->system_settings, &error);
-	g_object_unref (duplicated);
-
+	editor = nm_connection_editor_new (NM_CONNECTION (connection), info->list->system_settings, &error);
 	if (!editor) {
 		error_dialog (info->list_window,
 		              _("Could not edit connection"),
@@ -771,7 +786,7 @@ do_edit (ActionInfo *info)
 	edit_info = g_malloc0 (sizeof (EditInfo));
 	edit_info->list = info->list;
 	edit_info->editor = editor;
-	edit_info->original_connection = g_object_ref (connection);
+	edit_info->orig_scope = nm_connection_get_scope (NM_CONNECTION (connection));
 
 	g_signal_connect (editor, "done", G_CALLBACK (edit_done_cb), edit_info);
 	g_hash_table_insert (info->list->editors, connection, editor);
@@ -780,12 +795,6 @@ do_edit (ActionInfo *info)
 }
 
 static void
-edit_connection_cb (GtkButton *button, gpointer user_data)
-{
-	do_edit ((ActionInfo *) user_data);
-}
-
-static void
 delete_result_cb (NMConnectionList *list,
                   GError *error,
                   gpointer user_data)
@@ -954,6 +963,8 @@ import_success_cb (NMConnection *connection, gpointer user_data)
 	if (!service_type || !strlen (service_type)) {
 		GtkWidget *dialog;
 
+		g_object_unref (connection);
+
 		dialog = gtk_message_dialog_new (NULL,
 		                                 GTK_DIALOG_DESTROY_WITH_PARENT,
 		                                 GTK_MESSAGE_ERROR,
@@ -971,6 +982,7 @@ import_success_cb (NMConnection *connection, gpointer user_data)
 
 	editor = nm_connection_editor_new (connection, info->list->system_settings, &error);
 	if (!editor) {
+		g_object_unref (connection);
 		error_dialog (info->list_window,
 		              _("Could not edit imported connection"),
 		              "%s",
@@ -1233,7 +1245,7 @@ add_connection_buttons (NMConnectionList *self,
 	gtk_box_pack_end (GTK_BOX (hbox), button, TRUE, TRUE, 0);
 
 	action_info_set_button (info, button);
-	g_signal_connect (button, "clicked", G_CALLBACK (edit_connection_cb), info);
+	g_signal_connect_swapped (button, "clicked", G_CALLBACK (do_edit), info);
 	g_signal_connect (treeview, "row-activated", G_CALLBACK (connection_double_clicked_cb), info);
 	g_signal_connect (selection, "changed", G_CALLBACK (pk_button_selection_changed_cb), info);
 	pk_button_selection_changed_cb (selection, info);
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index f327865..3a8c2c1 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -2531,18 +2531,3 @@ nm_gconf_clear_private_connection_values (NMConnection *connection)
 	g_object_set_data (G_OBJECT (connection), NMA_PHASE2_PRIVATE_KEY_PASSWORD_TAG, NULL);
 }
 
-NMConnection *
-nm_gconf_connection_duplicate (NMConnection *connection)
-{
-	NMConnection *dup;
-
-	g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
-
-	dup = nm_connection_duplicate (connection);
-	g_return_val_if_fail (NM_IS_CONNECTION (dup), NULL);
-
-	nm_gconf_copy_private_connection_values (dup, connection);
-
-	return dup;
-}
-
diff --git a/src/gconf-helpers/gconf-helpers.h b/src/gconf-helpers/gconf-helpers.h
index edf0db3..727115d 100644
--- a/src/gconf-helpers/gconf-helpers.h
+++ b/src/gconf-helpers/gconf-helpers.h
@@ -37,10 +37,10 @@
 
 
 /* 
-   ATTENTION: Make sure to update nm_gconf_connection_duplicate() 
-   when new connection tag is added! Otherwise duplicating connection
-   will not work correctly.
-*/
+ * ATTENTION: Make sure to update nm_gconf_copy_private_connection_values()
+ * and nm_gconf_clear_private_connection_values() when new tag is added!
+ * Otherwise duplicating connection will not work correctly.
+ */
 #define NMA_CA_CERT_IGNORE_TAG  "nma-ca-cert-ignore"
 #define NMA_PHASE2_CA_CERT_IGNORE_TAG  "nma-phase2-ca-cert-ignore"
 #define NMA_PATH_CLIENT_CERT_TAG "nma-path-client-cert"
@@ -52,8 +52,6 @@
 #define NMA_PATH_PHASE2_PRIVATE_KEY_TAG "nma-path-phase2-private-key"
 #define NMA_PHASE2_PRIVATE_KEY_PASSWORD_TAG "nma-phase2-private-key-password"
 
-NMConnection *nm_gconf_connection_duplicate (NMConnection *connection);
-
 void nm_gconf_copy_private_connection_values (NMConnection *dst, NMConnection *src);
 void nm_gconf_clear_private_connection_values (NMConnection *connection);
 
diff --git a/src/gconf-helpers/nma-gconf-connection.c b/src/gconf-helpers/nma-gconf-connection.c
index b792b55..bf4a780 100644
--- a/src/gconf-helpers/nma-gconf-connection.c
+++ b/src/gconf-helpers/nma-gconf-connection.c
@@ -279,6 +279,7 @@ internal_get_secrets (NMSettingsConnectionInterface *connection,
                       const char *setting_name,
                       const char **hints,
                       gboolean request_new,
+                      gboolean local,
                       NMANewSecretsRequestedFunc callback,
                       gpointer callback_data,
                       GError **error)
@@ -328,7 +329,7 @@ internal_get_secrets (NMSettingsConnectionInterface *connection,
 		goto get_secrets;
 	}
 
-	secrets = nm_gconf_get_keyring_items (NM_CONNECTION (self), setting_name, FALSE, error);
+	secrets = nm_gconf_get_keyring_items (NM_CONNECTION (self), setting_name, local, error);
 	if (!secrets) {
 		if (error)
 			return FALSE;
@@ -431,6 +432,7 @@ get_secrets (NMSettingsConnectionInterface *connection,
 	                           setting_name,
 	                           hints,
 	                           request_new,
+	                           TRUE,
 	                           get_secrets_cb,
 	                           info,
 	                           &error)) {
@@ -620,6 +622,7 @@ dbus_get_secrets (NMExportedConnection *connection,
 	                           setting_name,
 	                           hints,
 	                           request_new,
+	                           FALSE,
 	                           dbus_get_secrets_cb,
 	                           context,
 	                           &error)) {
diff --git a/src/wireless-security/helpers.c b/src/wireless-security/helpers.c
index 9b08713..47deb6a 100644
--- a/src/wireless-security/helpers.c
+++ b/src/wireless-security/helpers.c
@@ -31,9 +31,6 @@ helper_fill_secret_entry (NMConnection *connection,
                           const char *secret_name)
 {
 	NMSetting *setting;
-	GHashTable *secrets;
-	GError *error = NULL;
-	GValue *value;
 	const char *tmp;
 
 	g_return_if_fail (connection != NULL);
@@ -43,24 +40,10 @@ helper_fill_secret_entry (NMConnection *connection,
 	g_return_if_fail (secret_name != NULL);
 
 	setting = nm_connection_get_setting (connection, setting_type);
-
-	if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
-		if (setting) {
-			tmp = (*func) (setting);
-			if (tmp)
-				gtk_entry_set_text (entry, tmp);
-		}
-	} else {
-		secrets = nm_gconf_get_keyring_items (connection, setting_name, FALSE, &error);
-		if (!secrets) {
-			g_clear_error (&error);
-			return;
-		}
-
-		value = g_hash_table_lookup (secrets, secret_name);
-		if (value)
-			gtk_entry_set_text (entry, g_value_get_string (value));
-		g_hash_table_destroy (secrets);
+	if (setting) {
+		tmp = (*func) (setting);
+		if (tmp)
+			gtk_entry_set_text (entry, tmp);
 	}
 }
 
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index 4b13b33..fc4be18 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -218,9 +218,6 @@ static void
 fill_secrets (WirelessSecurityWEPKey *sec, NMConnection *connection)
 {
 	NMSettingWirelessSecurity *s_wsec;
-	GHashTable *secrets;
-	GError *error = NULL;
-	GValue *value;
 	const char *tmp;
 	int i;
 
@@ -228,40 +225,10 @@ fill_secrets (WirelessSecurityWEPKey *sec, NMConnection *connection)
 	g_return_if_fail (connection != NULL);
 
 	s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
-
-	if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
-		for (i = 0; s_wsec && i < 4; i++) {
-			tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i);
-			if (tmp)
-				strcpy (sec->keys[i], tmp);
-		}
-	} else {
-		secrets = nm_gconf_get_keyring_items (connection,
-		                                      NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
-		                                      FALSE,
-		                                      &error);
-		if (!secrets) {
-			g_clear_error (&error);
-			return;
-		}
-
-		value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
-		if (value)
-			strcpy (sec->keys[0], g_value_get_string (value));
-
-		value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY1);
-		if (value)
-			strcpy (sec->keys[1], g_value_get_string (value));
-
-		value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY2);
-		if (value)
-			strcpy (sec->keys[2], g_value_get_string (value));
-
-		value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY3);
-		if (value)
-			strcpy (sec->keys[3], g_value_get_string (value));
-
-		g_hash_table_destroy (secrets);
+	for (i = 0; s_wsec && i < 4; i++) {
+		tmp = nm_setting_wireless_security_get_wep_key (s_wsec, i);
+		if (tmp)
+			strcpy (sec->keys[i], tmp);
 	}
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]