commit afd6e9da6034530e3a9c66cc97e6f2dd8f02b07b
parent 266a18e09bdcc2e9962561743c09b905898d3b25
Author: Divan Visagie <me@divanv.com>
Date: Sat, 28 Nov 2026 00:41:04 +0100
polkit: let the greeter join a Wi-Fi network during the first run (ADR-0019)
What: three NetworkManager actions join the first-run window, for the setup's coming Wi-Fi step:
wifi.scan (look for networks), network-control (activate a connection) and settings.modify.system
(save the connection for the whole machine). Turning Wi-Fi on or off and the rest of NetworkManager
are not included.
Why settings.modify.system: the connection is saved system-wide on purpose, so the account made a
moment later has the network without joining it again. By default that action needs an
administrator's password, which no one can give at that point; the rule answers it, in the same
window as the account (no human account can log in) and for the greeter user only, as the clock and
name rules do.
Tested with the stand-in for polkit: the three are allowed on a fresh machine, the last is refused
once an account can log in, and a fourth NetworkManager action (enable-disable-wifi) is refused.
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/greeter/tests/first-run-rules.js b/greeter/tests/first-run-rules.js
@@ -40,6 +40,10 @@ const cases = [
["nobody else gets it, even on a fresh machine", { user: "divan", action: ZONE, passwd: NONE }, undefined],
["greetd may set the computer's name on a fresh machine", { user: "greetd", action: HOSTNAME, passwd: NONE }, "YES"],
["not the name once an account can log in", { user: "greetd", action: HOSTNAME, passwd: ALICE, locked: { 1000: false } }, undefined],
+ ...["org.freedesktop.NetworkManager.wifi.scan", "org.freedesktop.NetworkManager.network-control", "org.freedesktop.NetworkManager.settings.modify.system"]
+ .map((a) => [`greetd may use NetworkManager's ${a.split(".").slice(3).join(".")} on a fresh machine`, { user: "greetd", action: a, passwd: NONE }, "YES"]),
+ ["but not once an account can log in", { user: "greetd", action: "org.freedesktop.NetworkManager.settings.modify.system", passwd: ALICE, locked: { 1000: false } }, undefined],
+ ["and nothing else of NetworkManager (turning Wi-Fi off, say)", { user: "greetd", action: "org.freedesktop.NetworkManager.enable-disable-wifi", passwd: NONE }, undefined],
["greetd gets nothing else of hostnamed (the transient name)", { user: "greetd", action: "org.freedesktop.hostname1.set-hostname", passwd: NONE }, undefined],
["nor the clock's NTP setting", { user: "greetd", action: "org.freedesktop.timedate1.set-ntp", passwd: NONE }, undefined],
];
diff --git a/linux/system/usr/share/polkit-1/rules.d/50-patina-first-user.rules b/linux/system/usr/share/polkit-1/rules.d/50-patina-first-user.rules
@@ -1,5 +1,5 @@
// The greeter may change a few things on a machine fresh from the install: administer accounts, which
-// is what makes the first one (ADR-0012), and set the time zone and the computer's name (ADR-0019, the setup's clock and name steps).
+// is what makes the first one (ADR-0012), and set the time zone, the computer's name and join a Wi-Fi network (ADR-0019, the setup's steps).
// Only while no human account can log in: none exists (uid 1000 up, with a shell), or the ones that
// do are all still locked. That is what keeps the window open for the password and for taking the
// account back out if that fails, and closes it the moment a password is set. ADR-0012's alternative
@@ -29,7 +29,12 @@ function noHumanCanLogIn() {
var firstRunActions = [
"org.freedesktop.accounts.user-administration",
"org.freedesktop.timedate1.set-timezone",
- "org.freedesktop.hostname1.set-static-hostname"
+ "org.freedesktop.hostname1.set-static-hostname",
+ // Joining a Wi-Fi network: scan, activate it, and save the connection for every user
+ // (settings.modify.system), which is what lets the account made next have the network too.
+ "org.freedesktop.NetworkManager.wifi.scan",
+ "org.freedesktop.NetworkManager.network-control",
+ "org.freedesktop.NetworkManager.settings.modify.system"
];
polkit.addRule(function(action, subject) {