sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

commit e9ea2e298ff0a84e4f5427934d2e3ec0c17dd1e2
parent 668cb41cc84ced37e0e8ba4ab65b6ab6549edc6c
Author: Divan Visagie <me@divanv.com>
Date:   Sat, 28 Nov 2026 00:50:23 +0100

greeter: a Wi-Fi network counts as joined once its password is accepted, not once it has an address

Found by trying the real thing: in a VM with a virtual Wi-Fi radio and an access point (mac80211_hwsim
and hostapd, WPA2 with a password), the greeter's real backend listed the network correctly, refused a
wrong password cleanly and left nothing saved, but ALSO refused the right password.

Why: wifi_connect waited for NetworkManager's connection to reach "activated", which needs an IP
address, and that test network has no DHCP server, so it never did and the 30 seconds ran out. On a
real network DHCP answers in a second or two and it would have passed, but the step should not hinge
on the network's DHCP at all: a mistyped password fails in seconds (the device goes to
need-auth and the connection is deactivated), while a correct one reaches "configuring an address".

Fix: the loop now also reads the device's state and counts it as joined from IP_CONFIG (70)
onwards (IP_CHECK, SECONDARIES, ACTIVATED too); it still fails when the connection is deactivated, and
still deletes the saved connection then, so a mistyped password is not kept.

Tried again in the same VM with the new build: wrong password: error, 0 connections left saved;
right password: Ok, the connection saved system-wide in
/etc/NetworkManager/system-connections/TestNet.nmconnection with key-mgmt=wpa-psk, the device
"getting IP configuration" (there is no DHCP there).

Also tried as the greetd user, with the real polkit rules, on the same VM: with an account that can
log in, setting the zone, the name and joining the network are all refused and change nothing; with
the only account locked (the first-run window), all three succeed with no password, while an action the
rules do not cover (turning NTP off) is still refused. The action names in the rules all exist in the
image's polkit policy files.

Diffstat:
Mgreeter/src/system.rs | 17+++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/greeter/src/system.rs b/greeter/src/system.rs @@ -406,20 +406,33 @@ impl Backend for System { .call("AddAndActivateConnection", &(settings, &device, &any)) .map_err(|e| format!("could not join {ssid}: {e}"))?; - // Up, or failed: a wrong password ends as deactivated. The state is polled for half a minute. + // Joined, or failed. A wrong password ends with the connection deactivated, quickly. The + // device says how far it got: from "configuring an address" on, the password was accepted + // and the network answered, even if DHCP has not finished, which is the network's own + // time and not a reason to refuse. The state is polled for half a minute. let active = Self::proxy( &bus, NM, active.as_str(), "org.freedesktop.NetworkManager.Connection.Active", )?; + let device_state = || -> u32 { + Self::proxy(&bus, NM, device.as_str(), NM_DEVICE) + .and_then(|d| d.get_property::<u32>("State").map_err(|e| e.to_string())) + .unwrap_or(0) + }; for _ in 0..60 { match active.get_property::<u32>("State") { Ok(2) => return Ok(()), // Deactivating or deactivated: it did not work. Ok(3 | 4) | Err(_) => break, - Ok(_) => std::thread::sleep(std::time::Duration::from_millis(500)), + Ok(_) => {} + } + // NM_DEVICE_STATE_IP_CONFIG, IP_CHECK, SECONDARIES, ACTIVATED. + if matches!(device_state(), 70 | 80 | 90 | 100) { + return Ok(()); } + std::thread::sleep(std::time::Duration::from_millis(500)); } // Do not keep a network that would not join (a mistyped password) on the machine. Self::proxy(