diff options
Diffstat (limited to 'src/supplicant')
| -rw-r--r-- | src/supplicant/nm-supplicant-config.c | 51 | ||||
| -rw-r--r-- | src/supplicant/nm-supplicant-interface.c | 18 | ||||
| -rw-r--r-- | src/supplicant/nm-supplicant-interface.h | 4 | ||||
| -rw-r--r-- | src/supplicant/nm-supplicant-settings-verify.c | 2 | ||||
| -rw-r--r-- | src/supplicant/tests/meson.build | 1 |
5 files changed, 32 insertions, 44 deletions
diff --git a/src/supplicant/nm-supplicant-config.c b/src/supplicant/nm-supplicant-config.c index 41d510e8..80db5baa 100644 --- a/src/supplicant/nm-supplicant-config.c +++ b/src/supplicant/nm-supplicant-config.c @@ -89,17 +89,23 @@ config_option_free (ConfigOption *opt) } static void +blob_free (GByteArray *array) +{ + g_byte_array_free (array, TRUE); +} + +static void nm_supplicant_config_init (NMSupplicantConfig * self) { NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self); priv->config = g_hash_table_new_full (nm_str_hash, g_str_equal, - g_free, + (GDestroyNotify) g_free, (GDestroyNotify) config_option_free); priv->blobs = g_hash_table_new_full (nm_str_hash, g_str_equal, - g_free, - (GDestroyNotify) g_bytes_unref); + (GDestroyNotify) g_free, + (GDestroyNotify) blob_free); priv->ap_scan = 1; priv->dispose_has_run = FALSE; @@ -192,6 +198,7 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self, ConfigOption *old_opt; ConfigOption *opt; OptType type; + GByteArray *blob; const guint8 *data; gsize data_len; @@ -219,6 +226,9 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self, return FALSE; } + blob = g_byte_array_sized_new (data_len); + g_byte_array_append (blob, data, data_len); + opt = g_slice_new0 (ConfigOption); opt->value = g_strdup_printf ("blob://%s", blobid); opt->len = strlen (opt->value); @@ -227,9 +237,7 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self, nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, opt->value); g_hash_table_insert (priv->config, g_strdup (key), opt); - g_hash_table_insert (priv->blobs, - g_strdup (blobid), - g_bytes_ref (value)); + g_hash_table_insert (priv->blobs, g_strdup (blobid), blob); return TRUE; } @@ -941,7 +949,7 @@ add_pkcs11_uri_with_pin (NMSupplicantConfig *self, const NMSettingSecretFlags pin_flags, GError **error) { - gs_strfreev char **split = NULL; + gs_strfreev gchar **split = NULL; gs_free char *tmp = NULL; gs_free char *tmp_log = NULL; gs_free char *pin_qattr = NULL; @@ -1001,7 +1009,6 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, guint32 frag, hdrs; gs_free char *frag_str = NULL; NMSetting8021xAuthFlags phase1_auth_flags; - nm_auto_free_gstring GString *eap_str = NULL; g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE); g_return_val_if_fail (setting != NULL, FALSE); @@ -1038,38 +1045,20 @@ nm_supplicant_config_add_setting_8021x (NMSupplicantConfig *self, priv->ap_scan = 0; } - /* Build the "eap" option string while we check for EAP methods needing - * special handling: PEAP + GTC, FAST, external */ - eap_str = g_string_new (NULL); + if (!ADD_STRING_LIST_VAL (self, setting, 802_1x, eap_method, eap_methods, "eap", ' ', TRUE, NULL, error)) + return FALSE; + + /* Check EAP method for special handling: PEAP + GTC, FAST */ num_eap = nm_setting_802_1x_get_num_eap_methods (setting); for (i = 0; i < num_eap; i++) { const char *method = nm_setting_802_1x_get_eap_method (setting, i); - if (nm_streq (method, "fast")) { + if (method && (strcasecmp (method, "fast") == 0)) { fast = TRUE; priv->fast_required = TRUE; } - - if (nm_streq (method, "external")) { - if (num_eap == 1) { - g_set_error (error, NM_SUPPLICANT_ERROR, NM_SUPPLICANT_ERROR_CONFIG, - "Connection settings managed externally to NM, connection" - " cannot be used with wpa_supplicant"); - return FALSE; - } - continue; - } - - if (eap_str->len) - g_string_append_c (eap_str, ' '); - g_string_append (eap_str, method); } - g_string_ascii_up (eap_str); - if ( eap_str->len - && !nm_supplicant_config_add_option (self, "eap", eap_str->str, -1, NULL, error)) - return FALSE; - /* Adjust the fragment size according to MTU, but do not set it higher than 1280-14 * for better compatibility */ hdrs = 14; /* EAPOL + EAP-TLS */ diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index 5237acb2..e16e3130 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -1579,7 +1579,7 @@ assoc_add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_dat GHashTable *blobs; GHashTableIter iter; const char *blob_name; - GBytes *blob_data; + GByteArray *blob_data; assoc_data = add_network_data->assoc_data; if (assoc_data) @@ -1637,7 +1637,8 @@ assoc_add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_dat "AddBlob", g_variant_new ("(s@ay)", blob_name, - nm_utils_gbytes_to_variant_ay (blob_data)), + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + blob_data->data, blob_data->len, 1)), G_DBUS_CALL_FLAGS_NONE, -1, priv->assoc_data->cancellable, @@ -1789,9 +1790,7 @@ scan_request_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) } void -nm_supplicant_interface_request_scan (NMSupplicantInterface *self, - GBytes *const*ssids, - guint ssids_len) +nm_supplicant_interface_request_scan (NMSupplicantInterface *self, const GPtrArray *ssids) { NMSupplicantInterfacePrivate *priv; GVariantBuilder builder; @@ -1805,14 +1804,15 @@ nm_supplicant_interface_request_scan (NMSupplicantInterface *self, g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_add (&builder, "{sv}", "Type", g_variant_new_string ("active")); g_variant_builder_add (&builder, "{sv}", "AllowRoam", g_variant_new_boolean (FALSE)); - if (ssids_len > 0) { + if (ssids) { GVariantBuilder ssids_builder; g_variant_builder_init (&ssids_builder, G_VARIANT_TYPE_BYTESTRING_ARRAY); - for (i = 0; i < ssids_len; i++) { - nm_assert (ssids[i]); + for (i = 0; i < ssids->len; i++) { + GByteArray *ssid = g_ptr_array_index (ssids, i); g_variant_builder_add (&ssids_builder, "@ay", - nm_utils_gbytes_to_variant_ay (ssids[i])); + g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, + ssid->data, ssid->len, 1)); } g_variant_builder_add (&builder, "{sv}", "SSIDs", g_variant_builder_end (&ssids_builder)); } diff --git a/src/supplicant/nm-supplicant-interface.h b/src/supplicant/nm-supplicant-interface.h index 0365fdcd..31272b3c 100644 --- a/src/supplicant/nm-supplicant-interface.h +++ b/src/supplicant/nm-supplicant-interface.h @@ -100,9 +100,7 @@ void nm_supplicant_interface_disconnect (NMSupplicantInterface * iface); const char *nm_supplicant_interface_get_object_path (NMSupplicantInterface * iface); -void nm_supplicant_interface_request_scan (NMSupplicantInterface *self, - GBytes *const*ssids, - guint ssids_len); +void nm_supplicant_interface_request_scan (NMSupplicantInterface * self, const GPtrArray *ssids); NMSupplicantInterfaceState nm_supplicant_interface_get_state (NMSupplicantInterface * self); diff --git a/src/supplicant/nm-supplicant-settings-verify.c b/src/supplicant/nm-supplicant-settings-verify.c index 8a0cadc7..317afff9 100644 --- a/src/supplicant/nm-supplicant-settings-verify.c +++ b/src/supplicant/nm-supplicant-settings-verify.c @@ -220,7 +220,7 @@ validate_type_keyword (const struct Opt * opt, const guint32 len) { char **allowed; - char **candidates = NULL; + gchar **candidates = NULL; char **candidate; gboolean found = FALSE; diff --git a/src/supplicant/tests/meson.build b/src/supplicant/tests/meson.build index 5e4cbdbe..b8bad7f3 100644 --- a/src/supplicant/tests/meson.build +++ b/src/supplicant/tests/meson.build @@ -4,6 +4,7 @@ exe = executable( test_unit, test_unit + '.c', dependencies: test_nm_dep, + c_args: nm_build_cflags, ) test( |