diff options
Diffstat (limited to 'libnm-core/nm-setting-wireless-security.c')
| -rw-r--r-- | libnm-core/nm-setting-wireless-security.c | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/libnm-core/nm-setting-wireless-security.c b/libnm-core/nm-setting-wireless-security.c index a634546d..036434cc 100644 --- a/libnm-core/nm-setting-wireless-security.c +++ b/libnm-core/nm-setting-wireless-security.c @@ -13,6 +13,7 @@ #include "nm-utils-private.h" #include "nm-setting-private.h" #include "nm-setting-wireless.h" +#include "nm-glib-aux/nm-secret-utils.h" /** * SECTION:nm-setting-wireless-security @@ -62,36 +63,26 @@ NM_GOBJECT_PROPERTIES_DEFINE (NMSettingWirelessSecurity, ); typedef struct { + GSList *proto; /* GSList of strings */ + GSList *pairwise; /* GSList of strings */ + GSList *group; /* GSList of strings */ char *key_mgmt; char *auth_alg; - GSList *proto; /* GSList of strings */ - GSList *pairwise; /* GSList of strings */ - GSList *group; /* GSList of strings */ - NMSettingWirelessSecurityPmf pmf; - - /* LEAP */ char *leap_username; char *leap_password; - NMSettingSecretFlags leap_password_flags; - - /* WEP */ char *wep_key0; char *wep_key1; char *wep_key2; char *wep_key3; - NMSettingSecretFlags wep_key_flags; - NMWepKeyType wep_key_type; - guint32 wep_tx_keyidx; - - /* WPA-PSK */ char *psk; + NMSettingSecretFlags leap_password_flags; + NMSettingSecretFlags wep_key_flags; NMSettingSecretFlags psk_flags; - - /* WPS */ + NMSettingWirelessSecurityPmf pmf; + NMWepKeyType wep_key_type; NMSettingWirelessSecurityWpsMethod wps_method; - - /* FILS */ NMSettingWirelessSecurityFils fils; + guint32 wep_tx_keyidx; } NMSettingWirelessSecurityPrivate; G_DEFINE_TYPE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_SETTING) @@ -175,7 +166,7 @@ nm_setting_wireless_security_add_proto (NMSettingWirelessSecurity *setting, cons priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->proto; iter; iter = g_slist_next (iter)) { - if (strcasecmp (proto, (char *) iter->data) == 0) + if (g_ascii_strcasecmp (proto, (char *) iter->data) == 0) return FALSE; } @@ -229,7 +220,7 @@ nm_setting_wireless_security_remove_proto_by_value (NMSettingWirelessSecurity *s priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->proto; iter; iter = g_slist_next (iter)) { - if (strcasecmp (proto, (char *) iter->data) == 0) { + if (g_ascii_strcasecmp (proto, (char *) iter->data) == 0) { priv->proto = g_slist_delete_link (priv->proto, iter); _notify (setting, PROP_PROTO); return TRUE; @@ -319,7 +310,7 @@ nm_setting_wireless_security_add_pairwise (NMSettingWirelessSecurity *setting, c priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) { - if (strcasecmp (pairwise, (char *) iter->data) == 0) + if (g_ascii_strcasecmp (pairwise, (char *) iter->data) == 0) return FALSE; } @@ -375,7 +366,7 @@ nm_setting_wireless_security_remove_pairwise_by_value (NMSettingWirelessSecurity priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->pairwise; iter; iter = g_slist_next (iter)) { - if (strcasecmp (pairwise, (char *) iter->data) == 0) { + if (g_ascii_strcasecmp (pairwise, (char *) iter->data) == 0) { priv->pairwise = g_slist_delete_link (priv->pairwise, iter); _notify (setting, PROP_PAIRWISE); return TRUE; @@ -466,7 +457,7 @@ nm_setting_wireless_security_add_group (NMSettingWirelessSecurity *setting, cons priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->group; iter; iter = g_slist_next (iter)) { - if (strcasecmp (group, (char *) iter->data) == 0) + if (g_ascii_strcasecmp (group, (char *) iter->data) == 0) return FALSE; } @@ -523,7 +514,7 @@ nm_setting_wireless_security_remove_group_by_value (NMSettingWirelessSecurity *s priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting); for (iter = priv->group; iter; iter = g_slist_next (iter)) { - if (strcasecmp (group, (char *) iter->data) == 0) { + if (g_ascii_strcasecmp (group, (char *) iter->data) == 0) { priv->group = g_slist_delete_link (priv->group, iter); _notify (setting, PROP_GROUP); return TRUE; @@ -865,7 +856,8 @@ need_secrets (NMSetting *setting) } if ( (strcmp (priv->key_mgmt, "ieee8021x") == 0) - || (strcmp (priv->key_mgmt, "wpa-eap") == 0)) { + || (strcmp (priv->key_mgmt, "wpa-eap") == 0) + || (strcmp (priv->key_mgmt, "owe") == 0)) { /* Let caller check the 802.1x setting for secrets */ goto no_secrets; } @@ -884,7 +876,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY (setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self); - const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-psk", "wpa-eap", "sae", NULL }; + const char *valid_key_mgmt[] = { "none", "ieee8021x", "wpa-psk", "wpa-eap", "sae", "owe", NULL }; const char *valid_auth_algs[] = { "open", "shared", "leap", NULL }; const char *valid_protos[] = { "wpa", "rsn", NULL }; const char *valid_pairwise[] = { "tkip", "ccmp", NULL }; @@ -1054,7 +1046,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) if ( NM_IN_SET (priv->pmf, NM_SETTING_WIRELESS_SECURITY_PMF_OPTIONAL, NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED) - && !NM_IN_STRSET (priv->key_mgmt, "wpa-eap", "wpa-psk", "sae")) { + && !NM_IN_STRSET (priv->key_mgmt, "wpa-eap", "wpa-psk", "sae", "owe")) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1315,33 +1307,33 @@ set_property (GObject *object, guint prop_id, priv->leap_username = g_value_dup_string (value); break; case PROP_WEP_KEY0: - g_free (priv->wep_key0); + nm_free_secret (priv->wep_key0); priv->wep_key0 = g_value_dup_string (value); break; case PROP_WEP_KEY1: - g_free (priv->wep_key1); + nm_free_secret (priv->wep_key1); priv->wep_key1 = g_value_dup_string (value); break; case PROP_WEP_KEY2: - g_free (priv->wep_key2); + nm_free_secret (priv->wep_key2); priv->wep_key2 = g_value_dup_string (value); break; case PROP_WEP_KEY3: - g_free (priv->wep_key3); + nm_free_secret (priv->wep_key3); priv->wep_key3 = g_value_dup_string (value); break; case PROP_WEP_KEY_FLAGS: priv->wep_key_flags = g_value_get_flags (value); break; case PROP_PSK: - g_free (priv->psk); + nm_free_secret (priv->psk); priv->psk = g_value_dup_string (value); break; case PROP_PSK_FLAGS: priv->psk_flags = g_value_get_flags (value); break; case PROP_LEAP_PASSWORD: - g_free (priv->leap_password); + nm_free_secret (priv->leap_password); priv->leap_password = g_value_dup_string (value); break; case PROP_LEAP_PASSWORD_FLAGS: @@ -1365,8 +1357,10 @@ set_property (GObject *object, guint prop_id, /*****************************************************************************/ static void -nm_setting_wireless_security_init (NMSettingWirelessSecurity *setting) +nm_setting_wireless_security_init (NMSettingWirelessSecurity *self) { + nm_assert (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self)->wep_key_type == NM_WEP_KEY_TYPE_UNKNOWN); + nm_assert (NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (self)->wps_method == NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT); } /** @@ -1391,12 +1385,12 @@ finalize (GObject *object) g_free (priv->key_mgmt); g_free (priv->auth_alg); g_free (priv->leap_username); - g_free (priv->wep_key0); - g_free (priv->wep_key1); - g_free (priv->wep_key2); - g_free (priv->wep_key3); - g_free (priv->psk); - g_free (priv->leap_password); + nm_free_secret (priv->wep_key0); + nm_free_secret (priv->wep_key1); + nm_free_secret (priv->wep_key2); + nm_free_secret (priv->wep_key3); + nm_free_secret (priv->psk); + nm_free_secret (priv->leap_password); g_slist_free_full (priv->proto, g_free); g_slist_free_full (priv->pairwise, g_free); @@ -1429,7 +1423,8 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) * * Key management used for the connection. One of "none" (WEP), * "ieee8021x" (Dynamic WEP), "wpa-psk" (infrastructure WPA-PSK), "sae" - * (SAE) or "wpa-eap" (WPA-Enterprise). This property must be set for + * (SAE), "owe" (Opportunistic Wireless Encryption) or "wpa-eap" + * (WPA-Enterprise). This property must be set for * any Wi-Fi connection that uses security. **/ /* ---ifcfg-rh--- @@ -1466,7 +1461,6 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, "", "", 0, 3, 0, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); /** @@ -1582,7 +1576,6 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) g_param_spec_int (NM_SETTING_WIRELESS_SECURITY_PMF, "", "", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); @@ -1809,7 +1802,6 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) NM_TYPE_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); _nm_properties_override_gobj (properties_override, obj_properties[PROP_WEP_KEY_TYPE], @@ -1844,7 +1836,6 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) g_param_spec_uint (NM_SETTING_WIRELESS_SECURITY_WPS_METHOD, "", "", 0, G_MAXUINT32, NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); @@ -1874,7 +1865,6 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *klass) g_param_spec_int (NM_SETTING_WIRELESS_SECURITY_FILS, "", "", G_MININT32, G_MAXINT32, 0, G_PARAM_READWRITE | - G_PARAM_CONSTRUCT | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); |