mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-02 00:18:06 +02:00
wifi: Use SSID from connection also if AP is not configured
Creating a mode=ap connection (as GNOME control center does) would otherwise assert in complete_connection despite having a proper SSID set: NetworkManager-wifi:ERROR:nm-device-wifi.c:1118:complete_connection: assertion failed: (ssid) Aborted
This commit is contained in:
parent
0bc11cb730
commit
3a6c618a4a
1 changed files with 27 additions and 26 deletions
|
|
@ -1046,35 +1046,37 @@ complete_connection (NMDevice *device,
|
|||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||
}
|
||||
|
||||
if (ap) {
|
||||
if (ap)
|
||||
ssid = nm_ap_get_ssid (ap);
|
||||
|
||||
if (ssid == NULL) {
|
||||
/* The AP must be hidden. Connecting to a WiFi AP requires the SSID
|
||||
* as part of the initial handshake, so check the connection details
|
||||
* for the SSID. The AP object will still be used for encryption
|
||||
* settings and such.
|
||||
*/
|
||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (setting_ssid) {
|
||||
ssid = tmp_ssid = g_byte_array_new ();
|
||||
g_byte_array_append (tmp_ssid,
|
||||
g_bytes_get_data (setting_ssid, NULL),
|
||||
g_bytes_get_size (setting_ssid));
|
||||
}
|
||||
if (ssid == NULL) {
|
||||
/* The AP must be hidden. Connecting to a WiFi AP requires the SSID
|
||||
* as part of the initial handshake, so check the connection details
|
||||
* for the SSID. The AP object will still be used for encryption
|
||||
* settings and such.
|
||||
*/
|
||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (setting_ssid) {
|
||||
ssid = tmp_ssid = g_byte_array_new ();
|
||||
g_byte_array_append (tmp_ssid,
|
||||
g_bytes_get_data (setting_ssid, NULL),
|
||||
g_bytes_get_size (setting_ssid));
|
||||
}
|
||||
}
|
||||
|
||||
if (ssid == NULL) {
|
||||
/* If there's no SSID on the AP itself, and no SSID in the
|
||||
* connection data, then we cannot connect at all. Return an error.
|
||||
*/
|
||||
g_set_error_literal (error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
"A 'wireless' setting with a valid SSID is required for hidden access points.");
|
||||
return FALSE;
|
||||
}
|
||||
if (ssid == NULL) {
|
||||
/* If there's no SSID on the AP itself, and no SSID in the
|
||||
* connection data, then we cannot connect at all. Return an error.
|
||||
*/
|
||||
g_set_error_literal (error,
|
||||
NM_DEVICE_ERROR,
|
||||
NM_DEVICE_ERROR_INVALID_CONNECTION,
|
||||
ap
|
||||
? "A 'wireless' setting with a valid SSID is required for hidden access points."
|
||||
: "Cannot create 'wireless' setting due to missing SSID.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (ap) {
|
||||
/* If the SSID is a well-known SSID, lock the connection to the AP's
|
||||
* specific BSSID so NM doesn't autoconnect to some random wifi net.
|
||||
*/
|
||||
|
|
@ -1103,7 +1105,6 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (ssid);
|
||||
str_ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
|
||||
nm_utils_complete_generic (connection,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue