From 20603a6e06f16b82267fac9c8cd90d0113b36e92 Mon Sep 17 00:00:00 2001 From: Rémy Oudompheng Date: Sat, 30 Jul 2011 20:25:09 +0200 Subject: 8021x: prepare for configurable WPA_CTRL_PATH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Oudompheng --- src/8021x | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/8021x b/src/8021x index 8cdf0d5..2b897b9 100644 --- a/src/8021x +++ b/src/8021x @@ -1,4 +1,4 @@ -WPA_CLI="wpa_cli -p /run/wpa_supplicant" +WPA_CTRL_PATH=/run/wpa_supplicant # Uses wpa_supplicant to check for association to a network # wpa_check interface [timeout] @@ -10,9 +10,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 -i "$INTERFACE" status 2> /dev/null | fgrep "wpa_state=") + eval $(wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" status 2> /dev/null | fgrep "wpa_state=") else - eval $($WPA_CLI -i "$INTERFACE" status | fgrep "wpa_state=") + eval $(wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" status | fgrep "wpa_state=") fi [[ "$wpa_state" = "$CONDITION" ]] ) && return 0 @@ -42,7 +42,7 @@ start_wpa() stop_wpa() { - $WPA_CLI -i "$1" terminate &> /dev/null + wpa_cli -p "$WPA_CTRL_PATH" -i "$1" terminate &> /dev/null sleep 1 # JP: need this else the file tends to disappear after [[ -f ... ]] but before cat... # see if [[ -f "/run/wpa_supplicant_$1.pid" ]]; then @@ -52,7 +52,7 @@ stop_wpa() wpa_reconfigure() { local INTERFACE=$1 - $WPA_CLI -i "$INTERFACE" reconfigure + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" reconfigure return $? } @@ -60,7 +60,7 @@ wpa_check_current_essid() { # usage: wpa_check_current_essid $interface $essid # check that wpa_supplicant is connected to the right essid local INTERFACE=$1 ESSID=$2 status - status=$($WPA_CLI -i "$INTERFACE" status | grep "^ssid=") + status=$(wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" status | grep "^ssid=") if (( $? == 0 )) && [[ "$status" == "ssid=$ESSID" ]]; then return 0 else @@ -97,11 +97,11 @@ wpa_supplicant_scan_and_find() { # item = string to lookup local INTERFACE="$1" FIELD="$2" ITEM="$3" RETRIES=5 try scan_ok scan_ok=0 - $WPA_CLI -i "$INTERFACE" scan &> /dev/null + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan &> /dev/null for ((try=0; try < $RETRIES; try++)); do local found sleep 2 - found=$($WPA_CLI -i "$INTERFACE" scan_results | tail -n+2 | cut -f ${FIELD} | grep -F -x -m 1 "${ITEM}") + found=$(wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan_results | tail -n+2 | cut -f ${FIELD} | grep -F -x -m 1 "${ITEM}") (( $? == 0 )) && scan_ok=1 # ITEM has been found, echo it @@ -109,7 +109,7 @@ wpa_supplicant_scan_and_find() { echo "$found" return 0 fi - $WPA_CLI -i "$INTERFACE" scan &> /dev/null + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan &> /dev/null done if (( $scan_ok != 1 )); then report_debug wpa_supplicant_scan_and_find "unable to retrieve scan results" @@ -132,9 +132,9 @@ wpa_supplicant_scan_info() { essids=$(mktemp --tmpdir essid.XXXXXXXX) wpa_supplicant -B -i"$INTERFACE" -Dnl80211,wext -C/run/wpa_supplicant -P/run/wpa_supplicant.pid || return 1 - $WPA_CLI -i "$INTERFACE" scan &> /dev/null + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan &> /dev/null sleep 2.5 - $WPA_CLI -i "$INTERFACE" scan_results | + wpa_cli -p "$WPA_CTRL_PATH" -i "$INTERFACE" scan_results | grep -v "^Selected" | grep -v "^bssid" | sort -rn -k3 | -- cgit v1.2.3-24-g4f1b