From 521a0b336c7df8ad79efc7848c95a7b060beea27 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 17 Nov 2019 19:04:38 +0100 Subject: bootrc: for wireless netbooting, set the WPA/WPA2 preshard key with wpapsk=password boot parameter this allows automatic netbooting without password prompt for the wirelss network. --- sys/man/8/plan9.ini | 11 ++++++++--- sys/src/9/boot/net.rc | 19 ++++++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sys/man/8/plan9.ini b/sys/man/8/plan9.ini index a684860c9..296439feb 100644 --- a/sys/man/8/plan9.ini +++ b/sys/man/8/plan9.ini @@ -420,9 +420,6 @@ file and can be read out like: cat /net/ether1/ifstats .EE Ad-hoc mode or WEP encryption is currently not supported. -To enable WPA/WPA2 encryption, see -.IR wpa (8) -for details. .TP .B rt2860 Ralink Technology PCI/PCI-Express wireless adapters require @@ -443,6 +440,14 @@ to be present on attach in or .B /boot. See iwl section above for configuration details. +.SS \fLwpapsk\fI=password\fP +WPA/WPA2 encryption +is detected automatically and a prompt for the +.I password +will appear when using the WIFI interface for netbooting. +To avoid the prompt, the +.I password +can be specified with the boot parameter above. .SS \fLnora6= Disable automatic IPv6 configuration from incoming router advertisements. .SS DISKS, TAPES diff --git a/sys/src/9/boot/net.rc b/sys/src/9/boot/net.rc index 1a194dd84..54d108eed 100755 --- a/sys/src/9/boot/net.rc +++ b/sys/src/9/boot/net.rc @@ -9,10 +9,23 @@ fn confignet{ } # setup wifi encryption if any - if(~ $1 ether && ~ $service terminal && test -x /bin/aux/wpa){ - if(grep -s '^status: need authentication' $2/ifstats >[2]/dev/null){ - aux/wpa -p $2 + if(~ $1 ether && test -x /bin/aux/wpa){ + essid=`{grep '^essid: ' $2/ifstats | sed 's/^essid: //; q'} + if(! ~ $#essid 0){ + if(! ~ $#wpapsk 0 || grep -s '^status: need authentication' $2/ifstats >[2]/dev/null){ + x=(aux/wpa -s $"essid) + if(! ~ $#wpapsk 0){ + echo 'key proto=wpapsk' `{!password=$"wpapsk whatis essid !password} > /mnt/factotum/ctl + wpapsk=() + } + if not { + x=($x -p) + } + $x $2 + } + essid=() } + rm -f /env/^(essid wpapsk) } if(~ $1 ether gbe && ~ $#* 2) @{ -- cgit v1.2.3