rockymeza/wifi

Networking breaks after attempting to connect to an AP with spaces in its name

drmn4ea opened this issue · 1 comments

Hi,
I encountered what looks to be a bug in Wifi 0.3.8. I'm currently using it for a project (https://github.com/drmn4ea/WiSneak) that needs to connect and disconnect to large numbers of public WiFi hotspots, over which the user has no control over the access point name. If a connection attempt is made to an access point with spaces in its name, an invalid /etc/network/interfaces file is generated and no further network management operations will work. For example, the generated interfaces file entry:

iface wlan0-HP-Print-56-ENVY 4500 series inet dhcp
wireless-channel auto
wireless-essid HP-Print-56-ENVY 4500 series

Result when performing subsequent network operations:

$ ifdown -v wlan0
Reading directory /etc/network/interfaces.d
/etc/network/interfaces:28: too many parameters for iface line
ifdown: couldn't read interfaces file "/etc/network/interfaces"

The space in the 'wireless-essid' line may or may not also be a problem, but APs with a blank network name (e.g. '' or only spaces) will also fail.

It looks like it is legal to solve these by putting quotes around the generated interface name (http://askubuntu.com/questions/50876/how-to-connect-to-a-wireless-network-that-has-a-two-word-name-with-a-space). This may run down a rabbit hole (now, what if the interface name contains quotes?). Since the interface file entries are generated by Wifi and not a human, it might make sense to eliminate the 'wireless-essid My AP Name' line entirely and replace it with 'wireless-ap C0:FF:EE:C0:FF:EE' instead. This avoids any issues with cute ESSIDs, and avoids ambiguity when multiple APs with the same name are in range (I can count at least 6 'xfinitywifi' APs from my living room).

Tl;DR:

  • Suggest mangling/encoding the generated 'iface' name to avoid spaces
  • Suggest using BSSID ('ap') rather than ESSID to avoid issues with blank/unusual AP names and ambiguity over which one is being connected to (the ESSID could be retained on this line as a comment)

Thanks!

EDIT: Several Internet references suggest using a line with the format 'wireless-bssid C0FFEEC0FFEE' to specify BSSID. This did not work for me. According to the documentation for 'iwlist' etc., the option name should be 'ap' and not 'bssid'. Using 'wireless-ap C0:FF:EE:C0:FF:EE' (with colons; I haven't tried it without) worked for me.

hmm. To be honest, I'm not sure how long we can go on storing stuff in the network interfaces file. It seems that other distributions use the file differently and sometimes don't even have one.

You don't have to use the SSID as the scheme name if you want to avoid spaces. You can specify a name yourself. Here's an example using the command line interface:

#  wifi -i wlan0 config zza blahblah
passkey> s3cret
iface wlp3s0-zza inet dhcp
    wpa-psk XXXXXXXXXXXXXXXXXXXXXXXXXX
    wpa-ssid Blah Blah Net
    wireless-channel auto