View Issue Details

IDProjectCategoryView StatusLast Update
0009300Kali LinuxKali Package Improvementpublic2025-09-15 18:08
Reporterllamagobeepboop Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary0009300: Incorrect parsing of wpa_supplicant.conf for nmcli
Description

I found this out the hard way when I attempted to use a wpa_supplicant.conf generated by the Raspberry Pi Imager tool to pre-configure wireless settings on a Raspberry Pi Zero 2 W.

copy-user-wpasupplicant.sh doesn't correctly parse wpa_supplicant.conf to extract the SSID and PSK for nmcli.
In my particular situation, the wpa_supplicant.conf I was using included a scan_ssid=1 line. This caused the awk expression to match and print multiple lines of text which resulted in the SSID containing a newline character. Similar issues can occur for the PSK if any other lines contain the text "psk". Likewise, a valid wpa_supplicant.conf containing multiple network entries will cause problems.

As a workaround, I would suggest leveraging the fact that certain fields must be quoted (SSID, ASCII PSK) or unquoted (hex PSK) and limiting it to a single match:

SSID values must be quoted

ssid=$(grep -m 1 'ssid="' /boot/firmware/wpa_supplicant.conf | cut -d '=' -f2- | tr -d '"')

ASCII PSK must be quoted, length 8 to 63

psk=$(grep -m 1 'psk="' /boot/firmware/wpa_supplicant.conf | cut -d '=' -f2- | tr -d '"')

or

psk=$(grep -m 1 -E 'psk="[^"]{8,63}"' /boot/firmware/wpa_supplicant.conf | cut -d '=' -f2- | tr -d '"')

Hex PSK must be unquoted, length 64

psk=$(grep -m 1 'psk=[^"]' /boot/firmware/wpa_supplicant.conf | cut -d '=' -f2- | tr -d '"')

or

psk=$(grep -m 1 -E 'psk=[A-Fa-f0-9]{64}' /boot/firmware/wpa_supplicant.conf | cut -d '=' -f2- | tr -d '"')

Activities

llamagobeepboop

llamagobeepboop

2025-09-15 18:08

reporter   ~0020821

Apologies for the janky description formatting! I didn't realize the bug tracker supported markdown and it doesn't look like I can edit the description. :(

Issue History

Date Modified Username Field Change
2025-09-15 18:06 llamagobeepboop New Issue
2025-09-15 18:08 llamagobeepboop Note Added: 0020821