dhclient/wpa_supplicant patch

From: Brooks Davis <brooks_at_one-eyed-alien.net>
Date: Tue, 28 Jun 2005 22:33:35 -0700
Below you will find a patch which I believe solves the major issues with
the removable_interfaces variable, and adds wpa_supplicant support to
the startup scripts.  The significant behavioral changes are starting
wpa_supplicant it the ifconfig_<ifn> entry contains WPA, always
including removable interfaces in the list of potential interfaces,
always running /etc/rc.d/netif's start/stop code when passed a list of
interfaces on all interfaces, even if they don't exist, and replacing
pccard_ifconfig with a new ifconfig_DEFAULT variable which applies to
all interfaces that lack an ifconfig_<ifn> line.

Please review and test.  I plan to commit tomorrow PDT unless there are
issues.

-- Brooks

Index: network.subr
===================================================================
RCS file: /usr/cvs/src/etc/network.subr,v
retrieving revision 1.162
diff -u -p -u -r1.162 network.subr
--- network.subr	7 Jun 2005 23:59:45 -0000	1.162
+++ network.subr	29 Jun 2005 01:22:03 -0000
_at__at_ -48,7 +48,7 _at__at_ ifconfig_up()
 	fi
 
 	if wpaif $1; then
-		#/etc/rc.d/wpa_supplicant start $1
+		/etc/rc.d/wpa_supplicant start $1
 		_cfg=0		# XXX: not sure this should count
 	fi
 
_at__at_ -89,7 +89,7 _at__at_ ifconfig_down()
 	IFS="$oldifs"
 
 	if wpaif $1; then
-		#/etc/rc.d/wpa_supplicant stop $1
+		/etc/rc.d/wpa_supplicant stop $1
 		_cfg=0
 	fi
 
_at__at_ -113,16 +113,11 _at__at_ _ifconfig_getargs()
 	fi
 
 	eval _args=\$ifconfig_$1
-	if [ -z "$_args" -a -n "${pccard_ifconfig}" ]; then
-		for _if in ${removable_interfaces} ; do
-			if [ "$_if" = "$_ifn" ] ; then
-				_args=${pccard_ifconfig}
-				break
-			fi
-		done
+	if [ -z "$_args" ]; then
+		_args=$ifconfig_DEFAULT
 	fi
 
-	echo $_args
+	echo "$_args"
 }
 
 # ifconfig_getargs if
_at__at_ -394,7 +389,7 _at__at_ list_net_interfaces()
 		_tmplist="`ifconfig -l`"
 		;;
 	*)
-		_tmplist="${network_interfaces} ${cloned_interfaces}"
+		_tmplist="${network_interfaces} ${removable_interfaces} ${cloned_interfaces}"
 		;;
 	esac
 
_at__at_ -408,37 +403,15 _at__at_ list_net_interfaces()
 	_aprefix=
 	_bprefix=
 	for _if in ${_tmplist} ; do
-		eval _ifarg="\$ifconfig_${_if}"
-		case "$_ifarg" in
-		[Dd][Hh][Cc][Pp])
+		if dhcpif $_if; then
 			_dhcplist="${_dhcplist}${_aprefix}${_if}"
 			[ -z "$_aprefix" ] && _aprefix=' '
-			;;
-		''|*)
+		elif [ -n "`_ifconfig_getargs $if`" ]; then
 			_nodhcplist="${_nodhcplist}${_bprefix}${_if}"
 			[ -z "$_bprefix" ] && _bprefix=' '
-			;;
-		esac
+		fi
 	done
 
-	case ${pccard_ifconfig} in
-	[Dd][Hh][Cc][Pp])
-		for _if in ${removable_interfaces} ; do
-			_test_if=`ifconfig ${_if} 2>&1`
-			case "$_test_if" in
-			"ifconfig: interface $_if does not exist")
-				;;
-			*)
-				_dhcplist="${_dhcplist}${_aprefix}${_if}"
-				[ -z "$_aprefix" ] && _aprefix=' '
-				;;
-			esac
-		done
-		;;
-	*)
-		;;
-	esac
-
 	case "$type" in
 	nodhcp)
 		echo $_nodhcplist
Index: rc.d/Makefile
===================================================================
RCS file: /usr/cvs/src/etc/rc.d/Makefile,v
retrieving revision 1.52
diff -u -p -u -r1.52 Makefile
--- rc.d/Makefile	29 Apr 2005 23:02:56 -0000	1.52
+++ rc.d/Makefile	29 Jun 2005 01:23:12 -0000
_at__at_ -36,7 +36,7 _at__at_ FILES=	DAEMON LOGIN NETWORKING SERVERS \
 	timed tmp \
 	ugidfw usbd \
 	var virecover \
-	watchdogd \
+	watchdogd wpa_supplicant \
 	ypbind yppasswdd ypserv \
 	ypset ypupdated ypxfrd
 FILESDIR=	/etc/rc.d
Index: rc.d/netif
===================================================================
RCS file: /usr/cvs/src/etc/rc.d/netif,v
retrieving revision 1.13
diff -u -p -u -r1.13 netif
--- rc.d/netif	7 Jun 2005 04:49:12 -0000	1.13
+++ rc.d/netif	29 Jun 2005 02:13:48 -0000
_at__at_ -109,13 +109,10 _at__at_ network_common()
 	#
 	_cooked_list=
 	if [ -n "$_cmdifn" ]; then
-		for i in $_cmdifn ; do
-			eval _if=\"`expr "$_ifn_list" : ".*\(${i}\).*"`\"
-			if [ -z "$_if" ]; then
-				err 1 "No such network interface: $i"
-			fi
-			_cooked_list="$_cooked_list $_if"
-		done
+		# Don't check that the interfaces exist.  We need to run
+		# the down code even when the interface doesn't exist to
+		# kill off wpa_supplicant.
+		_cooked_list="$_cmdifn"
 	else
 		_cooked_list="$_ifn_list"
 	fi
--- rc.d/wpa_supplicant	Tue Jun 28 22:24:18 2005
+++ rc.d/wpa_supplicant	Tue Jun 28 18:51:32 2005
_at__at_ -0,0 +1,33 _at__at_
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: wpa_supplicant
+# REQUIRE: mountcritremote
+# KEYWORD: nojail nostart
+
+. /etc/rc.subr
+. /etc/network.subr
+
+name="wpa_supplicant"
+rcvar=
+command="/usr/sbin/${name}"
+conf_file="/etc/wpa_supplicant.conf"
+
+ifn="$2"
+if [ -z "$ifn" ]; then
+	return 1
+fi
+
+load_rc_config $name
+
+if ! wpaif $ifn; then
+	return 1
+fi
+
+pid_file="/var/run/${name}/${ifn}.pid"
+command_args="-B -q -i $ifn -P $pid_file -c $conf_file"
+required_files=$conf_file
+
+run_rc_command "$1"

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

Received on Wed Jun 29 2005 - 03:33:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:37 UTC