Extended ctrl_iface SET_NETWORK to allow variables to be unset

Setting the value of the SET_NETWORK command to NULL (without quotation)
unsets the variable, i.e., removes it from configuration file. This is
needed to allow GUI programs to clear variables, e.g., identity for
EAP-AKA/SIM.
This commit is contained in:
Jouni Malinen 2008-10-02 12:16:25 +03:00 committed by Jouni Malinen
parent 8de594965f
commit b56c0546b7

View file

@ -95,6 +95,14 @@ static int wpa_config_parse_str(const struct parse_data *data,
size_t res_len, *dst_len; size_t res_len, *dst_len;
char **dst, *tmp; char **dst, *tmp;
if (os_strcmp(value, "NULL") == 0) {
wpa_printf(MSG_DEBUG, "Unset configuration string '%s'",
data->name);
tmp = NULL;
res_len = 0;
goto set;
}
tmp = wpa_config_parse_string(value, &res_len); tmp = wpa_config_parse_string(value, &res_len);
if (tmp == NULL) { if (tmp == NULL) {
wpa_printf(MSG_ERROR, "Line %d: failed to parse %s '%s'.", wpa_printf(MSG_ERROR, "Line %d: failed to parse %s '%s'.",
@ -127,6 +135,7 @@ static int wpa_config_parse_str(const struct parse_data *data,
return -1; return -1;
} }
set:
dst = (char **) (((u8 *) ssid) + (long) data->param1); dst = (char **) (((u8 *) ssid) + (long) data->param1);
dst_len = (size_t *) (((u8 *) ssid) + (long) data->param2); dst_len = (size_t *) (((u8 *) ssid) + (long) data->param2);
os_free(*dst); os_free(*dst);
@ -1007,6 +1016,14 @@ static int wpa_config_parse_password(const struct parse_data *data,
{ {
u8 *hash; u8 *hash;
if (os_strcmp(value, "NULL") == 0) {
wpa_printf(MSG_DEBUG, "Unset configuration string 'password'");
os_free(ssid->eap.password);
ssid->eap.password = NULL;
ssid->eap.password_len = 0;
return 0;
}
if (os_strncmp(value, "hash:", 5) != 0) { if (os_strncmp(value, "hash:", 5) != 0) {
char *tmp; char *tmp;
size_t res_len; size_t res_len;