Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Sep 2007 21:39:06 GMT
From:      Artem Naluzhnyy <tut@nhamon.com.ua>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   bin/116190: [patch] add syslog support for wpa_supplicant
Message-ID:  <200709072139.l87Ld6jP075820@www.freebsd.org>
Resent-Message-ID: <200709072140.l87Le2q7082197@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         116190
>Category:       bin
>Synopsis:       [patch] add syslog support for wpa_supplicant
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 07 21:40:02 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Artem Naluzhnyy
>Release:        7.0-CURRENT
>Organization:
>Environment:
FreeBSD tut.at.home 7.0-CURRENT FreeBSD 7.0-CURRENT #4: Tue Sep  4 18:10:44 EEST 2007     root@tut.at.home:/usr/obj/usr/src/sys/TUT  i386
>Description:
What about syslog capability for wpa_supplicant? See the patch attached.


We also have to remove '-q' option from appropriate rc.d/wpa_supplicant script to set wpa_supplicant debug level back to normal:

#------------------------------------------------------------
--- wpa_supplicant.orig	2005-10-20 01:26:47.000000000 +0300
+++ wpa_supplicant	2007-09-07 22:27:04.000000000 +0300
@@ -32,7 +32,7 @@
 load_rc_config $name
 
 pid_file="/var/run/${name}/${ifn}.pid"
-command_args="-B -q -i $ifn -c $conf_file -D $driver -P $pid_file"
+command_args="-B -i $ifn -c $conf_file -D $driver -P $pid_file"
 required_files=$conf_file
 
 run_rc_command "$1"
#------------------------------------------------------------


Here is an example of /var/log/messages for the default wpa_supplicant debug level:

Sep  6 02:57:38 tut wpa_supplicant[86187]: Trying to associate with 00:19:5b:da:aa:fc (SSID='Blackhole' freq=2457 MHz)
Sep  6 02:57:38 tut kernel: ath0: link state changed to UP
Sep  6 02:57:38 tut wpa_supplicant[86187]: Associated with 00:19:5b:da:aa:fc
Sep  6 02:57:38 tut wpa_supplicant[86187]: WPA: Key negotiation completed with 00:19:5b:da:aa:fc [PTK=CCMP GTK=TKIP]
Sep  6 02:57:38 tut wpa_supplicant[86187]: CTRL-EVENT-CONNECTED - Connection to 00:19:5b:da:aa:fc completed (auth) [id=0 id_str=]
Sep  6 02:57:45 tut dhclient: New IP Address (ath0): 192.168.0.180
Sep  6 02:57:45 tut dhclient: New Subnet Mask (ath0): 255.255.255.0
Sep  6 02:57:45 tut dhclient: New Broadcast Address (ath0): 192.168.0.255
Sep  6 02:57:45 tut dhclient: New Routers (ath0): 192.168.0.1
..
Sep  6 02:57:53 tut kernel: ath0: link state changed to DOWN
Sep  6 02:57:53 tut wpa_supplicant[86187]: CTRL-EVENT-TERMINATING - signal 2 received
Sep  6 02:57:53 tut dhclient[86212]: connection closed
Sep  6 02:57:53 tut dhclient[86212]: exiting.

>How-To-Repeat:

>Fix:
--- common.c.orig	2007-08-28 02:35:47.000000000 +0300
+++ common.c	2007-09-07 21:55:03.000000000 +0300
@@ -16,6 +16,7 @@
 
 #include "common.h"
 
+#include <syslog.h>
 
 #ifdef CONFIG_DEBUG_FILE
 static FILE *out_file = NULL;
@@ -177,6 +178,7 @@
 void wpa_printf(int level, char *fmt, ...)
 {
 	va_list ap;
+	int syslog_priority;
 
 	va_start(ap, fmt);
 	if (level >= wpa_debug_level) {
@@ -192,6 +194,25 @@
 #ifdef CONFIG_DEBUG_FILE
 		}
 #endif /* CONFIG_DEBUG_FILE */
+		
+		switch(level) {
+			case MSG_MSGDUMP:
+			case MSG_DEBUG:
+				syslog_priority = LOG_DEBUG;
+				break;
+			case MSG_INFO:
+				syslog_priority = LOG_NOTICE;
+				break;
+			case MSG_WARNING:
+				syslog_priority = LOG_WARNING;
+				break;
+			case MSG_ERROR:
+				syslog_priority = LOG_ERR;
+				break;
+			default:
+				syslog_priority = LOG_INFO;
+		}
+		vsyslog(syslog_priority, fmt, ap);
 	}
 	va_end(ap);
 }
--- wpa_supplicant.c.orig	2007-08-28 02:35:56.000000000 +0300
+++ wpa_supplicant.c	2007-09-07 21:32:09.000000000 +0300
@@ -38,6 +38,8 @@
 #include "wpa_ctrl.h"
 #include "mlme.h"
 
+#include <syslog.h>
+
 const char *wpa_supplicant_version =
 "wpa_supplicant v" VERSION_STR "\n"
 "Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi> and contributors";
@@ -2484,6 +2486,8 @@
 	wpa_debug_use_file = params->wpa_debug_use_file;
 	wpa_debug_open_file();
 
+	openlog("wpa_supplicant", LOG_PID | LOG_NDELAY, LOG_DAEMON);
+
 	ret = eap_peer_register_methods();
 	if (ret) {
 		wpa_printf(MSG_ERROR, "Failed to register EAP methods");
@@ -2609,5 +2613,6 @@
 	os_free(global->params.ctrl_interface);
 
 	os_free(global);
+	closelog();
 	wpa_debug_close_file();
 }


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709072139.l87Ld6jP075820>