commit b7db1f8b6c1b107c057936b222310bc5dee68fd8
parent 34d61801db7a3e9e50c2603b9ef86114e9699ca2
Author: Divan Visagie <me@divanv.com>
Date: Sat, 28 Nov 2026 00:39:06 +0100
polkit: let the greeter set the computer's name during the first run (ADR-0019)
What: one more action joins the first-run window: hostnamed's SetStaticHostname
(org.freedesktop.hostname1.set-static-hostname), for the setup's coming "Name this computer" step.
The transient host name (set-hostname) is not included: the static name is the one that persists, and
hostnamed applies it as the running name when no other was set.
Same shape as the clock's rule in the commit before: the greeter user only, and only while no human
account can log in; the shared check is unchanged. The new test cases: the name is allowed on a fresh
machine, refused once an account can log in, and the transient name is refused. (The test that used
to expect the static name to be refused now expects it allowed, since that is the point.)
Diffstat:
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/greeter/tests/first-run-rules.js b/greeter/tests/first-run-rules.js
@@ -29,6 +29,7 @@ const NONE = "root:x:0:0::/root:/bin/bash\ngreetd:x:972:972::/var/lib/greetd:/sb
const ALICE = NONE + "alice:x:1000:1000:Alice:/var/home/alice:/bin/bash\n";
const ADMIN = "org.freedesktop.accounts.user-administration";
const ZONE = "org.freedesktop.timedate1.set-timezone";
+const HOSTNAME = "org.freedesktop.hostname1.set-static-hostname";
const cases = [
["greetd may administer accounts on a fresh machine", { user: "greetd", action: ADMIN, passwd: NONE }, "YES"],
@@ -37,7 +38,9 @@ const cases = [
["still while the only account is locked (no password yet)", { user: "greetd", action: ZONE, passwd: ALICE, locked: { 1000: true } }, "YES"],
["a failing check closes the window", { user: "greetd", action: ZONE, passwd: NONE, spawnFails: true }, undefined],
["nobody else gets it, even on a fresh machine", { user: "divan", action: ZONE, passwd: NONE }, undefined],
- ["greetd gets nothing else (the host name)", { user: "greetd", action: "org.freedesktop.hostname1.set-static-hostname", 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],
+ ["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 (ADR-0019, the setup's clock step).
+// 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).
// 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
@@ -28,7 +28,8 @@ function noHumanCanLogIn() {
var firstRunActions = [
"org.freedesktop.accounts.user-administration",
- "org.freedesktop.timedate1.set-timezone"
+ "org.freedesktop.timedate1.set-timezone",
+ "org.freedesktop.hostname1.set-static-hostname"
];
polkit.addRule(function(action, subject) {