sector-f-linux

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

commit 7dc2e1401b0e6f7288e742d73316bbe1183b4e46
parent 52e03c471631c9e1e2dac490c0a886409ca8dc2a
Author: Divan Visagie <me@divanv.com>
Date:   Sat, 21 Nov 2026 00:37:08 +0100

image: greetd and the Patina greeter in place of GDM

The Containerfile installs greetd, cage and accountsservice (GDM used to bring it), builds the greeter in the Fedora builder (linux/greeter-build.sh, into build/greeter/) and enables greetd. greetd's config, the polkit rule for the first account and the /var/lib/greetd tmpfiles entry are in linux/system/. GDM, gnome-shell, the GDM theme stage and its dconf logo setting are removed (ADR-0012).

Checked on a fresh disk installed from the built image, SELinux enforcing, nothing layered: it boots to the greeter, the test account logs in to the Patina session, and with that account deleted the greeter shows the setup and a new account made there is logged straight in. Not checked: Restart and Shut down, the text console fallback by hand.

Diffstat:
MMakefile | 2+-
Mdocs/adr/0012-a-login-manager-of-our-own-greetd-and-a-patina-greeter.md | 13+++++++++++++
Mlinux/.dockerignore | 2+-
Mlinux/Containerfile | 45+++++++++++----------------------------------
Dlinux/branding/gdm-theme.py | 107-------------------------------------------------------------------------------
Alinux/greeter-build.sh | 20++++++++++++++++++++
Mlinux/publish.sh | 1+
Dlinux/system/etc/dconf/db/gdm.d/10-seflos-logo | 5-----
Alinux/system/etc/greetd/config.toml | 12++++++++++++
Alinux/system/usr/lib/tmpfiles.d/patina-greeter.conf | 3+++
Alinux/system/usr/share/polkit-1/rules.d/50-patina-first-user.rules | 27+++++++++++++++++++++++++++
Mlinux/vm/README.md | 6++----
Mlinux/vm/build.sh | 1+
13 files changed, 92 insertions(+), 152 deletions(-)

