Martin Samuelsson @ 2005-12-22 (Thursday), 21:46 (+0100) > > I'm attaching a quick and dirty patch for running ifup and ifdown on the > > interfaces if they are listed in /etc/network/interfaces. > > Even after testing this before I sent it, I missed to add copying of the > wpa_action.sh script to /usr/sbin/ in debian/rules.
I've hacked up my local configuration to work with 0.4.7-3 now. It's a mess and not worth including in it's current form, but I'm documenting it here for future work. The upstream source should be fixed so that wpa_cli can wait for wpa_supplicant to be started. A quick'n'dirty -w argument is added in the patch. I had problems building the qt interface, don't know why. The init.d script doesn't work unless it looks like the attached one and OPTIONS in /etc/default/wpasupplicant needs to be renamed to SUPPLICANTOPTIONS. Until I recieve any input, I won't work faster on this. Even if I think the package would benefit from having interfaces brought up automatically when roaming. Please let me know if you care, anybody... -- /Martin
diff -Nur wpasupplicant-0.4.7/Makefile wpasupplicant-0.4.7-cospatched/Makefile --- wpasupplicant-0.4.7/Makefile 2005-11-21 02:42:12.000000000 +0100 +++ wpasupplicant-0.4.7-cospatched/Makefile 2006-02-13 11:12:28.533025536 +0100 @@ -33,7 +33,7 @@ install: all mkdir -p $(DESTDIR)/usr/local/sbin/ - for i in $(ALL); do cp $$i $(DESTDIR)/usr/local/sbin/$$i; done + for i in $(ALL) wpa_action.sh; do cp $$i $(DESTDIR)/usr/local/sbin/$$i; done OBJS = config.o \ eloop.o common.o md5.o \ diff -Nur wpasupplicant-0.4.7/debian/changelog wpasupplicant-0.4.7-cospatched/debian/changelog --- wpasupplicant-0.4.7/debian/changelog 2006-02-13 10:53:41.019687592 +0100 +++ wpasupplicant-0.4.7-cospatched/debian/changelog 2006-02-13 11:14:09.599240738 +0100 @@ -1,3 +1,9 @@ +wpasupplicant (0.4.7-3cos) unstable; urgency=low + + * Added action_script. (closes: #287223) + + -- Martin Samuelsson <[EMAIL PROTECTED]> Mon, 13 Feb 2006 11:13:49 +0100 + wpasupplicant (0.4.7-3) unstable; urgency=low * Another brown paper bag release. diff -Nur wpasupplicant-0.4.7/debian/wpasupplicant.init wpasupplicant-0.4.7-cospatched/debian/wpasupplicant.init --- wpasupplicant-0.4.7/debian/wpasupplicant.init 2006-02-13 10:53:41.299704812 +0100 +++ wpasupplicant-0.4.7-cospatched/debian/wpasupplicant.init 2006-02-13 11:56:55.493033815 +0100 @@ -10,12 +10,15 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/sbin/wpa_supplicant +SUPPLICANT=/usr/sbin/wpa_supplicant +WPACLI=/usr/sbin/wpa_cli PIDFILE="/var/run/wpasupplicant.pid" -PNAME="wpa_supplicant" +SUPPLICANTNAME="wpa_supplicant" +WPACLINAME="wpa_cli" # insane defaults -OPTIONS="-Bw" # daemonize and wait for interface +SUPPLICANTOPTIONS="-Bw" # daemonize and wait for interface +WPACLIOPTIONS="-Bw -a /usr/sbin/wpa_action.sh" CONFIG="/etc/wpa_supplicant.conf" ENABLED=0 @@ -29,15 +32,18 @@ [ -f $CONFIG ] || ( echo "No configuration file found, not starting."; \ exit 1; ) -[ -f $DAEMON ] || exit 0 +[ -f $SUPPLICANT ] || exit 0 +[ -f $WPACLI ] || exit 0 set -e case "$1" in start) echo -n "Starting wpa_supplicant: " - start-stop-daemon --start --name $PNAME \ - --oknodo --startas $DAEMON -- -B $OPTIONS + start-stop-daemon --start --name $SUPPLICANTNAME \ + --oknodo --startas $SUPPLICANT -- -B $SUPPLICANTOPTIONS + start-stop-daemon --start --name $WPACLINAME \ + --oknodo --startas $WPACLI -- -B $WPACLIOPTIONS if [ -f $PIFFILE ]; then echo "done."; else @@ -47,7 +53,9 @@ ;; stop) echo -n "Stopping wpa_supplicant: " - start-stop-daemon --stop --name $PNAME \ + start-stop-daemon --stop --name $SUPPLICANTNAME \ + --oknodo + start-stop-daemon --stop --name $WPACLINAME \ --oknodo echo "done." if [ -f $PIDFILE ]; then @@ -57,12 +65,16 @@ reload|force-reload) echo -n "Reloading wpa_supplicant: " start-stop-daemon --stop --signal HUP \ - --name $PNAME + --name $SUPPLICANTNAME + start-stop-daemon --stop --signal HUP \ + --name $WPACLINAME echo "done." ;; restart) echo -n "Stopping wpa_supplicant: " - start-stop-daemon --stop --name $PNAME \ + start-stop-daemon --stop --name $SUPPLICANTNAME \ + --oknodo + start-stop-daemon --stop --name $WPACLINAME \ --oknodo echo "done." if [ -f $PIDFILE ]; then @@ -70,8 +82,10 @@ fi echo -n "Starting wpa_supplicant: " - start-stop-daemon --start --name $PNAME \ - --oknodo --startas $DAEMON -- -B $OPTIONS + start-stop-daemon --start --name $SUPPLICANTNAME \ + --oknodo --startas $SUPPLICANT -- -B $SUPPLICANTOPTIONS + start-stop-daemon --start --name $WPACLINAME \ + --oknodo --startas $WPACLI -- -B $WPACLIOPTIONS if [ -f $PIFFILE ]; then echo "done."; else diff -Nur wpasupplicant-0.4.7/wpa_action.sh wpasupplicant-0.4.7-cospatched/wpa_action.sh --- wpasupplicant-0.4.7/wpa_action.sh 1970-01-01 01:00:00.000000000 +0100 +++ wpasupplicant-0.4.7-cospatched/wpa_action.sh 2006-02-13 11:11:44.002287058 +0100 @@ -0,0 +1,21 @@ +IFNAME=$1 +CMD=$2 + +if [ "$CMD" == "CONNECTED" ]; then + BSSID=`wpa_cli -i$IFNAME status | grep ^bssid= | cut -f2- -d=` + SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=` + + # First try to use any logical network interface named as the BSSID ... + /bin/grep --quiet --no-messages "^iface $BSSID inet" /etc/network/interfaces && /sbin/ifup "$1"="$BSSID" && exit + + # ... then try any logical network interface named as the SSID ... + /bin/grep --quiet --no-messages "^iface $SSID inet" /etc/network/interfaces && /sbin/ifup "$1"="$SSID" && exit + + # ... or simply bring up the interface if configuration tells us. + /bin/grep --quiet --no-messages "^iface $1 inet" /etc/network/interfaces && /sbin/ifup "$1" +fi + +if [ "$CMD" == "DISCONNECTED" ]; then + # bring down interface if configuration mentions it + /bin/grep --quiet --no-messages "^iface $1 inet" /etc/network/interfaces && /sbin/ifdown "$1" +fi diff -Nur wpasupplicant-0.4.7/wpa_cli.c wpasupplicant-0.4.7-cospatched/wpa_cli.c --- wpasupplicant-0.4.7/wpa_cli.c 2005-10-16 00:51:02.000000000 +0200 +++ wpasupplicant-0.4.7-cospatched/wpa_cli.c 2006-02-13 11:50:21.092779643 +0100 @@ -1247,6 +1247,7 @@ int warning_displayed = 0; int c; int daemonize = 0; + int waitforsupplicant = 0; FILE *f; const char *global = NULL; @@ -1259,7 +1260,7 @@ #endif /* CONFIG_NATIVE_WINDOWS */ for (;;) { - c = getopt(argc, argv, "a:Bg:hi:p:P:v"); + c = getopt(argc, argv, "a:Bwg:hi:p:P:v"); if (c < 0) break; switch (c) { @@ -1269,6 +1270,9 @@ case 'B': daemonize = 1; break; + case 'w': + waitforsupplicant = 1; + break; case 'g': global = optarg; break; @@ -1332,9 +1336,11 @@ } if (!interactive) { - perror("Failed to connect to wpa_supplicant - " - "wpa_ctrl_open"); - return -1; + if(!waitforsupplicant) { + perror("Failed to connect to wpa_supplicant - " + "wpa_ctrl_open"); + return -1; + } } if (!warning_displayed) {
#!/bin/sh # Buyer beware! This is really only useful if you have a # MiniPCI or other permanent wireless device. # However, the wpa_supplicant daemon will start, and sit waiting # for the name interface to come up. Therefore, if you want to use # this with pcmcia or other nonsense, it may be best to ifrename # your wireless interface if it has an "ethX" name that is variable. PATH=/sbin:/bin:/usr/sbin:/usr/bin SUPPLICANT=/usr/sbin/wpa_supplicant WPACLI=/usr/sbin/wpa_cli PIDFILE="/var/run/wpasupplicant.pid" SUPPLICANTNAME="wpa_supplicant" WPACLINAME="wpa_cli" # insane defaults SUPPLICANTOPTIONS="-Bw" # daemonize and wait for interface WPACLIOPTIONS="-Bw -a /usr/sbin/wpa_action.sh" CONFIG="/etc/wpa_supplicant.conf" ENABLED=0 [ -f /etc/default/wpasupplicant ] && . /etc/default/wpasupplicant if [ "$ENABLED" = "0" ]; then echo "wpasupplicant: disabled, see /etc/default/wpasupplicant" exit 0; fi [ -f $CONFIG ] || ( echo "No configuration file found, not starting."; \ exit 1; ) [ -f $SUPPLICANT ] || exit 0 [ -f $WPACLI ] || exit 0 set -e case "$1" in start) echo -n "Starting wpa_supplicant: " start-stop-daemon --start --name $SUPPLICANTNAME \ --oknodo --startas $SUPPLICANT -- -B $SUPPLICANTOPTIONS start-stop-daemon --start --name $WPACLINAME \ --oknodo --startas $WPACLI -- -B $WPACLIOPTIONS # if [ -f $PIDFILE ]; then # echo "done."; # else # echo "failed."; # exit 1; # fi ;; stop) echo -n "Stopping wpa_supplicant: " start-stop-daemon --stop --name $SUPPLICANTNAME \ --oknodo echo "done." if [ -f $PIDFILE ]; then rm -f $PIDFILE; fi ;; reload|force-reload) echo -n "Reloading wpa_supplicant: " start-stop-daemon --stop --signal HUP \ --name $SUPPLICANTNAME echo "done." ;; restart) echo -n "Stopping wpa_supplicant: " start-stop-daemon --stop --name $SUPPLICANTNAME \ --oknodo echo "done." if [ -f $PIDFILE ]; then rm -f $PIDFILE; fi sleep 5 echo -n "Starting wpa_supplicant: " start-stop-daemon --start --name $SUPPLICANTNAME \ --oknodo --startas $SUPPLICANT -- -B $SUPPLICANTOPTIONS start-stop-daemon --start --name $WPACLINAME \ --oknodo --startas $WPACLI -- -B $WPACLIOPTIONS # if [ -f $PIFFILE ]; then # echo "done."; # else # echo "failed."; # exit 1; # fi ;; *) echo "Usage: wpa_supplicant {start|stop|restart|reload|force-reload}" >&2 exit 1 ;; esac exit 0