firecat53 / networkmanager-dmenu

Control NetworkManager via dmenu
MIT License
783 stars 74 forks source link

Getting re-prompted for passphrase for existing connections #91

Closed The-Compiler closed 3 years ago

The-Compiler commented 3 years ago

I noticed when I connect to some WiFi networks, I'm always getting prompted for the passphrase despite them being saved connections.

This is due to the connection filtering based on i.get_setting_wireless().get_mac_address() in process_ap.

Looking at the values we have in CONNS, it looks like the MAC address is None for all those:

(Pdb) pp [(c.get_filename(), f'MAC: {c.get_setting_wireless().get_mac_address()}' if c.get_setting_wireless() is not None else 'Not wireless') for c in CONNS]
[('/etc/NetworkManager/system-connections/SBB-FREE.nmconnection',
  'MAC: A8:7E:EA:redacted'),
 ('/etc/NetworkManager/system-connections/eduroam.nmconnection',
  'MAC: None'),
 ('/etc/NetworkManager/system-connections/hexenbesen-UPC.nmconnection',
  'MAC: None'),
 ('/etc/NetworkManager/system-connections/ins.nmconnection',
  'MAC: None'),
 ('/etc/NetworkManager/system-connections/Hosentascheninternet.nmconnection',
  'MAC: A8:7E:EA:redacted'),
 ('/etc/NetworkManager/system-connections/Taohuayuan-5.nmconnection',
  'MAC: A8:7E:EA:redacted'),
 ('/etc/NetworkManager/system-connections/OST-VPN.nmconnection',
  'Not wireless'),
 ('/etc/NetworkManager/system-connections/Nokia 8 Network.nmconnection',
  'Not wireless'),
 ('/var/run/NetworkManager/system-connections/Wired connection 1.nmconnection',
  'Not wireless'),
 ('/var/run/NetworkManager/system-connections/Wired connection 2.nmconnection',
  'Not wireless')]

"eduroam", "hexenbesen-UPC" and "ins" are all normal WiFi connections to which NetworkManager happily connects without re-asking for a password.

Looking at the .nmconnection files, they are missing the mac-address=A8:7E:EA:redacted key under [wifi]. No idea why. Maybe I added some via keepmenu and some via NetworkManager directly?

It looks like the filtering was added in d343d211d7ee5bbdf26c713b4baaae35648b3210 for #31 - maybe there should be a or i.get_setting_wireless().get_mac_address() is None there as well?

firecat53 commented 3 years ago

Hmm. It looks like adding a connection via nm-connection-editor for some reason doesn't add the mac-address= line. I'll have to look at this more later. You're probably right that this and #92 are related. It looks like MAC filtering was added in #59 and discussed in #58.

The-Compiler commented 3 years ago

Looks like in eduroam.nmconnection and hexenbesen-UPC.nmconnection I have interface-name=wlan set (I have a /etc/udev/rules.d/10-network.rules which names my interface wlan instead of the autogenerated name).

This seems to serve the same purpose, so perhaps the filtering should take that into account as well?

In ins.nmconnection, neither of those two are set... No idea why, and I don't remember how I added those profiles unfortunately... I might have added ins via nmtui or nmcli, I think it was the first connection I set up on this laptop, perhaps before I had a GUI.

I think the filtering logic should:

Does that sound good? Should I (try to) open a PR with that change?

edit: There's a bit of context here: https://bugzilla.redhat.com/show_bug.cgi?id=1139536

firecat53 commented 3 years ago

Certainly open to PRs! I'm working tomorrow so it might be a couple days at least before I can get back to this. I appreciate your recent inputs!!

The-Compiler commented 3 years ago

I have a patch ready for this - will submit a PR once I get a chance to actually test it with the same WiFi networks, probably next week.