mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 19:30:11 +01:00
wifi: fix connection completion when no wifi setting is sent
In NMDeviceWifi's real_complete_connection() the wifi setting was looked up at the start of the function, but if no wifi setting was sent by the caller, it would be NULL. The wifi setting would later get added by nm_ap_utils_complete_connection(), but after calling that the new wifi setting would not be looked up again. Make that clearer by moving the wifi setting add code to the wifi device's real_complete_connection() and not burying it in some other function. This is more like what other device types do.
This commit is contained in:
parent
b6e66c8ff4
commit
c7d1bf18c4
3 changed files with 25 additions and 13 deletions
|
|
@ -1390,9 +1390,9 @@ real_complete_connection (NMDevice *device,
|
|||
const GByteArray *ssid = NULL;
|
||||
GSList *iter;
|
||||
|
||||
s_wifi = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
|
||||
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
s_wsec = nm_connection_get_setting_wireless_security (connection);
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
||||
if (!specific_object) {
|
||||
/* If not given a specific object, we need at minimum an SSID */
|
||||
|
|
@ -1430,8 +1430,10 @@ real_complete_connection (NMDevice *device,
|
|||
gboolean valid;
|
||||
|
||||
settings = g_slist_prepend (settings, s_wifi);
|
||||
settings = g_slist_prepend (settings, s_wsec);
|
||||
settings = g_slist_prepend (settings, s_8021x);
|
||||
if (s_wsec)
|
||||
settings = g_slist_prepend (settings, s_wsec);
|
||||
if (s_8021x)
|
||||
settings = g_slist_prepend (settings, s_8021x);
|
||||
valid = nm_setting_verify (NM_SETTING (s_wifi), settings, error);
|
||||
g_slist_free (settings);
|
||||
if (!valid)
|
||||
|
|
@ -1449,6 +1451,12 @@ real_complete_connection (NMDevice *device,
|
|||
}
|
||||
}
|
||||
|
||||
/* Add a wifi setting if one doesn't exist yet */
|
||||
if (!s_wifi) {
|
||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||
}
|
||||
|
||||
if (ap) {
|
||||
ssid = nm_ap_get_ssid (ap);
|
||||
|
||||
|
|
|
|||
|
|
@ -481,14 +481,10 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||
const char *mode, *key_mgmt, *auth_alg, *leap_username;
|
||||
gboolean adhoc = FALSE;
|
||||
|
||||
s_wifi = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
s_wsec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);
|
||||
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
|
||||
|
||||
if (!s_wifi) {
|
||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||
}
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wifi);
|
||||
s_wsec = nm_connection_get_setting_wireless_security (connection);
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
||||
/* Fill in missing SSID */
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@ complete_connection (const char *ssid,
|
|||
{
|
||||
GByteArray *tmp;
|
||||
gboolean success;
|
||||
NMSettingWireless *s_wifi;
|
||||
|
||||
/* Add a wifi setting if one doesn't exist */
|
||||
s_wifi = nm_connection_get_setting_wireless (src);
|
||||
if (!s_wifi) {
|
||||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||
nm_connection_add_setting (src, NM_SETTING (s_wifi));
|
||||
}
|
||||
|
||||
tmp = g_byte_array_sized_new (strlen (ssid));
|
||||
g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue