Commit 06f6fab0 authored by Jim Pryor's avatar Jim Pryor Committed by James Rayner
Browse files

revert regexp ESSID patches



Signed-off-by: default avatarJim Pryor <profjim@jimpryor.net>
parent f2da81ef
......@@ -16,7 +16,7 @@ SECURITY (required)
KEY (required for SECURITY of 'wpa' or 'wep' only)
: Wireless encryption key.
ESSID (this or AP is required)
: Name of network to connect to. Note that for "wireless-dbus" profiles this is always a Gnu regexp (as interpreted by "expr").
: Name of network to connect to.
AP (this or ESSID is required)
: AP of the network to connect to.
TIMEOUT
......
......@@ -27,10 +27,9 @@ wifi_auto()
# Loop through all the found essid's, then find a matching profile.
local found_profile found_essid
local found_profile
# JP: add ability to use AP instead of ESSID
# JP: also, make ESSIDs in wireless-dbus CONNECTIONS a regexp instead of a literal
while read ap essid; do
while read network; do
(
......@@ -42,11 +41,7 @@ wifi_auto()
if [[ "$ap" == "$AP" ]]; then
exit 2
elif [[ -z "$found_profile" ]]; then
if [[ "$CONNECTION" == wireless-dbus ]]; then
if expr match "$essid" "^$ESSID\$" 1>/dev/null; then
exit 1
fi
elif [[ "$essid" == "$ESSID" ]]; then
if [[ "$essid" == "$ESSID" ]]; then
exit 1
fi
fi
......@@ -57,11 +52,10 @@ wifi_auto()
)
case $? in
2) found_profile="$network"
found_essid="$essid"
break 2;;
break 2
;;
1) found_profile="$network"
found_essid="$essid"
;;
;;
esac
done < <(list_profiles) # avoid subshell we'd get by piping list_profiles to while read
done < "$networks" # avoid subshell; list_networks returns name of a tmp file
......@@ -69,7 +63,7 @@ wifi_auto()
if [[ -n "$found_profile" ]]; then
report_success
if profile_up "$found_profile" "$found_essid"; then # JP: now we pass literal essid to profile_up as $2
if profile_up "$found_profile"; then
exit 0
else
set_interface forcedown "$interface"
......
......@@ -5,7 +5,6 @@
wireless_up() {
load_profile "$1"
[[ -n "$2" ]] && ESSID="$2" # JP: use the literal ESSID (though currently we only interpret wireless-dbus ESSIDs as regexps)
. "$SUBR_DIR/8021x"
. "$SUBR_DIR/wireless"
......@@ -64,8 +63,7 @@ wireless_up() {
if [[ -n "$AP" ]]; then
ESSID=$(find_ap "$INTERFACE" "$AP")
else
ESSID=$(find_essid "$INTERFACE" "$ESSID" "$CONNECTION") # JP: we could have left $3 null for default of treating ESSID as literal
# but instead we explicitly pass $CONNECTION
ESSID=$(find_essid "$INTERFACE" "$ESSID")
fi
if [[ $? -gt 0 ]]; then
report_fail "Wireless network \"$OLDESSID\" not present."
......
......@@ -94,7 +94,7 @@ all_resume()
done
}
# profile_up profile [literal essid]
# profile_up profile
# put all profiles up
#
profile_up()
......@@ -143,10 +143,10 @@ profile_up()
exit 1
fi
if ! "$CONN_DIR/$CONNECTION" up "$PROFILE" "$2"; then
if ! "$CONN_DIR/$CONNECTION" up "$PROFILE"; then
report_debug profile_up "connect failed"
report_fail
# "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2" # JP: should we do this to make sure?
# "$CONN_DIR/$CONNECTION" down "$PROFILE" # JP: should we do this to make sure?
exit 1
fi
......@@ -154,7 +154,7 @@ profile_up()
report_debug profile_up "POST_UP failed"
report_fail
# failing POST_UP will take interface down
"$CONN_DIR/$CONNECTION" down "$PROFILE" "$2"
"$CONN_DIR/$CONNECTION" down "$PROFILE"
exit 1
fi
......@@ -208,7 +208,7 @@ profile_down()
exit 1
fi
if ! "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2"; then
if ! "$CONN_DIR/$CONNECTION" down "$PROFILE"; then
report_debug profile_up "disconnect failed"
report_fail
exit 1
......
......@@ -14,28 +14,18 @@ wep_check()
}
# Check if a particular network is within range
# find_essid interface essid connection (we treat ESSID as regexp when CONNECTION=wireless-dbus)
# find_essid interface essid connection
find_essid() {
local INTERFACE="$1" ESSID="$2" CONNECTION="$3" RETRIES=10 try=0 res scanned
local INTERFACE="$1" ESSID="$2" RETRIES=10 try=0 res scanned
while [[ "$try" -lt "$RETRIES" ]]; do
sleep 0.5
let try++
if [[ "$CONNECTION" == wireless-dbus ]]; then
# JP: ESSID is a regexp
found=$(
res=$(iwlist "$INTERFACE" scan 2>/dev/null)
[[ -z "$res" ]] && exit 1
# if results were non-null, process them and exit 0
echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | egrep -xm1 "$ESSID"
)
else
found=$(
res=$(iwlist "$INTERFACE" scan 2>/dev/null)
[[ -z "$res" ]] && exit 1
# if results were non-null, process them and exit 0
echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID"
)
fi && {
found=$(
res=$(iwlist "$INTERFACE" scan 2>/dev/null)
[[ -z "$res" ]] && exit 1
# if results were non-null, process them and exit 0
echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID"
) && {
scanned=1
report_debug find_essid "\"$found\""
# we only bother with at most 5 successful scans
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment