[bin/qrwifi] Don't search passwords in other networks' sections

This commit is contained in:
Midgard 2023-07-26 17:24:49 +02:00
parent 83c1fd88d8
commit 652d261ee9
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -11,7 +11,7 @@ fi
pw="${2:-}"
if [ -z "$pw" ]; then
pw="$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf | sed -n '/^[\t ]*ssid="'"$ssid"'"$/{:findpsk;N;/\n[\t ]*psk=/!b findpsk;s/^\(\n\|.\)*[\t ]*psk="\(.*\)"$/\2/p; }')"
pw="$(sudo cat /etc/wpa_supplicant/wpa_supplicant.conf | sed -n '/^[\t ]*ssid="'"$ssid"'"$/{:findpsk;N;/}/d;/\n[\t ]*psk=/!b findpsk;s/^\(\n\|.\)*[\t ]*psk="\(.*\)"$/\2/p; }')"
fi
if [ -z "$pw" ]; then
echo "Couldn't find password for network \`$ssid\`"