summaryrefslogtreecommitdiff
path: root/panels
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-12-09 17:59:59 +0100
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2022-01-05 23:09:45 +0000
commit6f825cd486bf8af60a7a6726d540758e9a3e8809 (patch)
tree565d57a538425b02f46163335991cb5f03adbe73 /panels
parent4e2706fc6f6fa2d29afad5d6d6e8c535299686b8 (diff)
downloadgnome-control-center-6f825cd486bf8af60a7a6726d540758e9a3e8809.tar.gz
network: Fix saving passwords for non-wifi connections
When validating security settings for non-wifi connections, we temporarily create a wireless connection. Unfortunately, when this connection is destroyed, it'll clear the stored password from the 802.1x settings object. Avoid this by removing the setting before the temporary connection is destroyed. Closes: #337
Diffstat (limited to 'panels')
-rw-r--r--panels/network/connection-editor/ce-page-8021x-security.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/panels/network/connection-editor/ce-page-8021x-security.c b/panels/network/connection-editor/ce-page-8021x-security.c
index 3a15d0711..deec51fc8 100644
--- a/panels/network/connection-editor/ce-page-8021x-security.c
+++ b/panels/network/connection-editor/ce-page-8021x-security.c
@@ -122,22 +122,18 @@ ce_page_8021x_security_validate (CEPage *cepage, NMConnection *connection, GErro
valid = wireless_security_validate (WIRELESS_SECURITY (self->security), error);
if (valid) {
g_autoptr(NMConnection) tmp_connection = NULL;
- NMSetting *s_con;
/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
- tmp_connection = nm_simple_connection_new ();
+ tmp_connection = nm_simple_connection_new_clone (connection);
nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
- /* temp connection needs a 'connection' setting too, since most of
- * the EAP methods need the UUID for CA cert ignore stuff.
- */
- s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
- nm_connection_add_setting (tmp_connection, nm_setting_duplicate (s_con));
-
ws_wpa_eap_fill_connection (self->security, tmp_connection);
+ /* NOTE: It is important we create a copy of the settings, as the
+ * secrets might be cleared otherwise.
+ */
s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
- nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
+ nm_connection_add_setting (connection, nm_setting_duplicate (NM_SETTING (s_8021x)));
}
} else {
nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);