From 74335004f37bb554facc8394a5eb7d05e30f97d8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 3 Jun 2017 17:12:30 +0200 Subject: [PATCH 1/3] wifi: exclude AP mode wifi connection from hidden-scan list It makes no sense to scan for those. --- src/devices/wifi/nm-device-wifi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 6153f5d93c..68751cd225 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1364,8 +1364,12 @@ hidden_filter_func (NMSettings *settings, if (!nm_connection_is_type (NM_CONNECTION (connection), NM_SETTING_WIRELESS_SETTING_NAME)) return FALSE; - s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (NM_CONNECTION (connection)); - return s_wifi ? nm_setting_wireless_get_hidden (s_wifi) : FALSE; + s_wifi = nm_connection_get_setting_wireless (NM_CONNECTION (connection)); + if (!s_wifi) + return FALSE; + if (nm_streq0 (nm_setting_wireless_get_mode (s_wifi), NM_SETTING_WIRELESS_MODE_AP)) + return FALSE; + return nm_setting_wireless_get_hidden (s_wifi); } static GPtrArray * From c5fb410998b395e0a0fb9e0c22e86befa69b7599 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 3 Jun 2017 17:40:53 +0200 Subject: [PATCH 2/3] wifi: fix completing Wi-Fi connection for AP mode In AP mode we should not look up an access point. It is wrong to do, and it ends up marking the connection as hidden. It seems wrong to me that if the client explicitly set hidden=FALSE before AddAndActivate(), that complete_connection() would still set it to TRUE if it cannot find the access point. That is, because complete_connection() does not know whether hidden was omitted or set intentionally by the user. --- src/devices/wifi/nm-device-wifi.c | 33 +++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 68751cd225..28b8c26039 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -791,15 +791,18 @@ complete_connection (NMDevice *device, NMSettingWireless *s_wifi; const char *setting_mac; char *str_ssid = NULL; - NMWifiAP *ap = NULL; + NMWifiAP *ap; const GByteArray *ssid = NULL; GByteArray *tmp_ssid = NULL; GBytes *setting_ssid = NULL; gboolean hidden = FALSE; const char *perm_hw_addr; + const char *mode; s_wifi = nm_connection_get_setting_wireless (connection); + mode = s_wifi ? nm_setting_wireless_get_mode (s_wifi) : NULL; + if (!specific_object) { /* If not given a specific object, we need at minimum an SSID */ if (!s_wifi) { @@ -819,19 +822,29 @@ complete_connection (NMDevice *device, return FALSE; } - /* Find a compatible AP in the scan list */ - ap = find_first_compatible_ap (self, connection, FALSE); + if (!nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP)) { + /* Find a compatible AP in the scan list */ + ap = find_first_compatible_ap (self, connection, FALSE); - /* If we still don't have an AP, then the WiFI settings needs to be - * fully specified by the client. Might not be able to find an AP - * if the network isn't broadcasting the SSID for example. - */ - if (!ap) { + /* If we still don't have an AP, then the WiFI settings needs to be + * fully specified by the client. Might not be able to find an AP + * if the network isn't broadcasting the SSID for example. + */ + if (!ap) { + if (!nm_setting_verify (NM_SETTING (s_wifi), connection, error)) + return FALSE; + + hidden = TRUE; + } + } else { if (!nm_setting_verify (NM_SETTING (s_wifi), connection, error)) return FALSE; - - hidden = TRUE; + ap = NULL; } + } else if (nm_streq0 (mode, NM_SETTING_WIRELESS_MODE_AP)) { + if (!nm_setting_verify (NM_SETTING (s_wifi), connection, error)) + return FALSE; + ap = NULL; } else { ap = get_ap_by_path (self, specific_object); if (!ap) { From 8870b7ab129463f10bd34da71555ff19ecdb307f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 3 Jun 2017 17:46:03 +0200 Subject: [PATCH 3/3] wifi: change logging about probe-scanning SSIDs The SSID is not "hidden". It is the wildcard SSID. See build_hidden_probe_list(). --- src/devices/wifi/nm-device-wifi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 28b8c26039..633bcd6aae 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -1505,7 +1505,7 @@ request_wireless_scan (NMDeviceWifi *self, gboolean force_if_scanning, GVariant ? nm_utils_ssid_to_utf8 (ssid->data, ssid->len) : NULL; _LOGD (LOGD_WIFI, "wifi-scan: (%u) probe scanning SSID %s%s%s", - i, NM_PRINT_FMT_QUOTED (foo, "\"", foo, "\"", "")); + i, NM_PRINT_FMT_QUOTED (foo, "\"", foo, "\"", "*any*")); g_free (foo); } } else