0012-a-login-manager-of-our-own-greetd-and-a-patina-greeter.md (12641B)
1 # 0012. A login manager of our own: greetd, and a Patina greeter with the setup built in 2 3 Date: 2026-11-20 4 5 ## Status 6 7 Proposed. The user's idea: since there is no user on a fresh machine, the login screen should be 8 where the setup happens, and once the account exists it becomes the ordinary login screen. This 9 answers the question [ADR-0011](0011-the-first-boot-is-the-installer.md) left open, how to run 10 the setup with no user. Nothing here is built beyond the prototype noted at the end; "to verify" 11 marks what has not been looked at. 12 13 ## Context 14 15 [ADR-0011](0011-the-first-boot-is-the-installer.md) wants the first boot to be the installer: with 16 no user, a Patina setup assistant creates the account, and a factory reset returns to it. GDM, the 17 login manager the image has now, has no such mode: with no users it shows a bare "Username" box (seen 18 on 2026-11-20), and it brings GNOME Shell and a GNOME session entry with it, which the image only 19 carries for GDM's sake. Its look is ours only through a patched GNOME Shell theme resource and a 20 dconf setting (ADR-0009, `linux/branding/gdm-theme.py`). 21 22 An experiment on a VM installed from the published image, which has no accounts, showed the 23 account step is plumbing that works. AccountsService's `CreateUser` over D-Bus, as root and without 24 GNOME tools, made an administrator with a home on Btrfs in `/var/home`; `SetPassword` took a hash; 25 and the user template (`Session=patina`) applied to the new account, so a login started the Patina 26 session. What is missing is a place to run the setup before any account exists. 27 28 What is available: 29 - **greetd** 0.10.3, `cage` (a kiosk Wayland compositor) and `gtkgreet` 0.8 are in Fedora 45. 30 `greetd-tuigreet` and `regreet` are not. 31 - **greetd** does the privileged part: PAM, logind sessions, the seat, starting the user's session. 32 A greeter is any program that talks to it over a socket (JSON, a length prefix, the path in 33 `$GREETD_SOCK`), run as an unprivileged user. 34 - **patina-desktop** has the lock screen (`lock/`: a Patina password interface over PAM, whose PAM 35 half a greeter does not need, as greetd authenticates), user pictures (`system/src/avatar.rs`, 36 ADR-0104), `patina-session`, and the login profile (ADR-0083). It has no greeter. 37 38 ## Decision (proposed) 39 40 - **greetd is the login daemon.** We write the greeter, not the privileged code: no PAM or session 41 handling of our own. 42 - **A Patina greeter app** (egui, like Files and Settings) runs as the greeter user inside a kiosk 43 compositor: `cage` to start, the Patina compositor in a kiosk mode later. It has two modes: 44 - **Login:** the users, their pictures, a password, the power menu; an `initial_session` for the 45 live disc's `liveuser`, and for a first login straight after the setup. 46 - **First run**, when there is no human account (uid 1000 or above; to verify how best to tell): 47 the setup of ADR-0011, with the account first. 48 - **The greeter lives in this repository (patina-os), not in patina-desktop:** it is OS code, what 49 logs in, and not part of the desktop session. Where it wants Patina's interface pieces it depends on 50 the Patina libraries or copies what the lock screen does; it does not change patina-desktop. 51 - **The greeter makes the first account itself, through AccountsService, and polkit says when it 52 may.** It calls `CreateUser` and `SetPassword` over D-Bus, as the experiment did, and a polkit rule 53 (`linux/prototype/50-patina-first-user.rules`) lets the greeter user, and only that user, do 54 `org.freedesktop.accounts.user-administration` while **no human account can log in**: none exists 55 (uid 1000 and up, with a shell), or those that do are all still locked. That keeps the window 56 open for the password, and for taking a half-made account back out if the setup fails, and it 57 closes the moment a password is set. If a check in the rule fails, it counts as closed. 58 A helper of our own was built and tried first (below) and dropped: it needs a root service and an 59 SELinux policy of its own, and this does not. 60 - **After the account exists,** the greeter logs it straight into the session through greetd, with 61 the password it was just given, as on a Mac, and from then on shows the login mode. 62 - **GDM goes.** With it, gnome-shell, the GNOME session entry, `linux/branding/gdm-theme.py` and 63 its build stage, and the dconf logo setting. The greeter is Patina's, so the Everforest skin and 64 the logo are native, not patched in. 65 66 ## Known gaps against GDM 67 68 Accessibility (a screen reader, an on-screen keyboard for touch), multi-seat, fast user switching, 69 and fingerprint login: the PAM side works through greetd, but the greeter has to show PAM's 70 prompts ("place your finger") and handle a conversation with more than one step. These are 71 accepted for now. 72 73 ## Open questions 74 75 - Which kiosk compositor, and whether Patina's compositor can run as a greeter session for a 76 user with no account of their own (it uses libseat, so logind should do). 77 - What happens if the setup is interrupted half way: the account is locked, so the window is still 78 open and the setup can run again, but it should say so; and the greeter, not AccountsService, 79 has to check names for the person typing (AccountsService does check them) and hash the password. 80 - HiDPI and several monitors on the greeter, and the cursor. 81 - Joining the tailnet, and the encryption of ADR-0011, as setup steps. 82 - Whether greetd's own PAM service (`greetd`) needs more than Fedora's default for the fingerprint 83 reader and the lock screen's `patina-lock` service to agree. 84 85 ## Order of work 86 87 1. **A prototype on the VM** (done, see above): layer greetd, `gtkgreet` and `cage`, replace GDM, and 88 drive greetd by script as the greeter user: no account, the greeter makes the first through 89 AccountsService, and greetd starts that user's Patina session. 90 2. The greeter app, in login mode. 91 3. The first-run mode, on top of AccountsService and the polkit rule. 92 4. Remove GDM, gnome-shell, the theme stage and the dconf logo setting from the image. 93 5. The gaps above, as they matter. 94 95 ## Prototype (2026-11-20) 96 97 Done on the VM installed from the published image, with greetd, `gtkgreet` and `cage` layered on with 98 `rpm-ostree install` (22 packages with their dependencies; the layering survived the reboot). The 99 code is in `linux/prototype/`. Two ways of making the first account were tried. 100 101 Verified, for both: 102 - **greetd hosts a greeter on this image.** With GDM disabled, greetd runs `cage` and `gtkgreet` as 103 the unprivileged `greetd` user, and its PAM services (`greetd`, `greetd-greeter`) are there. 104 - **The whole flow works.** A scripted greeter speaking greetd's protocol found no human account, 105 had the first one made, logged it in through greetd with the password just given, and greetd 106 started its Patina session on tty1: the compositor, the hud pieces and the rest ran as the new 107 user, and the screen showed the desktop. 108 109 **The chosen route: the greeter asks AccountsService, and a polkit rule decides** (`proto-greeter-direct` 110 and `50-patina-first-user.rules`). It works with SELinux enforcing and no policy of our own: the 111 greeter, in the display-manager domain, can already call AccountsService, and no denial showed. 112 Checked: the greeter made the account and set its password, and greetd started the session; once an 113 account can log in, the greeter is refused `CreateUser`, `SetPassword` and `DeleteUser`; with no 114 accounts it can create one and take it back out while it is locked; and another user (`nobody`) is 115 refused. Found on the way: a first version of the rule, "only while no human account exists", shut 116 the window as soon as the account was made, so the password was refused, and so was the rollback, 117 which left an account nobody could log in to and no way to run the setup again. "No human account 118 that can log in" fixes it. The refusal checks ran through `su`, so they show the rule's logic and 119 not SELinux; the real run through greetd showed SELinux. Not tried: two greeters asking at once (there is 120 one greeter), and the rule failing closed when a check errors. 121 122 **The dropped route: a helper of our own** (`patina-setupd`, a socket-activated root service, in 123 this repository's history at commit 99f1870). It validated its input, took a lock, and rolled 124 back, and passed its checks: bad requests refused, callers outside the greeter's group unable to 125 connect, and one account for two or three simultaneous requests. But with SELinux enforcing the 126 greeter (`xdm_t`) was denied the helper's socket (`var_run_t`) and AccountsService (`accountsd_t`) 127 was denied a look at the caller, so it needed a policy module of its own, and writing one needs 128 `auditd`, which this image lacks. (The kernel rate-limits the audit messages it prints: 158 129 were suppressed in one run. An earlier "no denials" check of mine used `ausearch`, which is not on 130 the image, and meant nothing; the kernel log is where the real denial was.) 131 132 Also found, for either route: 133 - **`/var/lib/greetd` is never created.** greetd's tmpfiles rule is `Z`, which only fixes the 134 ownership of what exists, so the greeter starts with "unable to set working directory". The image 135 needs its own `d` entry. 136 - **uid reuse is racy.** Deleting an account and creating another at once reused uid 1000, and the 137 password could not be set on the AccountsService object that was still going away. It did not 138 recur after a pause. It matters for a factory reset (ADR-0011), where users are removed and made again. 139 - **greetd restarts a greeter that exits with an error**, until it gives up ("start of the service 140 was attempted too often"), so a broken greeter locks the screen: a text console login has to stay 141 available. 142 143 ## In the image (2026-11-20) 144 145 Done: the Containerfile installs `greetd`, `cage` and `accountsservice` (GDM used to bring the last) 146 and enables `greetd.service`; `linux/greeter-build.sh` builds the greeter in the Fedora builder into 147 `build/greeter/`, copied in as `/usr/libexec/patina-greeter`; `/etc/greetd/config.toml`, the polkit 148 rule (`/usr/share/polkit-1/rules.d/`) and the `d /var/lib/greetd` tmpfiles entry are in `linux/system/`. 149 GDM, gnome-shell, the GDM theme stage (`gdm-theme.py`) and the dconf logo setting are gone. 150 Checked on a fresh disk installed from the built image, SELinux enforcing, nothing layered: it 151 boots to the greeter; the test account logs in to the Patina session; with the account deleted the 152 greeter shows the setup, and a new account made there is logged straight in. The only denials in 153 the boot log are `bootupctl`'s, from the base. Not checked: Restart and Shut down, a screen 154 reader, and the text console fallback by hand. 155 156 ## The boot and shutdown splash (2026-11-21) 157 158 No text on the screen while starting or stopping: Plymouth, with a theme of our own (`sectorf`) of an 159 animated flask (the logo's own drawing: the liquid rises and falls, bubbles, the pipe's two circles 160 pulse) in the middle of Everforest's background, and the words Sector F Labs at the bottom. 161 `linux/branding/plymouth-theme.py` draws the frames (a `plymouth-theme` stage of the Containerfile, so 162 Pillow and rsvg-convert stay out of the image); the initramfs is rebuilt with the plymouth dracut 163 module so the splash is up from the start; `kargs.d/20-splash.toml` adds `quiet splash loglevel=3`; 164 greetd's command runs through `systemd-cat`, so cage's output goes to the journal and not to the 165 screen. Plymouth shows only for the graphical boot: a text or rescue boot, or `plymouth.enable=0`, 166 shows the messages as before. 167 168 Seen in the test VM, on boot and on shutdown. Found on the way: the test rig's serial console 169 (`console=ttyS0`) makes Plymouth treat the serial port as a screen and show its plain detail view at 170 once, so the rig keeps `console=tty0` last and the serial console is gone from the VM's arguments 171 (`rpm-ostree kargs --delete=console=ttyS0,115200`; new disks get the order from `vm/disk.sh`). 172 `make log` shows nothing on a machine booted without it. Not checked: real hardware (several 173 GPUs, the encrypted-disk password prompt, which uses Fedora's pictures). 174 175 ## Consequences 176 177 - The login screen and the setup are one thing, in Patina's own look, and a factory reset 178 (ADR-0011) reuses it. 179 - The image gets smaller and simpler without GNOME Shell, and the "a GNOME session shows at the 180 chooser" loose end disappears. 181 - We take on the greeter's quality: it is the first thing a user sees and where a bug locks them out. 182 greetd keeps the security-critical code out of it, but the interface and its first-run logic 183 are ours, as is a recovery path when something is wrong (a text console login stays available).