Blame SOURCES/0008-network-Fix-saving-passwords-for-non-wifi-connection.patch

44c0da
From 4269c292020aa11d7b8e17e804ad207e892d2bfe Mon Sep 17 00:00:00 2001
44c0da
From: Benjamin Berg <bberg@redhat.com>
44c0da
Date: Thu, 9 Dec 2021 17:53:09 +0100
44c0da
Subject: [PATCH 8/8] network: Fix saving passwords for non-wifi connections
44c0da
44c0da
When validating security settings for non-wifi connections, we
44c0da
temporarily create a wireless connection. Unfortunately, when this
44c0da
connection is destroyed, it'll clear the stored password from the 802.1x
44c0da
settings object.
44c0da
44c0da
Avoid this by removing the setting before unref'ing the temporary
44c0da
connection.
44c0da
---
44c0da
 .../connection-editor/ce-page-8021x-security.c    | 15 +++++----------
44c0da
 1 file changed, 5 insertions(+), 10 deletions(-)
44c0da
44c0da
diff --git a/panels/network/connection-editor/ce-page-8021x-security.c b/panels/network/connection-editor/ce-page-8021x-security.c
44c0da
index f7d31969a..0ac057f79 100644
44c0da
--- a/panels/network/connection-editor/ce-page-8021x-security.c
44c0da
+++ b/panels/network/connection-editor/ce-page-8021x-security.c
44c0da
@@ -126,22 +126,17 @@ validate (CEPage *cepage, NMConnection *connection, GError **error)
44c0da
 		/* FIXME: get failed property and error out of wireless security objects */
44c0da
 		valid = wireless_security_validate (page->security, error);
44c0da
 		if (valid) {
44c0da
-			NMSetting *s_con;
44c0da
-
44c0da
 			/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
44c0da
-			tmp_connection = nm_simple_connection_new ();
44c0da
+			tmp_connection = nm_simple_connection_new_clone (connection);
44c0da
 			nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
44c0da
 
44c0da
-			/* temp connection needs a 'connection' setting too, since most of
44c0da
-			 * the EAP methods need the UUID for CA cert ignore stuff.
44c0da
-			 */
44c0da
-			s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
44c0da
-			nm_connection_add_setting (tmp_connection, nm_setting_duplicate (s_con));
44c0da
-
44c0da
 			ws_802_1x_fill_connection (page->security, "wpa_eap_auth_combo", tmp_connection);
44c0da
 
44c0da
+			/* NOTE: It is important we create a copy of the settings, as the
44c0da
+			 * secrets might be cleared otherwise.
44c0da
+			 */
44c0da
 			s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
44c0da
-			nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
44c0da
+			nm_connection_add_setting (connection, nm_setting_duplicate (NM_SETTING (s_8021x)));
44c0da
 
44c0da
 			g_object_unref (tmp_connection);
44c0da
 		}
44c0da
-- 
44c0da
2.34.1
44c0da