aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Leffler <sam@FreeBSD.org>2008-03-24 20:13:41 +0000
committerSam Leffler <sam@FreeBSD.org>2008-03-24 20:13:41 +0000
commitbe6a4d63a5bc2be6043e1ea22d5ecf7105c5923c (patch)
treec2d22324a3e5d8b6010d1edc3d75a607e5b2e42e
parentf2afa83e728168e47c37af2a32a3b32afec888ec (diff)
downloadsrc-be6a4d63a5bc2be6043e1ea22d5ecf7105c5923c.tar.gz
src-be6a4d63a5bc2be6043e1ea22d5ecf7105c5923c.zip
add syslog support (committed on vendor branch as it's been sent upstream)
PR: bin/116190
Notes
Notes: svn path=/vendor/wpa_supplicant/dist/; revision=177572
-rw-r--r--contrib/wpa_supplicant/Makefile4
-rw-r--r--contrib/wpa_supplicant/common.c47
-rw-r--r--contrib/wpa_supplicant/defconfig3
-rw-r--r--contrib/wpa_supplicant/main.c12
-rw-r--r--contrib/wpa_supplicant/wpa_supplicant.c3
-rw-r--r--contrib/wpa_supplicant/wpa_supplicant_i.h5
6 files changed, 72 insertions, 2 deletions
diff --git a/contrib/wpa_supplicant/Makefile b/contrib/wpa_supplicant/Makefile
index 51114fa57a97..9bcdd83047a4 100644
--- a/contrib/wpa_supplicant/Makefile
+++ b/contrib/wpa_supplicant/Makefile
@@ -745,6 +745,10 @@ ifdef CONFIG_DEBUG_FILE
CFLAGS += -DCONFIG_DEBUG_FILE
endif
+ifdef CONFIG_DEBUG_SYSLOG
+CFLAGS += -DCONFIG_DEBUG_SYSLOG
+endif
+
OBJS += wpa_supplicant.o events.o
OBJS_t := $(OBJS) eapol_test.o radius.o radius_client.o
OBJS_t2 := $(OBJS) preauth_test.o
diff --git a/contrib/wpa_supplicant/common.c b/contrib/wpa_supplicant/common.c
index f226c68631b8..d0233d88f5d1 100644
--- a/contrib/wpa_supplicant/common.c
+++ b/contrib/wpa_supplicant/common.c
@@ -16,6 +16,10 @@
#include "common.h"
+#ifdef CONFIG_DEBUG_SYSLOG
+#include <syslog.h>
+#endif /* CONFIG_DEBUG_SYSLOG */
+
#ifdef CONFIG_DEBUG_FILE
static FILE *out_file = NULL;
@@ -23,6 +27,7 @@ static FILE *out_file = NULL;
int wpa_debug_level = MSG_INFO;
int wpa_debug_show_keys = 0;
int wpa_debug_timestamp = 0;
+int wpa_debug_syslog = 0;
static int hex2num(char c)
@@ -161,6 +166,40 @@ void wpa_debug_print_timestamp(void)
printf("%ld.%06u: ", (long) tv.sec, (unsigned int) tv.usec);
}
+void wpa_debug_open_syslog(void)
+{
+#ifdef CONFIG_DEBUG_SYSLOG
+ openlog("wpa_supplicant", LOG_PID | LOG_NDELAY, LOG_DAEMON);
+ wpa_debug_syslog++;
+#endif
+}
+
+void wpa_debug_close_syslog(void)
+{
+#ifdef CONFIG_DEBUG_SYSLOG
+ if (wpa_debug_syslog)
+ closelog();
+#endif
+}
+
+#ifdef CONFIG_DEBUG_SYSLOG
+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
@@ -179,6 +218,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) {
@@ -191,6 +235,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);
}
diff --git a/contrib/wpa_supplicant/defconfig b/contrib/wpa_supplicant/defconfig
index 52165988a883..73e5da555915 100644
--- a/contrib/wpa_supplicant/defconfig
+++ b/contrib/wpa_supplicant/defconfig
@@ -321,3 +321,6 @@ CONFIG_PEERKEY=y
# Add support for writing debug log to a file (/tmp/wpa_supplicant-log-#.txt)
#CONFIG_DEBUG_FILE=y
+
+# Add support for logging via syslog
+#CONFIG_DEBUG_SYSLOG=y
diff --git a/contrib/wpa_supplicant/main.c b/contrib/wpa_supplicant/main.c
index f371561cde66..5fe4e7bdba18 100644
--- a/contrib/wpa_supplicant/main.c
+++ b/contrib/wpa_supplicant/main.c
@@ -39,7 +39,7 @@ static void usage(void)
int i;
printf("%s\n\n%s\n"
"usage:\n"
- " wpa_supplicant [-BddhKLqqtuvwW] [-P<pid file>] "
+ " wpa_supplicant [-BddhKLqqstuvwW] [-P<pid file>] "
"[-g<global ctrl>] \\\n"
" -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] "
"[-p<driver_param>] \\\n"
@@ -77,6 +77,9 @@ static void usage(void)
printf(" -p = driver parameters\n"
" -P = PID file\n"
" -q = decrease debugging verbosity (-qq even less)\n"
+#ifdef CONFIG_DEBUG_SYSLOG
+ " -s = log output to syslog instead of stdout\n"
+#endif /* CONFIG_DEBUG_SYSLOG */
#ifdef CONFIG_CTRL_IFACE_DBUS
" -u = enable DBus control interface\n"
#endif /* CONFIG_CTRL_IFACE_DBUS */
@@ -147,7 +150,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:qtuvwW");
+ c = getopt(argc, argv, "b:Bc:C:D:df:g:hi:KLNp:P:qstuvwW");
if (c < 0)
break;
switch (c) {
@@ -208,6 +211,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;
diff --git a/contrib/wpa_supplicant/wpa_supplicant.c b/contrib/wpa_supplicant/wpa_supplicant.c
index 99f1185f048c..b7d3066d63fc 100644
--- a/contrib/wpa_supplicant/wpa_supplicant.c
+++ b/contrib/wpa_supplicant/wpa_supplicant.c
@@ -2488,6 +2488,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) {
@@ -2612,5 +2614,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();
}
diff --git a/contrib/wpa_supplicant/wpa_supplicant_i.h b/contrib/wpa_supplicant/wpa_supplicant_i.h
index 0d6f24a938df..95d171c0a23f 100644
--- a/contrib/wpa_supplicant/wpa_supplicant_i.h
+++ b/contrib/wpa_supplicant/wpa_supplicant_i.h
@@ -161,6 +161,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
+ */
+ const char *wpa_debug_syslog;
};
/**