From eb36380335d39a3959135453be4dccd561405a5b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 27 Oct 2020 13:44:08 +0100 Subject: device/wifi: don't reset the SSID of a NMWifiAP to unknown For hidden networks, we usually don't have an SSID. We try to match and fill the SSID based on the profiles that we have: [1603798852.9918] device[6b383dca267b6878] (wlp2s0): matched hidden AP AA:BB:CC:DD:EE:FF => "SSID" However, we should not clear that value again on the next update: [1603798856.5724] sup-iface[66c1a0883a262394,0,wlp2s0]: BSS /fi/w1/wpa_supplicant1/Interfaces/0/BSSs/3 updated [1603798856.5726] device[6b383dca267b6878] (wlp2s0): wifi-ap: updated AA:BB:CC:DD:EE:FF (none) Once we have a SSID, we can only update it to a better value, but not clear it. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/438 Fixes: b83f07916a54 ('supplicant: large rework of wpa_supplicant handling') --- src/devices/wifi/nm-wifi-ap.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/devices/wifi/nm-wifi-ap.c b/src/devices/wifi/nm-wifi-ap.c index fe26421df5..55438a53e4 100644 --- a/src/devices/wifi/nm-wifi-ap.c +++ b/src/devices/wifi/nm-wifi-ap.c @@ -113,22 +113,26 @@ nm_wifi_ap_set_ssid(NMWifiAP *ap, GBytes *ssid) g_return_val_if_fail(NM_IS_WIFI_AP(ap), FALSE); - if (ssid) { - l = g_bytes_get_size(ssid); - if (l == 0 || l > 32) - g_return_val_if_reached(FALSE); + if (!ssid) { + /* we don't clear the SSID, once we have it. We can only update + * it by a better value. */ + return FALSE; } + l = g_bytes_get_size(ssid); + if (l == 0 || l > 32) + g_return_val_if_reached(FALSE); + priv = NM_WIFI_AP_GET_PRIVATE(ap); if (ssid == priv->ssid) return FALSE; - if (ssid && priv->ssid && g_bytes_equal(ssid, priv->ssid)) + if (priv->ssid && g_bytes_equal(ssid, priv->ssid)) return FALSE; + g_bytes_ref(ssid); nm_clear_pointer(&priv->ssid, g_bytes_unref); - if (ssid) - priv->ssid = g_bytes_ref(ssid); + priv->ssid = ssid; _notify(ap, PROP_SSID); return TRUE; -- cgit v1.2.1