[network-manager-applet/lr/sae: 3/4] applet: add SAE support to the Wi-Fi secrets dialog



commit 2bbfe2401454357a7418dca4dd008f4585c996d0
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Fri Oct 4 12:13:15 2019 +0200

    applet: add SAE support to the Wi-Fi secrets dialog

 src/ap-menu-item.c           |  7 +++++--
 src/applet-dialogs.c         |  2 ++
 src/libnma/nma-wifi-dialog.c | 18 ++++++++++++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 207c4e0f..0fdb4483 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -18,6 +18,8 @@
 #include "nm-access-point.h"
 #include "mobile-helpers.h"
 
+/* Only to get the NMU_SEC_SAE compat constant. */
+#include "wireless-security.h"
 
 G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_MENU_ITEM);
 
@@ -268,13 +270,14 @@ nm_network_menu_item_new (NMAccessPoint *ap,
 
        /* Don't enable the menu item the device can't even connect to the AP */
        if (   !nm_utils_security_valid (NMU_SEC_NONE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
-        && !nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
            && !nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
            && !nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
            && !nm_utils_security_valid (NMU_SEC_WPA_PSK, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
            && !nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)
            && !nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
-           && !nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)) {
+           && !nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, TRUE, priv->is_adhoc, ap_flags, 
ap_wpa, ap_rsn)
+           && !nm_utils_security_valid (NMU_SEC_SAE, dev_caps, TRUE, priv->is_adhoc, ap_flags, ap_wpa, 
ap_rsn)) {
                gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
        }
 
diff --git a/src/applet-dialogs.c b/src/applet-dialogs.c
index 75597ae0..88d32a64 100644
--- a/src/applet-dialogs.c
+++ b/src/applet-dialogs.c
@@ -226,6 +226,8 @@ create_info_label_security (NMConnection *connection)
                                label = g_strdup (_("WPA/WPA2"));
                        else if (!strcmp (key_mgmt, "wpa-psk"))
                                label = g_strdup (_("WPA/WPA2"));
+                       else if (!strcmp (key_mgmt, "sae"))
+                               label = g_strdup (_("WPA3"));
                        else
                                label = get_eap_label (s_wireless_sec, s_8021x);
                } else {
diff --git a/src/libnma/nma-wifi-dialog.c b/src/libnma/nma-wifi-dialog.c
index 12a16e85..2a572ccf 100644
--- a/src/libnma/nma-wifi-dialog.c
+++ b/src/libnma/nma-wifi-dialog.c
@@ -692,6 +692,9 @@ get_default_type_for_security (NMSettingWirelessSecurity *sec,
                return NMU_SEC_DYNAMIC_WEP;
        }
 
+       if (!strcmp (key_mgmt, "sae"))
+               return NMU_SEC_SAE;
+
        if (   !strcmp (key_mgmt, "wpa-none")
            || !strcmp (key_mgmt, "wpa-psk")) {
                if (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) {
@@ -829,6 +832,8 @@ security_valid (NMUtilsSecurityType sectype,
 {
        switch (mode) {
        case NM_802_11_MODE_AP:
+               if (sectype == NMU_SEC_SAE)
+                       return TRUE;
                return nm_utils_ap_mode_security_valid (sectype, wifi_caps);
        case NM_802_11_MODE_ADHOC:
        case NM_802_11_MODE_INFRA:
@@ -1010,6 +1015,19 @@ security_combo_init (NMAWifiDialog *self, gboolean secrets_only,
                }
        }
 
+       if (security_valid (NMU_SEC_SAE, mode, dev_caps, !!priv->ap, ap_flags, ap_wpa, ap_rsn)) {
+               WirelessSecuritySAE *ws_sae;
+
+               ws_sae = ws_sae_new (priv->connection, secrets_only);
+               if (ws_sae) {
+                       add_security_item (self, WIRELESS_SECURITY (ws_sae), sec_model,
+                                          &iter, _("WPA3 Personal"));
+                       if (active < 0 && default_type == NMU_SEC_SAE)
+                               active = item;
+                       item++;
+               }
+       }
+
        gtk_combo_box_set_model (GTK_COMBO_BOX (priv->sec_combo), GTK_TREE_MODEL (sec_model));
        gtk_combo_box_set_active (GTK_COMBO_BOX (priv->sec_combo), active < 0 ? 0 : (guint32) active);
        g_object_unref (G_OBJECT (sec_model));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]