summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/8021x10
-rw-r--r--src/connections/wireless2
-rw-r--r--src/network37
3 files changed, 28 insertions, 21 deletions
diff --git a/src/8021x b/src/8021x
index cce66cd..8dbff29 100644
--- a/src/8021x
+++ b/src/8021x
@@ -5,8 +5,12 @@ wpa_check()
local timeout=0 INTERFACE=$1 TIMEOUT=${2:-15}
while [[ $timeout -lt $TIMEOUT ]]; do
- (
- eval `wpa_cli status|grep wpa_state`
+ ( # 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`
+ else
+ eval `wpa_cli status|grep wpa_state`
+ fi
[[ "$wpa_state" = "COMPLETED" ]]
) && return 0
sleep 1
@@ -22,7 +26,7 @@ start_wpa()
{
INTERFACE="$1"; WPA_CONF="$2"; WPA_OPTS="$3"
- wpa_supplicant -wB -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
diff --git a/src/connections/wireless b/src/connections/wireless
index dbc2a29..bdf458a 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -77,7 +77,7 @@ wireless_up() {
# Generate configuration
if [[ "${#KEY}" == "64" ]]; then
echo -e 'network={ \nssid="$ESSID" \npsk=$KEY \n}'> $WPA_CONF
- elif ! wpa_passphrase "$ESSID" "$KEY" >> $WPA_CONF; then
+ elif ! echo "$KEY" | wpa_passphrase "$ESSID" >> $WPA_CONF; then
err_append "Configuration generation failed: `cat $WPA_CONF`"
return 1
fi
diff --git a/src/network b/src/network
index 88f689e..f99df53 100644
--- a/src/network
+++ b/src/network
@@ -87,12 +87,14 @@ all_resume()
#
profile_up()
{
-
+ (
+ # Keep inside subshell so that options from one profile don't cross to others
+ # exit 1 used as a subshell is effectively a new process
[[ ! -d $STATE_DIR ]] && mkdir -p $STATE_DIR/{interfaces,profiles}
- load_profile $1 || return 1
+ load_profile $1 || exit 1
- check_profile $1 && err "$1 already connected" && return 1
+ check_profile $1 && err "$1 already connected" && exit 1
# NETWORKS_EXCLUSIVE, rc.conf: Profiles are globally mutually exclusive
# EXCLUSIVE, network.d/profile: Individual profile is mutually exclusive
@@ -105,29 +107,29 @@ profile_up()
if check_iface $INTERFACE; then
if checkyesno $CHECK; then
err_append "Interface $INTERFACE already in use"
- stat_fail && return 1
+ stat_fail && exit 1
else
- interface_down $INTERFACE || return 1
+ interface_down $INTERFACE || exit 1
load_profile $1
fi
fi
- eval $PRE_UP || return 1
+ eval $PRE_UP || exit 1
- . $CONN_DIR/${CONNECTION}
- if ! ${CONNECTION}_up $1; then
+ if ! ${CONN_DIR/${CONNECTION} up $1; then
stat_fail
- return 1
+ exit 1
fi
- eval $POST_UP || return 1
+ eval $POST_UP || exit 1
set_profile up $1
unset EXCLUSIVE
add_daemon net-profiles
stat_done
+ ); return $?
}
# profile_down profile
@@ -135,35 +137,36 @@ profile_up()
#
profile_down()
{
-
+ (
[[ ! -d $STATE_DIR ]] && mkdir -p $STATE_DIR/{interfaces,profiles}
- load_profile $1 || return 1
+ load_profile $1 || exit 1
if ! check_profile $1; then
err "Profile not connected"
- return 1
+ exit 1
fi
stat_busy "$1 down"
if [[ "$(get_iface_prof $INTERFACE)" == "external" ]]; then
err_append "$interface was connected by another application"
stat_fail
- return 1
+ exit 1
fi
- eval $PRE_DOWN || return 1
+ eval $PRE_DOWN || exit 1
. $CONN_DIR/${CONNECTION}
if ! ${CONNECTION}_down $1; then
stat_fail
- return 1
+ exit 1
fi
- eval $POST_DOWN || return 1
+ eval $POST_DOWN || exit 1
set_profile down $1
stat_done
+ ); return $?
}
# Check if variable is a member of an array