From c8608d7cc3ff11919d7c8ea8f68de9b3db714aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 25 Apr 2021 11:15:36 +0200 Subject: [PATCH 1/3] iwd: Correctly compare autoconnected states Quite obviously, we want to update the AutoConnect setting of the iwd network in case the NM and iwd settings differ, not if they are the same. So check for unequality here instead of equality, which fixes the AutoConnect setting's synchronization. Fixes: 4229c9701278 ('iwd: Mirror NM connections to IWD network config files'): --- src/core/devices/wifi/nm-iwd-manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 20a1703adb..36c3ac826f 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -491,7 +491,7 @@ sett_conn_changed(NMSettingsConnection * sett_conn, gboolean nm_autoconnectable = nm_setting_connection_get_autoconnect(s_conn); gboolean iwd_autoconnectable = get_property_bool(data->known_network, "AutoConnect", TRUE); - if (iwd_autoconnectable == nm_autoconnectable) { + if (iwd_autoconnectable != nm_autoconnectable) { nm_log_dbg(LOGD_WIFI, "iwd: updating AutoConnect on known network at %s based on connection %s", g_dbus_proxy_get_object_path(data->known_network), From 971dcc0777d98fc8af0adb1bb17411cf0b8bee45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 25 Apr 2021 11:18:48 +0200 Subject: [PATCH 2/3] iwd: Actually update iwd config in mirror_connection() if needed There are cases where the settings didn't actually change and we just want to ensure NM and iwd settings are in sync (one such case would be when a setting was changed while iwd wasn't running, here we want to synchronize all settings when starting up iwd). We're already doing this and calling sett_conn_changed() from mirror_connection() on all connections after adding an interface, the actual settings synchronization code doesn't get executed though because we're passing 0 as update_reason, which means we bail out early from sett_conn_changed(). To make sure we actually update the iwd network configurations in that case, too, pass UPDATE_REASON_UPDATE_NON_SECRET as the update reason to sett_conn_changed(), which is the correct update reason in this case. --- src/core/devices/wifi/nm-iwd-manager.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/devices/wifi/nm-iwd-manager.c b/src/core/devices/wifi/nm-iwd-manager.c index 36c3ac826f..c7ba20eaa6 100644 --- a/src/core/devices/wifi/nm-iwd-manager.c +++ b/src/core/devices/wifi/nm-iwd-manager.c @@ -742,7 +742,9 @@ mirror_connection(NMIwdManager * self, g_object_set(G_OBJECT(s_wifi), NM_SETTING_WIRELESS_HIDDEN, hidden, NULL); } else { KnownNetworkData data = {known_network, settings_connection, id}; - sett_conn_changed(settings_connection, 0, &data); + sett_conn_changed(settings_connection, + NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET, + &data); } } From 77ef56714de06673d62b4acf0e2fc8189824cbfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 27 Apr 2021 00:37:57 +0200 Subject: [PATCH 3/3] iwd: Don't add comments about PSK passphrase to config files g_key_file_set_comment() has slightly weird API that will fail to set a comment if it doesn't find the group. This is the case here since we haven't set any strings under the [Security] group yet. Fixing this is kind of ugly, so for now just don't add that comment in the case where we don't have the [Security] group. --- src/core/devices/wifi/nm-wifi-utils.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/core/devices/wifi/nm-wifi-utils.c b/src/core/devices/wifi/nm-wifi-utils.c index 5536aa4f08..d9cf5df20b 100644 --- a/src/core/devices/wifi/nm-wifi-utils.c +++ b/src/core/devices/wifi/nm-wifi-utils.c @@ -1010,11 +1010,6 @@ psk_setting_to_iwd_config(GKeyFile *file, NMSettingWirelessSecurity *s_wsec, GEr const char * key_mgmt = nm_setting_wireless_security_get_key_mgmt(s_wsec); if (!psk || NM_FLAGS_ANY(psk_flags, SECRETS_DONT_STORE_FLAGS)) { - g_key_file_set_comment(file, - "Security", - NULL, - "The passphrase is to be queried through the agent", - NULL); if (NM_FLAGS_ANY(psk_flags, SECRETS_DONT_STORE_FLAGS)) { nm_log_info( LOGD_WIFI,