mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 03:40:07 +01:00
settings/ifcfg: add support for KEY_MGMT=SAE
This commit is contained in:
parent
6640fb4b36
commit
386e75ee04
5 changed files with 60 additions and 5 deletions
|
|
@ -3612,7 +3612,7 @@ make_wpa_setting (shvarFile *ifcfg,
|
|||
gs_unref_object NMSettingWirelessSecurity *wsec = NULL;
|
||||
gs_free char *value = NULL;
|
||||
const char *v;
|
||||
gboolean wpa_psk = FALSE, wpa_eap = FALSE, ieee8021x = FALSE;
|
||||
gboolean wpa_psk = FALSE, wpa_sae = FALSE, wpa_eap = FALSE, ieee8021x = FALSE;
|
||||
int i_val;
|
||||
GError *local = NULL;
|
||||
|
||||
|
|
@ -3620,9 +3620,10 @@ make_wpa_setting (shvarFile *ifcfg,
|
|||
|
||||
v = svGetValueStr (ifcfg, "KEY_MGMT", &value);
|
||||
wpa_psk = nm_streq0 (v, "WPA-PSK");
|
||||
wpa_sae = nm_streq0 (v, "SAE");
|
||||
wpa_eap = nm_streq0 (v, "WPA-EAP");
|
||||
ieee8021x = nm_streq0 (v, "IEEE8021X");
|
||||
if (!wpa_psk && !wpa_eap && !ieee8021x)
|
||||
if (!wpa_psk && !wpa_sae && !wpa_eap && !ieee8021x)
|
||||
return NULL; /* Not WPA or Dynamic WEP */
|
||||
|
||||
/* WPS */
|
||||
|
|
@ -3636,7 +3637,7 @@ make_wpa_setting (shvarFile *ifcfg,
|
|||
NULL);
|
||||
|
||||
/* Pairwise and Group ciphers (only relevant for WPA/RSN) */
|
||||
if (wpa_psk || wpa_eap) {
|
||||
if (wpa_psk || wpa_sae || wpa_eap) {
|
||||
fill_wpa_ciphers (ifcfg, wsec, FALSE, adhoc);
|
||||
fill_wpa_ciphers (ifcfg, wsec, TRUE, adhoc);
|
||||
}
|
||||
|
|
@ -3659,7 +3660,7 @@ make_wpa_setting (shvarFile *ifcfg,
|
|||
nm_setting_wireless_security_add_proto (wsec, "rsn");
|
||||
}
|
||||
|
||||
if (wpa_psk) {
|
||||
if (wpa_psk || wpa_sae) {
|
||||
NMSettingSecretFlags psk_flags;
|
||||
|
||||
psk_flags = _secret_read_ifcfg_flags (ifcfg, "WPA_PSK_FLAGS");
|
||||
|
|
@ -3680,8 +3681,12 @@ make_wpa_setting (shvarFile *ifcfg,
|
|||
|
||||
if (adhoc)
|
||||
g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL);
|
||||
else
|
||||
else if (wpa_psk)
|
||||
g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
|
||||
else if (wpa_sae)
|
||||
g_object_set (wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "sae", NULL);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
} else if (wpa_eap || ieee8021x) {
|
||||
/* Adhoc mode is mutually exclusive with any 802.1x-based authentication */
|
||||
if (adhoc) {
|
||||
|
|
|
|||
|
|
@ -603,6 +603,10 @@ write_wireless_security_setting (NMConnection *connection,
|
|||
svSetValueStr (ifcfg, "KEY_MGMT", "WPA-PSK");
|
||||
wpa = TRUE;
|
||||
*no_8021x = TRUE;
|
||||
} else if (!strcmp (key_mgmt, "sae")) {
|
||||
svSetValueStr (ifcfg, "KEY_MGMT", "SAE");
|
||||
wpa = TRUE;
|
||||
*no_8021x = TRUE;
|
||||
} else if (!strcmp (key_mgmt, "ieee8021x")) {
|
||||
svSetValueStr (ifcfg, "KEY_MGMT", "IEEE8021X");
|
||||
dynamic_wep = TRUE;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
TYPE=Wireless
|
||||
DEVICE=wlan1
|
||||
ESSID=blahblah
|
||||
MODE=Managed
|
||||
KEY_MGMT=SAE
|
||||
|
|
@ -0,0 +1 @@
|
|||
WPA_PSK="The king is dead."
|
||||
|
|
@ -2966,6 +2966,45 @@ test_read_wifi_wpa_psk (void)
|
|||
g_object_unref (connection);
|
||||
}
|
||||
|
||||
static void
|
||||
test_read_wifi_sae (void)
|
||||
{
|
||||
gs_unref_object NMConnection *connection = NULL;
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
GBytes *ssid;
|
||||
const char *expected_ssid = "blahblah";
|
||||
|
||||
connection = _connection_from_file (TEST_IFCFG_DIR"/ifcfg-test-wifi-sae",
|
||||
NULL, TYPE_WIRELESS, NULL);
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
g_assert_cmpstr (nm_setting_connection_get_id (s_con), ==, "System blahblah (test-wifi-sae)");
|
||||
|
||||
g_assert_cmpint (nm_setting_connection_get_timestamp (s_con), ==, 0);
|
||||
g_assert (nm_setting_connection_get_autoconnect (s_con));
|
||||
|
||||
s_wireless = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wireless);
|
||||
|
||||
g_assert_cmpint (nm_setting_wireless_get_mtu (s_wireless), ==, 0);
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
g_assert (ssid);
|
||||
g_assert_cmpmem (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid), expected_ssid, strlen (expected_ssid));
|
||||
|
||||
g_assert (!nm_setting_wireless_get_bssid (s_wireless));
|
||||
g_assert_cmpstr (nm_setting_wireless_get_mode (s_wireless), ==, "infrastructure");
|
||||
|
||||
s_wsec = nm_connection_get_setting_wireless_security (connection);
|
||||
g_assert (s_wsec);
|
||||
g_assert_cmpstr (nm_setting_wireless_security_get_key_mgmt (s_wsec), ==, "sae");
|
||||
g_assert_cmpstr (nm_setting_wireless_security_get_psk (s_wsec), ==, "The king is dead.");
|
||||
g_assert (!nm_setting_wireless_security_get_auth_alg (s_wsec));
|
||||
}
|
||||
|
||||
static void
|
||||
test_read_wifi_wpa_psk_2 (void)
|
||||
{
|
||||
|
|
@ -10081,6 +10120,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_func (TPATH "wifi/read/wpa-psk/unquoted2", test_read_wifi_wpa_psk_unquoted2);
|
||||
g_test_add_func (TPATH "wifi/read/wpa-psk/adhoc", test_read_wifi_wpa_psk_adhoc);
|
||||
g_test_add_func (TPATH "wifi/read/wpa-psk/hex", test_read_wifi_wpa_psk_hex);
|
||||
g_test_add_func (TPATH "wifi/read/sae", test_read_wifi_sae);
|
||||
g_test_add_func (TPATH "wifi/read/dynamic-wep/leap", test_read_wifi_dynamic_wep_leap);
|
||||
g_test_add_func (TPATH "wifi/read/wpa/eap/tls", test_read_wifi_wpa_eap_tls);
|
||||
g_test_add_func (TPATH "wifi/read/wpa/eap/ttls/tls", test_read_wifi_wpa_eap_ttls_tls);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue