summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/8021x22
-rw-r--r--src/connections/ethernet3
-rw-r--r--src/connections/ethernet-iproute4
-rw-r--r--src/connections/wireless18
4 files changed, 28 insertions, 19 deletions
diff --git a/src/8021x b/src/8021x
index cccfd3a..78537a4 100644
--- a/src/8021x
+++ b/src/8021x
@@ -7,9 +7,9 @@ wpa_check()
while [[ $timeout -lt $TIMEOUT ]]; do
( # Sometimes wpa_supplicant isn't ready so silence errors for 2s only to avoid hiding real errors
if [[ $timeout -lt 2 ]]; then
- eval `wpa_cli status 2> /dev/null|grep wpa_state`
+ eval $(wpa_cli -i "$INTERFACE" status 2> /dev/null | grep wpa_state)
else
- eval `wpa_cli status|grep wpa_state`
+ eval $(wpa_cli -i "$INTERFACE" status | grep wpa_state)
fi
[[ "$wpa_state" = "COMPLETED" ]]
) && return 0
@@ -17,15 +17,19 @@ wpa_check()
let timeout++
done
echo "$wpa_state"
- wpa_cli terminate >/dev/null 2>&1
+ # wpa_cli -i "$INTERFACE" terminate >/dev/null 2>&1 # callers sometimes called stop_wpa, which does more but seems redundant
+ # termination should either be handled properly here, or by callers
+ stop_wpa "$INTERFACE"
return 1
}
start_wpa()
{
- INTERFACE="$1"; WPA_CONF="$2"; WPA_OPTS="$3"
+ local INTERFACE="$1" WPA_CONF="$2"
+ shift 2
+ local WPA_OPTS="$*"
- wpa_supplicant -B -P/var/run/wpa_supplicant_${INTERFACE}.pid -i"${INTERFACE}" -c "$WPA_CONF" $WPA_OPTS
+ wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "${INTERFACE}" -c "$WPA_CONF" $WPA_OPTS
sleep 1
if [[ ! -f "/var/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
@@ -35,9 +39,11 @@ start_wpa()
stop_wpa()
{
- wpa_cli terminate &> /dev/null
- if [[ -f /var/run/wpa_supplicant_$1.pid ]]; then
- kill $(cat /var/run/wpa_supplicant_$1.pid) &>/dev/null &
+ wpa_cli -i "$1" terminate &> /dev/null
+ sleep 1 # JP: need this else the file tends to disappear after [[ -f ... ]] but before cat...
+ # see <http://bbs.archlinux.org/viewtopic.php?pid=515667#p515667>
+ if [[ -f "/var/run/wpa_supplicant_$1.pid" ]]; then
+ kill $(cat "/var/run/wpa_supplicant_$1.pid") &>/dev/null &
fi
}
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 86d8b96..0e72ad3 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -24,12 +24,13 @@ ethernet_up() {
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired"
report_debug ethernet_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
- if ! start_wpa $INTERFACE $WPA_CONF $WPA_OPTS; then
+ if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi
if ! wpa_check "$INTERFACE"; then
ifconfig "$INTERFACE" down
+ report_fail "WPA Authentication/Association Failed"
return 1
fi
fi
diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute
index 2f0c485..6264497 100644
--- a/src/connections/ethernet-iproute
+++ b/src/connections/ethernet-iproute
@@ -31,13 +31,15 @@ ethernet_up() {
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired"
- if ! start_wpa $INTERFACE $WPA_CONF $WPA_OPTS; then
+ report_debug ethernet_iproute_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
+ if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi
if ! wpa_check "$INTERFACE"; then
ip link set $INTERFACE down
+ report_fail "WPA Authentication/Association Failed"
return 1
fi
fi
diff --git a/src/connections/wireless b/src/connections/wireless
index 10f751e..98320fa 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -40,7 +40,7 @@ wireless_up() {
# Kill any lingering wpa_supplicants.
report_debug wireless_up stop_wpa "$INTERFACE"
- stop_wpa $INTERFACE
+ 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.
@@ -92,7 +92,6 @@ wireless_up() {
quirk "predown" && ifconfig $INTERFACE up # madwifi FS#10585
report_debug ethernet_up wep_check
-
if ! wep_check $INTERFACE $TIMEOUT; then
report_fail "WEP Association Failed"
return 1
@@ -118,12 +117,14 @@ wireless_up() {
# Connect!
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
- report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF/wpa.conf" "$WPA_OPTS"
- start_wpa $INTERFACE $WPA_CONF $WPA_OPTS || return 1
+ report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
+ if ! start_wpa $INTERFACE $WPA_CONF $WPA_OPTS; then
+ report_fail "wpa_supplicant did not start, possible configuration error"
+ return 1
+ fi
report_debug wireless_up wpa_check
- if ! wpa_check $INTERFACE $TIMEOUT; then
+ if ! wpa_check "$INTERFACE" "$TIMEOUT"; then
report_fail "WPA Authentication/Association Failed"
- stop_wpa $INTERFACE
return 1
fi
;;
@@ -132,14 +133,13 @@ wireless_up() {
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf" # defaults
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwext"
report_debug wireless_up start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"
- if ! start_wpa $INTERFACE $WPA_CONF $WPA_OPTS; then
+ if ! start_wpa "$INTERFACE" "$WPA_CONF" "$WPA_OPTS"; then
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi
report_debug wireless_up wpa_check
- if ! wpa_check $INTERFACE $TIMEOUT; then
+ if ! wpa_check "$INTERFACE" "$TIMEOUT"; then
report_fail "WPA Authentication/Association Failed"
- stop_wpa $INTERFACE
return 1
fi
;;