From ea61aa1de1887b14440b02de711383d775ecc004 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 27 Sep 2013 23:30:20 +0300 Subject: [PATCH] Add no_ctrl_interface config param to clear ctrl_interface This can be used to override previously set ctrl_interface value in a way that clears the variable to NULL instead of empty string. The only real use case for this is to disable per-interface ctrl_interface from the additional control file (-I) in case ctrl_interface was set in the main configuration file. It should be noted that zero-length ctrl_interface parameter can be used to initiate some control interface backends, so simpler designs were not available for this. The format of the new parameter is not exactly cleanest due to configuration file parsing assumptions. For example: ctrl_interface=.... no_ctrl_interface= would end up with ctrl_interface=NULL. Signed-hostap: Jouni Malinen --- wpa_supplicant/config.c | 12 ++++++++++++ wpa_supplicant/ctrl_iface_unix.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 5ab11281e..f7ce80211 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -3082,6 +3082,17 @@ static int wpa_config_process_ap_vendor_elements( } +static int wpa_config_process_no_ctrl_interface( + const struct global_parse_data *data, + struct wpa_config *config, int line, const char *pos) +{ + wpa_printf(MSG_DEBUG, "no_ctrl_interface -> ctrl_interface=NULL"); + os_free(config->ctrl_interface); + config->ctrl_interface = NULL; + return 0; +} + + #ifdef OFFSET #undef OFFSET #endif /* OFFSET */ @@ -3101,6 +3112,7 @@ static int wpa_config_process_ap_vendor_elements( static const struct global_parse_data global_fields[] = { #ifdef CONFIG_CTRL_IFACE { STR(ctrl_interface), 0 }, + { FUNC_NO_VAR(no_ctrl_interface), 0 }, { STR(ctrl_interface_group), 0 } /* deprecated */, #endif /* CONFIG_CTRL_IFACE */ { INT_RANGE(eapol_version, 1, 2), 0 }, diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c index 8abf57d10..5fe9a4e43 100644 --- a/wpa_supplicant/ctrl_iface_unix.c +++ b/wpa_supplicant/ctrl_iface_unix.c @@ -586,6 +586,8 @@ void wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv) os_free(fname); } + if (priv->wpa_s->conf->ctrl_interface == NULL) + goto free_dst; buf = os_strdup(priv->wpa_s->conf->ctrl_interface); if (buf == NULL) goto free_dst;