summaryrefslogtreecommitdiffstats
path: root/src/connections/wireless
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-05-18 08:59:34 +0200
committerJames Rayner <james@archlinux.org>2009-05-18 08:59:34 +0200
commitbb3bade410cbfb4d19b65884b6525be7603dd686 (patch)
treed0defa7cffdfcbc084bf2124b661de249f8e79a9 /src/connections/wireless
parent92d6bde2e758466c5e524f84e424b7a98c749863 (diff)
downloadnetctl-bb3bade410cbfb4d19b65884b6525be7603dd686.tar.gz
netctl-bb3bade410cbfb4d19b65884b6525be7603dd686.tar.xz
wireless: check if iface is real, stop wpa_supplicant on failures
Diffstat (limited to 'src/connections/wireless')
-rw-r--r--src/connections/wireless28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/connections/wireless b/src/connections/wireless
index 66ccdab..653cb00 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -4,13 +4,19 @@
wireless_up() {
load_profile $1
-
+ . ${SUBR_DIR}/8021x
. ${SUBR_DIR}/wireless
+ # Check if interface exists
+ if [[ ! -e /sys/class/net/"$INTERFACE" ]]; then
+ if ! echo "$INTERFACE"|grep ":"; then
+ err_append "interface $INTERFACE does not exist"
+ return 1
+ fi
+ fi
+
# Kill any lingering wpa_supplicants.
- if [[ -f /var/run/wpa_supplicant_$INTERFACE.pid ]]; then
- kill $(cat /var/run/wpa_supplicant_$INTERFACE.pid)
- fi
+ stop_wpa $INTERFACE
# Most drivers (mac80211) need mode set before device is brought up
# Drivers generally default to managed, but set this to be sure.
@@ -57,7 +63,6 @@ wireless_up() {
wep_check $INTERFACE $TIMEOUT||return 1
;;
wpa)
- . ${SUBR_DIR}/8021x
# Quirk for broken drivers... http://bbs.archlinux.org/viewtopic.php?id=36384
quirk "wpaessid" && eval iwconfig $INTERFACE essid "\"$ESSID\""
@@ -78,14 +83,20 @@ wireless_up() {
# Connect!
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1
- wpa_check $INTERFACE $TIMEOUT || return 1
+ if ! wpa_check $INTERFACE $TIMEOUT; then
+ stop_wpa $INTERFACE
+ return 1
+ fi
;;
wpa-config)
. ${SUBR_DIR}/8021x
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1
- wpa_check $INTERFACE $TIMEOUT || return 1
+ if ! wpa_check $INTERFACE $TIMEOUT; then
+ stop_wpa $INTERFACE
+ return 1
+ fi
;;
esac
@@ -97,11 +108,12 @@ wireless_up() {
wireless_down() {
load_profile $1
+ . ${SUBR_DIR}/8021x
PROFILE=$1 NOETHERNETDOWN=$2
if ! checkyesno $2; then
${CONN_DIR}/ethernet down $1
fi
- wpa_cli terminate &> /dev/null
+ stop_wpa $INTERFACE
[[ "$SECURITY" == "wpa" ]] && rm -f "/tmp/wpa.${1// /}" # remove wpa config
iwconfig $INTERFACE essid off key off &> /dev/null
ifconfig $INTERFACE down