mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Add support for wpa_supplicant syslog output
Enable for build: CFLAGS += -DCONFIG_DEBUG_SYSLOG in .config Enable at runtime: -s on command line
This commit is contained in:
parent
af12135524
commit
daa70d49de
@ -16,6 +16,12 @@
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
#include <syslog.h>
|
||||
|
||||
static int wpa_debug_syslog = 0;
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
|
||||
|
||||
#ifdef CONFIG_DEBUG_FILE
|
||||
static FILE *out_file = NULL;
|
||||
@ -45,6 +51,39 @@ void wpa_debug_print_timestamp(void)
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
void wpa_debug_open_syslog(void)
|
||||
{
|
||||
openlog("wpa_supplicant", LOG_PID | LOG_NDELAY, LOG_DAEMON);
|
||||
wpa_debug_syslog++;
|
||||
}
|
||||
|
||||
|
||||
void wpa_debug_close_syslog(void)
|
||||
{
|
||||
if (wpa_debug_syslog)
|
||||
closelog();
|
||||
}
|
||||
|
||||
|
||||
static int syslog_priority(int level)
|
||||
{
|
||||
switch (level) {
|
||||
case MSG_MSGDUMP:
|
||||
case MSG_DEBUG:
|
||||
return LOG_DEBUG;
|
||||
case MSG_INFO:
|
||||
return LOG_NOTICE;
|
||||
case MSG_WARNING:
|
||||
return LOG_WARNING;
|
||||
case MSG_ERROR:
|
||||
return LOG_ERR;
|
||||
}
|
||||
return LOG_INFO;
|
||||
}
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
|
||||
|
||||
/**
|
||||
* wpa_printf - conditional printf
|
||||
* @level: priority level (MSG_*) of the message
|
||||
@ -62,6 +101,11 @@ void wpa_printf(int level, char *fmt, ...)
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (level >= wpa_debug_level) {
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
if (wpa_debug_syslog) {
|
||||
vsyslog(syslog_priority(level), fmt, ap);
|
||||
} else {
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
wpa_debug_print_timestamp();
|
||||
#ifdef CONFIG_DEBUG_FILE
|
||||
if (out_file) {
|
||||
@ -74,6 +118,9 @@ void wpa_printf(int level, char *fmt, ...)
|
||||
#ifdef CONFIG_DEBUG_FILE
|
||||
}
|
||||
#endif /* CONFIG_DEBUG_FILE */
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
}
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
@ -205,6 +205,23 @@ enum hostapd_logger_level {
|
||||
};
|
||||
|
||||
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
|
||||
void wpa_debug_open_syslog(void);
|
||||
void wpa_debug_close_syslog(void);
|
||||
|
||||
#else /* CONFIG_DEBUG_SYSLOG */
|
||||
|
||||
static inline void wpa_debug_open_syslog(void)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void wpa_debug_close_syslog(void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
|
||||
|
||||
#ifdef EAPOL_TEST
|
||||
#define WPA_ASSERT(a) \
|
||||
|
@ -26,7 +26,7 @@ static void usage(void)
|
||||
int i;
|
||||
printf("%s\n\n%s\n"
|
||||
"usage:\n"
|
||||
" wpa_supplicant [-BddhKLqqtuvW] [-P<pid file>] "
|
||||
" wpa_supplicant [-BddhKLqqstuvW] [-P<pid file>] "
|
||||
"[-g<global ctrl>] \\\n"
|
||||
" -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
|
||||
"[-p<driver_param>] \\\n"
|
||||
@ -57,8 +57,11 @@ static void usage(void)
|
||||
printf(" -f = log output to debug file instead of stdout\n");
|
||||
#endif /* CONFIG_DEBUG_FILE */
|
||||
printf(" -g = global ctrl_interface\n"
|
||||
" -K = include keys (passwords, etc.) in debug output\n"
|
||||
" -t = include timestamp in debug messages\n"
|
||||
" -K = include keys (passwords, etc.) in debug output\n");
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
printf(" -s = log output to syslog instead of stdout\n");
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
printf(" -t = include timestamp in debug messages\n"
|
||||
" -h = show this help text\n"
|
||||
" -L = show license (GPL and BSD)\n"
|
||||
" -p = driver parameters\n"
|
||||
@ -72,7 +75,9 @@ static void usage(void)
|
||||
" -N = start describing new interface\n");
|
||||
|
||||
printf("example:\n"
|
||||
" wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf\n");
|
||||
" wpa_supplicant -D%s -iwlan0 -c/etc/wpa_supplicant.conf\n",
|
||||
wpa_supplicant_drivers[i] ?
|
||||
wpa_supplicant_drivers[i]->name : "wext");
|
||||
#endif /* CONFIG_NO_STDOUT_DEBUG */
|
||||
}
|
||||
|
||||
@ -133,7 +138,7 @@ int main(int argc, char *argv[])
|
||||
wpa_supplicant_fd_workaround();
|
||||
|
||||
for (;;) {
|
||||
c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qtuvW");
|
||||
c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qstuvW");
|
||||
if (c < 0)
|
||||
break;
|
||||
switch (c) {
|
||||
@ -194,6 +199,11 @@ int main(int argc, char *argv[])
|
||||
case 'q':
|
||||
params.wpa_debug_level++;
|
||||
break;
|
||||
#ifdef CONFIG_DEBUG_SYSLOG
|
||||
case 's':
|
||||
params.wpa_debug_syslog++;
|
||||
break;
|
||||
#endif /* CONFIG_DEBUG_SYSLOG */
|
||||
case 't':
|
||||
params.wpa_debug_timestamp++;
|
||||
break;
|
||||
|
@ -2074,6 +2074,8 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
|
||||
return NULL;
|
||||
|
||||
wpa_debug_open_file(params->wpa_debug_file_path);
|
||||
if (params->wpa_debug_syslog)
|
||||
wpa_debug_open_syslog();
|
||||
|
||||
ret = eap_peer_register_methods();
|
||||
if (ret) {
|
||||
@ -2224,5 +2226,6 @@ void wpa_supplicant_deinit(struct wpa_global *global)
|
||||
os_free(global->params.ctrl_interface);
|
||||
|
||||
os_free(global);
|
||||
wpa_debug_close_syslog();
|
||||
wpa_debug_close_file();
|
||||
}
|
||||
|
@ -157,6 +157,11 @@ struct wpa_params {
|
||||
* wpa_debug_file_path - Path of debug file or %NULL to use stdout
|
||||
*/
|
||||
const char *wpa_debug_file_path;
|
||||
|
||||
/**
|
||||
* wpa_debug_syslog - Enable log output through syslog
|
||||
*/
|
||||
int wpa_debug_syslog;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user