Extended ctrl_iface SET_NETWORK to allow variables to be unset
authorJouni Malinen <jouni.malinen@atheros.com>
Thu, 2 Oct 2008 09:16:25 +0000 (12:16 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 2 Oct 2008 09:16:25 +0000 (12:16 +0300)
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.

wpa_supplicant/config.c

index e8065d0..fc64be1 100644 (file)
@@ -95,6 +95,14 @@ static int wpa_config_parse_str(const struct parse_data *data,
        size_t res_len, *dst_len;
        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);
        if (tmp == NULL) {
                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;
        }
 
+set:
        dst = (char **) (((u8 *) ssid) + (long) data->param1);
        dst_len = (size_t *) (((u8 *) ssid) + (long) data->param2);
        os_free(*dst);
@@ -1007,6 +1016,14 @@ static int wpa_config_parse_password(const struct parse_data *data,
 {
        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) {
                char *tmp;
                size_t res_len;