3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 10:39:23 +01:00

eap-mschapv2: Load credentials obtained from agent

If needed load the username and password obtained from the agent and
received in the settings object.
This commit is contained in:
Andrew Zaborowski 2018-04-26 11:29:24 +02:00 committed by Denis Kenzior
parent cb775819b8
commit 6dc5d2c3ec

View File

@ -724,37 +724,62 @@ static bool eap_mschapv2_load_settings(struct eap_state *eap,
const char *prefix) const char *prefix)
{ {
struct eap_mschapv2_state *state; struct eap_mschapv2_state *state;
const char *password; const char *identity, *password = NULL;
char setting[64]; char setting[64];
state = l_new(struct eap_mschapv2_state, 1); state = l_new(struct eap_mschapv2_state, 1);
snprintf(setting, sizeof(setting), "%sIdentity", prefix); snprintf(setting, sizeof(setting), "%sIdentity", prefix);
set_user_name(state, identity = l_settings_get_value(settings, "Security", setting);
l_settings_get_value(settings, "Security", setting));
if (!identity) {
snprintf(setting, sizeof(setting), "%sIdentity-User", prefix);
identity = l_settings_get_value(settings, "Security", setting);
if (!identity)
goto error;
snprintf(setting, sizeof(setting), "%sIdentity-Password",
prefix);
password = l_settings_get_value(settings, "Security", setting);
if (!password)
goto error;
set_password_from_string(state, password);
}
set_user_name(state, identity);
state->user_len = strlen(state->user); state->user_len = strlen(state->user);
/* Either read the password-hash from hexdump or password and hash it */ /* Either read the password-hash from hexdump or password and hash it */
snprintf(setting, sizeof(setting), "%sPassword-Hash", prefix); if (!password) {
password = l_settings_get_value(settings, "Security", setting); snprintf(setting, sizeof(setting), "%sPassword-Hash", prefix);
if (password) { password = l_settings_get_value(settings, "Security", setting);
unsigned char *tmp; if (password) {
size_t len; unsigned char *tmp;
size_t len;
tmp = l_util_from_hexstring(password, &len); tmp = l_util_from_hexstring(password, &len);
memcpy(state->password_hash, tmp, 16); memcpy(state->password_hash, tmp, 16);
l_free(tmp); l_free(tmp);
} else { }
}
if (!password) {
snprintf(setting, sizeof(setting), "%sPassword", prefix); snprintf(setting, sizeof(setting), "%sPassword", prefix);
password = l_settings_get_value(settings, "Security", password = l_settings_get_value(settings, "Security", setting);
setting); if (!password)
goto error;
set_password_from_string(state, password); set_password_from_string(state, password);
} }
eap_set_data(eap, state); eap_set_data(eap, state);
return true; return true;
error:
free(state);
return false;
} }
static struct eap_method eap_mschapv2 = { static struct eap_method eap_mschapv2 = {