On Tue, Nov 02, 2021 at 05:26:17PM +0000, Klemens Nanni wrote:
> At least bwfm(4) does not support WEP:
>
> # ifconfig bwfm0 nwkey 12345
> ifconfig: SIOCS80211NWKEY: Operation not supported by device
> # echo $?
> 0
>
> ifconfig(8) must return non-zero in this case.
>
> This is relevant for an upcoming installer fix, but also worth itself.
>
> OK?
>
> Index: ifconfig.c
> ===================================================================
> RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
> retrieving revision 1.445
> diff -u -p -r1.445 ifconfig.c
> --- ifconfig.c 6 Oct 2021 06:14:08 -0000 1.445
> +++ ifconfig.c 2 Nov 2021 17:20:01 -0000
> @@ -2033,7 +2033,7 @@ setifnwkey(const char *val, int d)
> }
>
> if (ioctl(sock, SIOCS80211NWKEY, (caddr_t)&nwkey) == -1)
> - warn("SIOCS80211NWKEY");
> + err("SIOCS80211NWKEY");
> }
>
> /* ARGSUSED */
>
I noticed the above mentioned error^Wwarning in the installer:
Which network interface do you wish to configure? (or 'done') [bse0]
bwfm0
ifconfig: SIOCS80211NWKEY: Operation not supported by device
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, (W)EP, WPA-(P)SK [O]
This comes from ieee80211_scan():
Reset 802.11 settings and determine WPA capability.
ifconfig $_if -nwid -nwkey
ifconfig $_if -wpa 2>/dev/null && _has_wpa=1
With ifconfig and installer fixed, we can properly detect and skip WEP:
Which network interface do you wish to configure? (or 'done') [bse0]
bwfm0
Access point? (ESSID, 'any', list# or '?') [any] 2
Security protocol? (O)pen, WPA-(P)SK [O] w
'w' is not a valid choice.
Security protocol? (O)pen, WPA-(P)SK [O] p
WPA passphrase? (will echo)
OK?
Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1184
diff -u -p -r1.1184 install.sub
--- install.sub 2 Nov 2021 16:54:01 -0000 1.1184
+++ install.sub 2 Nov 2021 17:26:40 -0000
@@ -1228,11 +1228,12 @@ ieee80211_scan() {
# Configure 802.11 interface $1 and append ifconfig options to hostname.if $2.
# Ask the user for the access point ESSID, the security protocol and a secret.
ieee80211_config() {
- local _if=$1 _hn=$2 _prompt _nwid _haswpa=0 _err
+ local _if=$1 _hn=$2 _prompt _nwid _has_wep=0 _has_wpa=0 _err
- # Reset 802.11 settings and determine wpa capability.
- ifconfig $_if -nwid -nwkey
- ifconfig $_if -wpa 2>/dev/null && _haswpa=1
+ # Reset 802.11 settings and determine WEP and WPA capabilities.
+ ifconfig $_if -nwid
+ ifconfig $_if -nwkey 2>/dev/null && _has_wep=1
+ ifconfig $_if -wpa 2>/dev/null && _has_wpa=1
# Empty scan cache.
rm -f $WLANLIST
@@ -1256,17 +1257,19 @@ ieee80211_config() {
# 'any' implies that only open access points are considered.
if [[ $_nwid != any ]]; then
- _prompt="Security protocol? (O)pen, (W)EP"
- ((_haswpa == 1)) && _prompt="$_prompt, WPA-(P)SK"
+ _prompt="Security protocol? (O)pen"
+ ((_has_wep == 1)) && _prompt="$_prompt, (W)EP"
+ ((_has_wpa == 1)) && _prompt="$_prompt, WPA-(P)SK"
while :; do
ask_until "$_prompt" "O"
- case "$_haswpa-$resp" in
- ?-[Oo]) # No further questions
+ case "${_has_wep}${_has_wpa}-${resp}" in
+ ??-[Oo]) # No further questions
ifconfig $_if join "$_nwid"
quote join "$_nwid" >>$_hn
break
;;
- ?-[Ww]) ask_passphrase "WEP key?"
+ 1?-[Ww])
+ ask_passphrase "WEP key?"
# Make sure ifconfig accepts the key.
if _err=$(ifconfig $_if join "$_nwid" nwkey
"$_passphrase" 2>&1) &&
[[ -z $_err ]]; then
@@ -1275,7 +1278,8 @@ ieee80211_config() {
fi
echo "$_err"
;;
- 1-[Pp]) ask_passphrase "WPA passphrase?"
+ ?1-[Pp])
+ ask_passphrase "WPA passphrase?"
# Make sure ifconfig accepts the key.
if ifconfig $_if join "$_nwid" wpakey
"$_passphrase"; then
quote join "$_nwid" wpakey
"$_passphrase" >>$_hn