[PATCH 2/2] wpa_supplicant: Allow re-open of log files with SIGHUP

Jouni Malinen j
Thu Nov 18 03:10:50 PST 2010


On Wed, Nov 17, 2010 at 04:58:06PM -0800, Ben Greear wrote:
> With this, one can cause wpa_supplicant log files to
> roll:
> 
> mv log.txt log.txt.old
> kill -HUP <wpa_supplicant-pid>

With the potential of getting configuration changes since SIGHUP is also
requesting wpa_supplicant to re-read configuration file.

> diff --git a/wpa_supplicant/main.c b/wpa_supplicant/main.c
> +void handle_sighup(int sig, void *signal_ctx)
> +{
> +	wpa_printf(MSG_INFO, "SIGHUP received - reopening log-file");
> +	wpa_debug_close_file();
> +	wpa_debug_open_file(params.wpa_debug_file_path);
> +	wpa_printf(MSG_INFO, "SIGHUP received - reopened log-file");
> +}

why would this be in main.c and not in wpa_supplicant.c where all builds
can use it? Please also note that there is already a SIGHUP handler in
wpa_supplicant.c (wpa_supplicant_reconfig) that should be used instead
of adding a new one.

> diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
> @@ -2420,6 +2421,10 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
> +#ifndef CONFIG_NATIVE_WINDOWS
> +	eloop_register_signal(SIGHUP, handle_sighup, NULL);
> +#endif /* CONFIG_NATIVE_WINDOWS */
> +

Proper way of registering eloop handler for SIGHUP is to call
eloop_register_signal_reconfig(). Anyway, this is already done in
wpa_supplicant, so there is no need to add new registration. Please also
note that this would break builds that use other main*.c file than
main.c.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list