summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Daudt <kdaudt@alpinelinux.org>2023-01-28 19:25:41 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2023-01-30 19:23:16 +0000
commit6c9955efa34ebd415d7a490c893264427b249757 (patch)
treeb335afd0836afe3639dda510af0d0fd64e1e116d
parentb527b1b2eea9a9ed11a11dcb8c50fb0a28d36120 (diff)
downloadalpine-conf-6c9955efa34ebd415d7a490c893264427b249757.zip
setup-interfaces: find essids when SSID List capability present
When a essid has the 'SSID List' extended capibility, the `find_essids` function will not return that ssid. That's because the `$1 ~ /SSID/` awk pattern will match that line. The ssid variable then is set to an empty value because there is no `:` (field separate) in that line, so `$2` is empty. The terminator of the statemachine then skips this essid, because it checks if the `ssid` variable is not empty. We can fix this by making sure the field ends with `SSID`, which is not the case with the `SSID List` line. Partial output of `iw dev wlan0 scan`: ``` Extended capabilities: * Extended Channel Switching * TFS * WNM-Sleep Mode * TIM Broadcast * BSS Transition * SSID List * Operating Mode Notification * 6 * Max Number Of MSDUs In A-MSDU is unlimited ``` Reported-by: invoked Fixes: #10546
-rw-r--r--setup-interfaces.in2
-rwxr-xr-xtests/setup_interfaces_test24
2 files changed, 25 insertions, 1 deletions
diff --git a/setup-interfaces.in b/setup-interfaces.in
index a5cc9ed..6ffcdd5 100644
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -124,7 +124,7 @@ find_essids() {
$MOCK ip link set dev "$iface" up
(iw dev wlan0 scan; echo BSS) | awk -F": " '
/^BSS/ { if (ssid) { print ssid "/" auth }; ssid=""; auth="" }
- $1 ~ /SSID/ { ssid=$2 }
+ $1 ~ /SSID$/ { ssid=$2 }
$1 ~ /Authentication suites/ { auth=$2 }' \
| grep -E -v '(802.1x|\\x00)' | sort -u >"$essids_list"
if [ -s "$essids_list" ]; then
diff --git a/tests/setup_interfaces_test b/tests/setup_interfaces_test
index 4a611ab..3bd5c61 100755
--- a/tests/setup_interfaces_test
+++ b/tests/setup_interfaces_test
@@ -13,6 +13,7 @@ init_tests \
setup_interfaces_interactive_bond0 \
setup_interfaces_interactive_wlan0_psk \
setup_interfaces_interactive_wlan0_open \
+ setup_interfaces_interactive_ssid_list \
setup_interfaces_auto \
setup_interfaces_auto_none \
setup_interfaces_auto_restart
@@ -237,6 +238,29 @@ setup_interfaces_interactive_wlan0_open_body() {
setup-interfaces <answers
}
+setup_interfaces_interactive_ssid_list_body() {
+ init_env
+ create_fake_ifaces lo eth0 wlan0
+ mkdir -p sys/class/net/wlan0/phy80211
+
+ (
+ # Which one do you want to initialize? (or '?' or 'done') [eth0]
+ echo wlan0
+ # Type the wireless network name to connect to:
+ echo kano1
+ # Ip address for wlan0? (or 'dhcp', 'none', '?') [dhcp]
+ echo dhcp
+ # Do you want to do any manual network configuration? (y/n) [n]
+ echo n
+ )>answers
+
+ atf_check -s exit:0 \
+ -o match:"Available interfaces are: eth0 wlan0" \
+ -o match:"kano1" \
+ -o match:"Type the \"kano1\" network Pre-Shared Key" \
+ setup-interfaces <answers
+}
+
setup_interfaces_auto_body() {
init_env
create_fake_ifaces lo eth0