diff --git a/Makefile b/Makefile @@ -26,7 +26,7 @@ $(DISK): run: $(DISK) ## Boot the built image in a VM (installs it first if there is no disk) $(VM) start $(VM) wait - @echo "Up. GDM shows on 'make view' (VNC localhost:5901); log in as patina / patina." + @echo "Up. The greeter shows on 'make view' (VNC localhost:5901); log in as patina / patina." @echo "make ssh for a root shell, make stop to power off." console: $(DISK) ## Boot the image on this terminal instead (Ctrl-a x quits) diff --git a/docs/adr/0012-a-login-manager-of-our-own-greetd-and-a-patina-greeter.md b/docs/adr/0012-a-login-manager-of-our-own-greetd-and-a-patina-greeter.md @@ -140,6 +140,19 @@ Also found, for either route: was attempted too often"), so a broken greeter locks the screen: a text console login has to stay available. +## In the image (2026-11-20) + +Done: the Containerfile installs `greetd`, `cage` and `accountsservice` (GDM used to bring the last) +and enables `greetd.service`; `linux/greeter-build.sh` builds the greeter in the Fedora builder into +`build/greeter/`, copied in as `/usr/libexec/patina-greeter`; `/etc/greetd/config.toml`, the polkit +rule (`/usr/share/polkit-1/rules.d/`) and the `d /var/lib/greetd` tmpfiles entry are in `linux/system/`. +GDM, gnome-shell, the GDM theme stage (`gdm-theme.py`) and the dconf logo setting are gone. +Checked on a fresh disk installed from the built image, SELinux enforcing, nothing layered: it +boots to the greeter; the test account logs in to the Patina session; with the account deleted the +greeter shows the setup, and a new account made there is logged straight in. The only denials in +the boot log are `bootupctl`'s, from the base. Not checked: Restart and Shut down, a screen +reader, and the text console fallback by hand. + ## Consequences - The login screen and the setup are one thing, in Patina's own look, and a factory reset diff --git a/linux/.dockerignore b/linux/.dockerignore @@ -4,4 +4,4 @@ * !system/ !build/desktop/ -!branding/gdm-theme.py +!build/greeter/ diff --git a/linux/Containerfile b/linux/Containerfile @@ -1,11 +1,12 @@ # Patina OS: Fedora 45's bootc image with the Patina desktop and what it needs, -# logged into from GDM, on Btrfs (ADR-0009). Two images come out of it: +# logged into through greetd and a Patina greeter, on Btrfs (ADR-0009). Two images come out of it: # # system the real one # dev the system plus what the test VM needs: a user to log in as, and # trust in the development registry (vm/README.md) # -# The desktop is built first by desktop/build.sh, into build/desktop/. +# The desktop is built first by desktop/build.sh, into build/desktop/, and the greeter by +# greeter-build.sh, into build/greeter/. # Fedora's own bootc image, pinned by digest: the best-tested base bootc has, # with its own kernel, so none of the workarounds the Ubuntu base needed (a @@ -13,21 +14,10 @@ # 2026-11-20; update it to take a new base. FROM quay.io/fedora/fedora-bootc@sha256:813fd13fb01363e76310c5e764ddcba8e275a0259255f49b5717a9925e74b177 AS base -# GDM's login screen in Everforest Dark, the Patina desktop's default skin: -# GNOME Shell's theme resource with its greys and its accent rewritten by -# branding/gdm-theme.py. Built here, from the same base, so glib2-devel (which -# compiles resources) stays out of the image; the system stage checks that its -# gnome-shell is the version this was made from. -FROM base AS gdm-theme -RUN dnf -y --setopt=install_weak_deps=False install gnome-shell glib2-devel python3 && \ - dnf clean all -COPY branding/gdm-theme.py /gdm-theme.py -RUN python3 /gdm-theme.py /gnome-shell-theme.gresource && \ - rpm -q gnome-shell > /gnome-shell.version - FROM base AS system -# What the desktop needs: GDM to log in, NetworkManager (patina-wifi), PipeWire +# What the desktop needs: greetd and cage to log in (the greeter itself is ours, below), +# AccountsService for the accounts, NetworkManager (patina-wifi), PipeWire # and WirePlumber (wpctl, for the volume keys), Mesa (EGL, GBM, Vulkan), # libinput, libseat, xkb's layouts, fonts and the icon themes, and foot as a # terminal. The libraries are what the binaries link or load: GTK4 and WebKitGTK @@ -48,7 +38,7 @@ FROM base AS system # Not here yet: the NVIDIA driver, which comes from RPM Fusion or NVIDIA's own # repository and is built against the image's kernel at build time. RUN dnf -y --setopt=install_weak_deps=False install \ - gdm dconf polkit NetworkManager \ + greetd cage accountsservice dconf polkit NetworkManager \ pipewire pipewire-pulseaudio wireplumber \ mesa-dri-drivers mesa-vulkan-drivers mesa-libEGL mesa-libgbm vulkan-loader \ libinput libseat libxkbcommon xkeyboard-config pixman libdrm \ @@ -65,9 +55,10 @@ RUN dnf -y --setopt=install_weak_deps=False install \ qemu-kvm fastfetch htop microcode_ctl linux-firmware btrfs-progs && \ dnf clean all -# The Patina desktop and Files, and "Patina" as GDM's session: laid out under / -# by desktop/build.sh. +# The Patina desktop and Files, and its session: laid out under / by desktop/build.sh. And the +# greeter, laid out by greeter-build.sh. COPY build/desktop/ / +COPY build/greeter/ / # Files the system adds to the base, as laid out under system/. Among them, # boot.automount is masked (a symlink to /dev/null in /etc/systemd/system): @@ -85,21 +76,7 @@ COPY build/desktop/ / # carries Fedora's os-release, whose DEFAULT_HOSTNAME ("fedora") wins otherwise. COPY system/ / -# The login screen's logo (system/etc/dconf/db/gdm.d/) is compiled into dconf's -# database here, since it is read from the compiled file. -RUN dconf update - -# And the rest of the login screen: the Everforest Dark theme resource made in -# the gdm-theme stage, in place of GNOME Shell's own. It was made from one -# version of gnome-shell, so this stops the build if the system stage got a -# different one: a newer stylesheet needs its colours looked at again. -COPY --from=gdm-theme /gnome-shell-theme.gresource /gnome-shell.version /tmp/ -RUN test "$(rpm -q gnome-shell)" = "$(cat /tmp/gnome-shell.version)" || \ - { echo "error: gnome-shell is $(rpm -q gnome-shell), the GDM theme was made from $(cat /tmp/gnome-shell.version): rebuild without the cache" >&2; exit 1; } && \ - install -m 644 /tmp/gnome-shell-theme.gresource /usr/share/gnome-shell/gnome-shell-theme.gresource && \ - rm /tmp/gnome-shell-theme.gresource /tmp/gnome-shell.version - -RUN systemctl enable gdm.service NetworkManager.service \ +RUN systemctl enable greetd.service NetworkManager.service \ bluetooth.service power-profiles-daemon.service thermald.service \ cups.socket cups.service cups-browsed.service avahi-daemon.service \ ModemManager.service tailscaled.service fwupd-refresh.timer && \ @@ -111,7 +88,7 @@ RUN bootc container lint FROM system AS dev -# A user to log in as at GDM: patina, password patina, allowed sudo (wheel). +# A user to log in as at the greeter: patina, password patina, allowed sudo (wheel). # Its home is made at boot, since /var starts empty. RUN useradd -M -d /var/home/patina -s /bin/bash -G wheel patina && \ echo patina:patina | chpasswd && \ diff --git a/linux/branding/gdm-theme.py b/linux/branding/gdm-theme.py @@ -1,107 +0,0 @@ -#!/usr/bin/env python3 -"""Makes GDM's login screen Everforest Dark, the Patina desktop's default skin. - -GDM's login screen is drawn by GNOME Shell, and its look is the dark stylesheet inside -/usr/share/gnome-shell/gnome-shell-theme.gresource: a dozen hard-coded greys (the background is -#222226) and an accent that is the variable -st-accent-color, which the shell sets itself from the -accent-colour setting, so it can only be one of GNOME's named colours. This takes the stock -resource, rewrites those colours in gnome-shell-dark.css to Everforest's, and compiles the result -into a resource to put in its place. Only the dark stylesheet changes: nothing here runs the -GNOME session, so only the login screen sees it. - - gdm-theme.py [OUT] OUT defaults to ./gnome-shell-theme.gresource - -Needs gresource and glib-compile-resources (Fedora's glib2-devel). It stops with an error, and -writes nothing, if the stylesheet no longer has what it expects, which is how a newer GNOME Shell -that changed its colours shows up at build time instead of as a login screen that looks wrong. -The colours are the ones in patina's skins/everforest-dark.toml. -""" - -import re -import subprocess -import sys -import tempfile -from pathlib import Path - -SOURCE = "/usr/share/gnome-shell/gnome-shell-theme.gresource" -PREFIX = "/org/gnome/shell/theme" -CSS = "gnome-shell-dark.css" - -# Everforest Dark (patina's skins/everforest-dark.toml): bg0 #2d353b, bg_dim #272e33, bg1 #343f44, -# bg2 #3d484d, bg3 #475258, bg4 #4f5b5e, fg #d3c6aa, fg_dim #e6e2dc, accent (green) #a7c080. -GREYS = { - "#222226": "#2d353b", # the login screen's background, and the dialogs' (51 uses) - "#2e2e33": "#343f44", # the next layer up - "#36363a": "#3d484d", - "#38383b": "#3d484d", - "#333333": "#343f44", - "#424247": "#475258", - "#47474c": "#475258", - "#4a4a4f": "#475258", - "#4d4d4d": "#4f5b5e", - "#56565c": "#4f5b5e", - "#fafafb": "#d3c6aa", # text -} -ACCENT = "#a7c080" -ACCENT_TEXT = "#2d353b" # dark text on the green -STRONG_TEXT = "#e6e2dc" # text that is pure white now - -# What must be there for the change to make sense; fewer than this and the stylesheet has moved. -MUST = {"#222226": 10, "#fafafb": 10, "-st-accent-color": 50} - - -def run(*cmd, **kw): - return subprocess.run(cmd, check=True, text=True, **kw) - - -def main(): - out = Path(sys.argv[1] if len(sys.argv) > 1 else "gnome-shell-theme.gresource").resolve() - with tempfile.TemporaryDirectory() as tmp: - root = Path(tmp) - names = run("gresource", "list", SOURCE, capture_output=True).stdout.split() - files = [] - for resource in names: - assert resource.startswith(PREFIX + "/"), resource - name = resource[len(PREFIX) + 1 :] - data = run("gresource", "extract", SOURCE, resource, capture_output=True).stdout - (root / name).write_text(data) if name.endswith(".css") else (root / name).write_bytes( - subprocess.run(["gresource", "extract", SOURCE, resource], check=True, capture_output=True).stdout - ) - files.append(name) - if CSS not in files: - sys.exit(f"error: {CSS} is not in {SOURCE}") - - css = (root / CSS).read_text() - low = css.lower() - for needle, least in MUST.items(): - found = low.count(needle) - if found < least: - sys.exit(f"error: {CSS} has {found} of {needle}, expected at least {least}: " - "GNOME Shell's stylesheet has changed; look at it before shipping this") - - counts = {} - for old, new in GREYS.items(): - css, counts[old] = re.subn(re.escape(old), new, css, flags=re.I) - # The accent: its text colour first, as -st-accent-color is not in -st-accent-fg-color. - css, fg = re.subn(r"-st-accent-fg-color", ACCENT_TEXT, css) - css, accent = re.subn(r"-st-accent-color", ACCENT, css) - # Text drawn in pure white; the white inside translucent overlays and accent mixes stays. - css, white = re.subn(r"(?<![\w-])color: #ffffff", f"color: {STRONG_TEXT}", css, flags=re.I) - (root / CSS).write_text(css) - - manifest = ( - '<?xml version="1.0" encoding="UTF-8"?>\n<gresources>\n' - f' <gresource prefix="{PREFIX}">\n' - + "".join(f" <file>{n}</file>\n" for n in sorted(files)) - + " </gresource>\n</gresources>\n" - ) - (root / "theme.gresource.xml").write_text(manifest) - run("glib-compile-resources", f"--sourcedir={root}", f"--target={out}", str(root / "theme.gresource.xml")) - - print(f"wrote {out} ({out.stat().st_size} bytes)") - print(f" greys replaced: {sum(counts.values())} ({', '.join(f'{k}x{v}' for k, v in counts.items() if v)})") - print(f" accent colour: {accent} uses; accent text: {fg}; white text: {white}") - - -if __name__ == "__main__": - main() diff --git a/linux/greeter-build.sh b/linux/greeter-build.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Builds the Patina greeter (../greeter) for the image, in the same Fedora 45 builder as the +# desktop (desktop/build.sh), so it links the libraries the image has. It lands in +# build/greeter/ as it goes under /, and the Containerfile copies it in. The whole repository is +# mounted because the greeter embeds the logo from linux/system/. +set -euo pipefail + +ROOT=$(cd "$(dirname "$0")/.." && pwd) # the repository +BUILDER=patina-os-desktop-builder +STAGE="$ROOT/linux/build/greeter" + +docker build -q -f "$ROOT/linux/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/linux/desktop" >/dev/null +printf '==> building patina-greeter\n' +docker run --rm --user "$(id -u):$(id -g)" -e CARGO_HOME=/cargo -e HOME=/tmp \ + -v patina-os-cargo:/cargo -v "$ROOT:/repo" -w /repo/greeter "$BUILDER" \ + cargo build --release --locked --target-dir /repo/greeter/target-fedora + +rm -rf "$STAGE" && mkdir -p "$STAGE/usr/libexec" +install -m 755 "$ROOT/greeter/target-fedora/release/patina-greeter" "$STAGE/usr/libexec/patina-greeter" +printf '==> build/greeter/ (%s)\n' "$(git -C "$ROOT" rev-parse --short HEAD)" diff --git a/linux/publish.sh b/linux/publish.sh @@ -21,6 +21,7 @@ LOCAL="$REPO:build" say() { printf '==> %s\n' "$*"; } "$ROOT/desktop/build.sh" +"$ROOT/greeter-build.sh" say "building the system image" docker build -f "$ROOT/Containerfile" --target system -t "$LOCAL" "$ROOT" diff --git a/linux/system/etc/dconf/db/gdm.d/10-seflos-logo b/linux/system/etc/dconf/db/gdm.d/10-seflos-logo @@ -1,5 +0,0 @@ -# The logo at the bottom of GDM's login screen: Sector F Labs, in place of Fedora's -# (linux/branding/make-logo.py makes it). The gdm profile reads this database -# before the schema's default; the Containerfile runs `dconf update`. -[org/gnome/login-screen] -logo='/usr/share/pixmaps/seflos-logo.svg' diff --git a/linux/system/etc/greetd/config.toml b/linux/system/etc/greetd/config.toml @@ -0,0 +1,12 @@ +# greetd runs the Patina greeter (the login and the first-run setup, ADR-0012, ADR-0013) inside +# cage, a kiosk compositor, as the unprivileged greetd user. It talks to greetd over $GREETD_SOCK, +# and greetd starts the person's session, patina-session, once the password is right. +# +# If the greeter is broken, greetd gives up after a few restarts: a text login is still on the +# other consoles (Ctrl+Alt+F2). +[terminal] +vt = 1 + +[default_session] +command = "cage -s -- /usr/libexec/patina-greeter" +user = "greetd" diff --git a/linux/system/usr/lib/tmpfiles.d/patina-greeter.conf b/linux/system/usr/lib/tmpfiles.d/patina-greeter.conf @@ -0,0 +1,3 @@ +# greetd's own tmpfiles entry is `Z`, which fixes the ownership of what exists and never creates +# the greeter's working directory, so the greeter fails with "unable to set working directory". +d /var/lib/greetd 0755 greetd greetd - 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 @@ -0,0 +1,27 @@ +// The greeter may administer accounts, which is what makes the first one, 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 to a helper of our own. +// +// Any doubt closes it: if a check fails, the account counts as able to log in. +polkit.addRule(function(action, subject) { + if (subject.user !== "greetd") return; + if (action.id !== "org.freedesktop.accounts.user-administration") return; + try { + var humans = polkit.spawn(["/usr/bin/getent", "passwd"]).split("\n") + .map(function(line) { return line.split(":"); }) + .filter(function(f) { + var uid = parseInt(f[2], 10); + return uid >= 1000 && uid < 60000 && !/(nologin|false)$/.test(f[6] || ""); + }); + var canLogIn = humans.filter(function(f) { + var locked = polkit.spawn(["/usr/bin/busctl", "--system", "get-property", + "org.freedesktop.Accounts", "/org/freedesktop/Accounts/User" + f[2], + "org.freedesktop.Accounts.User", "Locked"]); + return locked.indexOf("true") === -1; + }); + if (canLogIn.length === 0) return polkit.Result.YES; + } catch (e) { + return; + } +}); diff --git a/linux/vm/README.md b/linux/vm/README.md @@ -21,7 +21,7 @@ vm/vm.sh stop power it off vm/clean.sh stop it and delete out/ (--all: the registry and the image too) ``` -GDM comes up on the screen; log in as **patina**, password **patina**, and the Patina session +The Patina greeter comes up on the screen; log in as **patina**, password **patina**, and the Patina session starts (the dev image adds that user, in `wheel`; the real image has none). Trying an update: @@ -74,9 +74,7 @@ image underneath and keeps the layer. automount sits in front of ostree's `/boot`, and `ostree admin finalize-staged` fails with "Remounting /boot read-write: Invalid argument". `boot.automount` is masked in the image (`system/etc/systemd/system/`); the Containerfile has the upstream issues. -- GDM has no setting for the default session, and AccountsService's templates leave a new user's - session empty, which GDM takes as GNOME. `system/etc/accountsservice/user-templates` makes it - Patina. Fedora's GDM pulls GNOME's session in too, so both show at the login screen. +- The accounts' session comes from `system/etc/accountsservice/user-templates` (Patina), and greetd starts `patina-session` itself; there is no GNOME session in the image any more (ADR-0012). - Fedora's `fedora-bootc` image runs out of disk when `dnf` installs into it with `docker run`: inspect packages in `quay.io/fedora/fedora` instead. - Docker here has only the legacy builder (no BuildKit), so the Containerfile uses `COPY --from` diff --git a/linux/vm/build.sh b/linux/vm/build.sh @@ -6,6 +6,7 @@ source "$(dirname "$0")/common.sh" "$ROOT/desktop/build.sh" +"$ROOT/greeter-build.sh" build_id=$(date -u +%Y-%m-%dT%H:%M:%SZ) say "building $IMAGE ($build_id)" docker build -f "$ROOT/Containerfile" --target dev \