From 02af9c90fb8589f78ebed43a6f8f58777deaa412 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 3 Aug 2012 22:12:55 +0300 Subject: [PATCH] EXT PW: Allow Interwork cred block to use external storage for password Signed-hostap: Jouni Malinen --- wpa_supplicant/config.c | 9 +++++++++ wpa_supplicant/config.h | 5 +++++ wpa_supplicant/interworking.c | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 6573ba82c..0ce4d0949 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -2326,6 +2326,14 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var, return 0; } + if (os_strcmp(var, "password") == 0 && + os_strncmp(value, "ext:", 4) == 0) { + os_free(cred->password); + cred->password = os_strdup(value); + cred->ext_password = 1; + return 0; + } + val = wpa_config_parse_string(value, &len); if (val == NULL) { wpa_printf(MSG_ERROR, "Line %d: invalid field '%s' string " @@ -2348,6 +2356,7 @@ int wpa_config_set_cred(struct wpa_cred *cred, const char *var, if (os_strcmp(var, "password") == 0) { os_free(cred->password); cred->password = val; + cred->ext_password = 0; return 0; } diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h index c8c154251..080c0cd9a 100644 --- a/wpa_supplicant/config.h +++ b/wpa_supplicant/config.h @@ -80,6 +80,11 @@ struct wpa_cred { */ char *password; + /** + * ext_password - Whether password is a name for external storage + */ + int ext_password; + /** * ca_cert - CA certificate for Interworking network selection */ diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c index e0e209c0f..ebc668b84 100644 --- a/wpa_supplicant/interworking.c +++ b/wpa_supplicant/interworking.c @@ -894,9 +894,15 @@ static int interworking_set_eap_params(struct wpa_ssid *ssid, wpa_config_set_quoted(ssid, "identity", cred->username) < 0) return -1; - if (cred->password && cred->password[0] && - wpa_config_set_quoted(ssid, "password", cred->password) < 0) - return -1; + if (cred->password && cred->password[0]) { + if (cred->ext_password && + wpa_config_set(ssid, "password", cred->password, 0) < 0) + return -1; + if (!cred->ext_password && + wpa_config_set_quoted(ssid, "password", cred->password) < + 0) + return -1; + } if (cred->client_cert && cred->client_cert[0] && wpa_config_set_quoted(ssid, "client_cert", cred->client_cert) < 0)