setup-interfaces: parsing iwlist is broken
At my place the wifi around looks like this:
$ iwlist wlan0 scanning | grep -e Cell -e key: -e SSID -e Auth
Cell 01 - Address: A0:E4:CB:AF:1C:A5
Encryption key:on
ESSID:"foo5"
Authentication Suites (1) : PSK
Cell 02 - Address: A0:E4:CB:AF:1C:A4
Encryption key:on
ESSID:"foo2"
Authentication Suites (1) : PSK
Cell 03 - Address: FA:8F:CA:6A:2A:20
Encryption key:off
ESSID:""
Cell 04 - Address: 14:9D:09:31:02:81
Encryption key:off
ESSID:"Telekom_FON"
Cell 05 - Address: 14:9D:09:31:02:80
Encryption key:on
ESSID:"WLAN-PXFA7W"
Authentication Suites (1) : PSK
Cell 06 - Address: AE:75:57:D1:C7:D8
Encryption key:off
ESSID:"muenchen.freifunk.net"
Cell 07 - Address: 02:0E:8E:1E:61:17
Encryption key:off
ESSID:"mesh.ffmuc"
Cell 08 - Address: 5C:03:39:5B:12:F8
Encryption key:on
ESSID:"Susi"
Authentication Suites (1) : PSK
Cell 09 - Address: 34:31:C4:CF:AA:66
Encryption key:on
ESSID:"FRITZ!Box 7490"
Authentication Suites (1) : PSK
Cell 10 - Address: B4:A5:EF:0A:33:DC
Encryption key:on
ESSID:"EasyBox-570871"
Authentication Suites (1) : PSK
Authentication Suites (1) : PSK
Cell 11 - Address: 00:21:91:EC:FA:CB
Encryption key:on
ESSID:"Eiselbrecher_net"
Authentication Suites (1) : PSK
Authentication Suites (1) : PSK
This is taken by setup-interfaces and processed by awk to produce this:
"EasyBox-570871" : PSK
"Eiselbrecher_net" : PSK
"foo2" : PSK
"foo5" : PSK
"FRITZ!Box 7490" : PSK
"muenchen.freifunk.net" "mesh.ffmuc" "Susi" : PSK
: PSK
"" "Telekom_FON" "WLAN-PXFA7W" : PSK
Later this is interpreted as “muenchen.freifunk.net is using PSK”, which
is clearly wrong.
Connecting to such a network (using that script) is therefore not
possible.
Not sure about the best way to fix this. Parsing the text output correctly is tricky and using something like iwlib would probably result in an unwanted dependencies.
(from redmine: issue id 8571, created on 2018-02-25)