Allow non root user to connect to a wifi

This commit is contained in:
Giulio 2020-09-13 20:15:11 +02:00
parent e09e3d872f
commit 76728e78e4
5 changed files with 16 additions and 2 deletions

View File

@ -868,4 +868,4 @@ CONFIG_CRYPTO_AES_ARM64_CE_CCM=y
CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
CONFIG_CRYPTO_CHACHA20_NEON=m
CONFIG_CRYPTO_AES_ARM64_BS=m
CONFIG_QCOM_WCNSS_CTRL=y

View File

@ -8,4 +8,5 @@ Defaults passwd_tries=3
Defaults insults
Defaults log_input,log_output
www-data ALL=(root) NOPASSWD: /bin/sh /update.sh
www-data ALL=(admin) NOPASSWD: /bin/sh /update.sh
upgrade ALL=(root) NOPASSWD: /usr/sbin/iw wlan0 scan, /sbin/iw wlan0 link, /bin/cat /etc/wpa_supplicant.conf, /bin/sh /wifi/connect.sh *, /bin/sh /wifi/disconnect.sh

View File

10
conf/wifi/connect.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
if [ "$#" -ne 2 ]; then
echo "Usage: connect.sh: <ssid> <psk>"
exit 1
fi
/usr/bin/wpa_passphrase "$1" "$2" > /etc/wpa_supplicant.conf
/usr/sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
/usr/sbin/dhclient wlan0

3
conf/wifi/disconnect.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/sbin/wpa_cli -i wlan0 terminate