[ previous ] [ next ] [ threads ]
 
 From:  "Frank Edwards" <fedwards at internode dot on dot net>
 To:  <m0n0wall dash dev at lists dot m0n0 dot ch>
 Subject:  WPA Problem on 1.3b3
 Date:  Sat, 11 Aug 2007 12:39:22 +1000
Gday
 
I can also replicate this issue.
http://m0n0.ch/wall/list/showmsg.php?id=327/32
 
As indicated the problem exists only when hostapd is started during the
booting sequence. 
 
I think this may be related to use of nohup and/or the rc process
environment. I've altered interfaces.inc to include the hostapd -B flag (run
as a daemon process), and included changes to start/stop hostapd the same
way as  racoon in vpn.inc.

A brief look at the hostapd code suggests the only difference -B makes is a
call to daemon (man 3).

I've done some basic testing using FreeBSD and WinXP WPA-PSK clients.

Suggested fix...

--------------------
--- interfaces.inc.orig	Wed Aug  1 22:30:04 2007
+++ interfaces.inc	Fri Aug 10 20:06:17 2007
@@ -312,8 +312,11 @@
 	global $config, $g;
 	
 	/* kill any running hostapd */
-	killbypid("{$g['varrun_path']}/hostapd-$if.pid");
-	unlink_if_exists("{$g['varetc_path']}/hostapd-$if.conf");
+	killbyname("hostapd");
+	/* wait for process to die */
+	sleep(2);
+	/* send a SIGKILL to be sure */
+	sigkillbyname("hostapd", "KILL");
 	
 	/* killing hostapd leaves the interface in down state - make sure
it's up again */
 	mwexec("/sbin/ifconfig " . escapeshellarg($if) . " up");
@@ -335,12 +338,7 @@
 			fclose($fd);
 			
 			/* start hostapd */
-			$pid = mwexec_bg("/usr/sbin/hostapd
{$g['varetc_path']}/hostapd-$if.conf");
-			
-			/* write hostapd PID to file for later use */
-			$fd = fopen("{$g['varrun_path']}/hostapd-$if.pid",
"w");
-			fwrite($fd, $pid);
-			fclose($fd);
+			mwexec("/usr/sbin/hostapd -B
{$g['varetc_path']}/hostapd-$if.conf");
 		}
 		
 	} else {

--------------------

Regards

Frank