eap: Make Identity optional

Some of the EAP methods don't require a clear-text identity to
be sent with the Identity Response packet. The mandatory identity
filed has resulted in unnecessary transmission of the garbage
values. This patch makes the Identity field to be optional and
shift responsibility to ensure its existence to the individual
methods if the field is required. All necessary identity checks
have been previously propagated to individual methods.
This commit is contained in:
Tim Kourt 2019-01-11 15:27:15 -08:00 committed by Denis Kenzior
parent 782bd4a7ae
commit 726bf9d8e4
1 changed files with 3 additions and 32 deletions

View File

@ -418,23 +418,6 @@ void eap_secret_info_free(void *data)
l_free(info);
}
static int eap_setting_exists(struct l_settings *settings,
const char *setting,
struct l_queue *secrets,
struct l_queue *missing)
{
if (l_settings_get_value(settings, "Security", setting))
return 0;
if (l_queue_find(secrets, eap_secret_info_match, setting))
return 0;
if (l_queue_find(missing, eap_secret_info_match, setting))
return 0;
return -ENOENT;
}
int __eap_check_settings(struct l_settings *settings, struct l_queue *secrets,
const char *prefix, bool set_key_material,
struct l_queue **missing)
@ -482,19 +465,10 @@ int __eap_check_settings(struct l_settings *settings, struct l_queue *secrets,
}
/*
* Methods that provide the get_identity callback are responsible
* for ensuring, inside check_settings(), that they have enough data
* to return the identity after load_settings().
* Individual methods are responsible for ensuring, inside their
* check_settings(), that they have enough data to return the
* identity after load_settings() if it is required.
*/
if (!method->get_identity) {
snprintf(setting, sizeof(setting), "%sIdentity", prefix);
ret = eap_setting_exists(settings, setting, secrets, *missing);
if (ret < 0) {
l_error("Property %s is missing", setting);
return -ENOENT;
}
}
return 0;
}
@ -566,9 +540,6 @@ bool eap_load_settings(struct eap_state *eap, struct l_settings *settings,
eap->identity = l_strdup(eap->method->get_identity(eap));
}
if (!eap->identity)
goto err;
return true;
err: