sector-f-linux

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

commit 23fa6e5f98916ba3ec4dc88bf76e65dd2f654a17
parent aba36e51fff91f1ca461fb1cf38c235a17dc3ed8
Author: Divan Visagie <me@divanv.com>
Date:   Sat, 21 Nov 2026 00:00:01 +0100

ADR-0012: the greeter makes the first account through AccountsService; a polkit rule decides when

The first design, a root helper that made the account, needed an SELinux policy of its own and auditd to write it. Asking AccountsService directly needs neither: with SELinux enforcing, the greeter in the display-manager domain can already call it, and a polkit rule (linux/prototype/50-patina-first-user.rules) lets the greeter user administer accounts only while no human account can log in, meaning none exists or all are still locked. That keeps the window open for the password and for taking a half-made account back out, and closes it when a password is set; a failed check counts as closed. A first version, 'only while none exists', shut the window as soon as the account was made, so the password and the rollback were refused.

Checked on the VM: the whole flow under enforcing (no account, the greeter makes one and sets the password, greetd logs it into the Patina session); once an account can log in, CreateUser, SetPassword and DeleteUser are refused; with none, the greeter can create an account and take it back out while it is locked; another user is refused. The refusal checks ran through su, so they show the rule's logic and not SELinux. Not tried: two greeters at once, and the rule failing closed on an error.

The helper (patina-setupd, its units and the scripted greeter for it) is removed from the tree and stays in aba36e5; the ADR records what it cost. linux/prototype/ keeps the direct scripted greeter, the rule and a README. Also recorded: greetd's tmpfiles rule never creates /var/lib/greetd, a uid reused right after a delete raced once, and greetd gives up on a greeter that keeps failing.

Diffstat:
Mdocs/adr/0012-a-login-manager-of-our-own-greetd-and-a-patina-greeter.md | 91++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Alinux/prototype/50-patina-first-user.rules | 27+++++++++++++++++++++++++++
Mlinux/prototype/README.md | 31++++++++++++++++---------------
Dlinux/prototype/patina-setup.socket | 13-------------
Dlinux/prototype/patina-setup@.service | 11-----------
Dlinux/prototype/patina-setupd | 86-------------------------------------------------------------------------------
Dlinux/prototype/proto-greeter | 88-------------------------------------------------------------------------------
Alinux/prototype/proto-greeter-direct | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 186 insertions(+), 251 deletions(-)

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 @@ -45,16 +45,18 @@ What is available: live disc's `liveuser`, and for a first login straight after the setup. - **First run**, when there is no human account (uid 1000 or above; to verify how best to tell): the setup of ADR-0011, with the account first. -- **Both live in this repository (patina-os), not in patina-desktop:** the greeter and the helper are - OS code, what logs in, and not part of the desktop session. Where the greeter wants Patina's - interface pieces it depends on the Patina libraries or copies what the lock screen does; it - does not change patina-desktop. -- **An account helper**, a small root service that only makes the first user. It is socket-activated, - listens on a Unix socket only the greeter user can reach, checks the name and the other fields, - refuses once any human account exists (and under a lock, so two requests cannot both succeed), - and makes the account through AccountsService as in the experiment. It is a helper and not a - polkit rule because a rule has to express "only while no users exist" in policy, and the helper - can be read in one sitting. The greeter stays unprivileged. +- **The greeter lives in this repository (patina-os), not in patina-desktop:** it is OS code, what + logs in, and not part of the desktop session. Where it wants Patina's interface pieces it depends on + the Patina libraries or copies what the lock screen does; it does not change patina-desktop. +- **The greeter makes the first account itself, through AccountsService, and polkit says when it + may.** It calls `CreateUser` and `SetPassword` over D-Bus, as the experiment did, and a polkit rule + (`linux/prototype/50-patina-first-user.rules`) lets the greeter user, and only that user, do + `org.freedesktop.accounts.user-administration` while **no human account can log in**: none exists + (uid 1000 and up, with a shell), or those that do are all still locked. That keeps the window + open for the password, and for taking a half-made account back out if the setup fails, and it + closes the moment a password is set. If a check in the rule fails, it counts as closed. + A helper of our own was built and tried first (below) and dropped: it needs a root service and an + SELinux policy of its own, and this does not. - **After the account exists,** the greeter logs it straight into the session through greetd, with the password it was just given, as on a Mac, and from then on shows the login mode. - **GDM goes.** With it, gnome-shell, the GNOME session entry, `linux/branding/gdm-theme.py` and @@ -72,8 +74,9 @@ accepted for now. - Which kiosk compositor, and whether Patina's compositor can run as a greeter session for a user with no account of their own (it uses libseat, so logind should do). -- How the helper knows nobody is already set up, and what happens if the setup is interrupted - half way. +- What happens if the setup is interrupted half way: the account is locked, so the window is still + open and the setup can run again, but it should say so; and the greeter, not AccountsService, + has to check names for the person typing (AccountsService does check them) and hash the password. - HiDPI and several monitors on the greeter, and the cursor. - Joining the tailnet, and the encryption of ADR-0011, as setup steps. - Whether greetd's own PAM service (`greetd`) needs more than Fedora's default for the fingerprint @@ -82,48 +85,60 @@ accepted for now. ## Order of work 1. **A prototype on the VM** (done, see above): layer greetd, `gtkgreet` and `cage`, replace GDM, and - drive greetd by script as the greeter user: no account, the helper makes the first, and greetd - starts that user's Patina session. The SELinux policy for the helper is still to do. + drive greetd by script as the greeter user: no account, the greeter makes the first through + AccountsService, and greetd starts that user's Patina session. 2. The greeter app, in login mode. -3. The first-run mode, on top of the helper. +3. The first-run mode, on top of AccountsService and the polkit rule. 4. Remove GDM, gnome-shell, the theme stage and the dconf logo setting from the image. 5. The gaps above, as they matter. ## Prototype (2026-11-20) Done on the VM installed from the published image, with greetd, `gtkgreet` and `cage` layered on with -`rpm-ostree install` (22 packages with their dependencies, and the layering survived the reboot). -The code is in `linux/prototype/`. +`rpm-ostree install` (22 packages with their dependencies; the layering survived the reboot). The +code is in `linux/prototype/`. Two ways of making the first account were tried. -Verified: +Verified, for both: - **greetd hosts a greeter on this image.** With GDM disabled, greetd runs `cage` and `gtkgreet` as the unprivileged `greetd` user, and its PAM services (`greetd`, `greetd-greeter`) are there. -- **The account helper does what the decision says.** From the greeter user, a bad name and a bad - request are refused, a caller outside the greeter's group cannot connect, the first request makes - the account, and a second is refused with "already set up". Two simultaneous requests gave exactly - one account, and so did three after a pause: the lock works. -- **The whole flow works.** A scripted greeter (`proto-greeter`, speaking greetd's protocol) found no - human account, asked the helper for one, logged it in through greetd with the password just - given, and greetd started its Patina session on tty1: the compositor, the hud pieces and the rest - ran as the new user, and the screen showed the desktop. Run with SELinux permissive (below). - -Not working yet, and found: -- **SELinux blocks it when enforcing.** The greeter runs in `xdm_t` and is denied write on the - helper's socket, labeled `var_run_t`; AccountsService (`accountsd_t`) is denied search on a - directory of the helper's, probably to look at the caller. The helper needs a policy of its own: a - type for the process and one for its socket, allowing `xdm_t` to reach the socket, and - AccountsService to look at the caller. Writing it needs the full list of denials, and this image - cannot give one: it has no `auditd` or `ausearch`, and the kernel rate-limits the audit messages - it prints (158 suppressed in one run), so `auditd` has to be added before the policy can be - written. An earlier "no denials" check of mine used `ausearch`, which is not on the image, and - meant nothing; the kernel log is where the real denial was. +- **The whole flow works.** A scripted greeter speaking greetd's protocol found no human account, + had the first one made, logged it in through greetd with the password just given, and greetd + started its Patina session on tty1: the compositor, the hud pieces and the rest ran as the new + user, and the screen showed the desktop. + +**The chosen route: the greeter asks AccountsService, and a polkit rule decides** (`proto-greeter-direct` +and `50-patina-first-user.rules`). It works with SELinux enforcing and no policy of our own: the +greeter, in the display-manager domain, can already call AccountsService, and no denial showed. +Checked: the greeter made the account and set its password, and greetd started the session; once an +account can log in, the greeter is refused `CreateUser`, `SetPassword` and `DeleteUser`; with no +accounts it can create one and take it back out while it is locked; and another user (`nobody`) is +refused. Found on the way: a first version of the rule, "only while no human account exists", shut +the window as soon as the account was made, so the password was refused, and so was the rollback, +which left an account nobody could log in to and no way to run the setup again. "No human account +that can log in" fixes it. The refusal checks ran through `su`, so they show the rule's logic and +not SELinux; the real run through greetd showed SELinux. Not tried: two greeters asking at once (there is +one greeter), and the rule failing closed when a check errors. + +**The dropped route: a helper of our own** (`patina-setupd`, a socket-activated root service, in +this repository's history at commit 99f1870). It validated its input, took a lock, and rolled +back, and passed its checks: bad requests refused, callers outside the greeter's group unable to +connect, and one account for two or three simultaneous requests. But with SELinux enforcing the +greeter (`xdm_t`) was denied the helper's socket (`var_run_t`) and AccountsService (`accountsd_t`) +was denied a look at the caller, so it needed a policy module of its own, and writing one needs +`auditd`, which this image lacks. (The kernel rate-limits the audit messages it prints: 158 +were suppressed in one run. An earlier "no denials" check of mine used `ausearch`, which is not on +the image, and meant nothing; the kernel log is where the real denial was.) + +Also found, for either route: - **`/var/lib/greetd` is never created.** greetd's tmpfiles rule is `Z`, which only fixes the ownership of what exists, so the greeter starts with "unable to set working directory". The image needs its own `d` entry. - **uid reuse is racy.** Deleting an account and creating another at once reused uid 1000, and the password could not be set on the AccountsService object that was still going away. It did not recur after a pause. It matters for a factory reset (ADR-0011), where users are removed and made again. -- **`/usr/local` is read-only**, so the helper belongs in `/usr/libexec`, shipped in the image. +- **greetd restarts a greeter that exits with an error**, until it gives up ("start of the service + was attempted too often"), so a broken greeter locks the screen: a text console login has to stay + available. ## Consequences diff --git a/linux/prototype/50-patina-first-user.rules b/linux/prototype/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/prototype/README.md b/linux/prototype/README.md @@ -1,21 +1,22 @@ # Prototype: the login manager of ADR-0012 -Throwaway code that proved the architecture on a VM. Nothing here ships. The real greeter and helper -will be written in this repository (not in patina-desktop), the helper as a Rust service shipped in -the image with an SELinux policy of its own. +Throwaway code that proved the architecture on a VM. Nothing here ships. The real greeter will be +written in this repository (not in patina-desktop), and the polkit rule moves into the image. -- `patina-setupd`: the account helper. Socket-activated, one JSON request in, one reply out; makes - the first user through AccountsService and refuses once any human account exists, under a lock. -- `patina-setup.socket`, `patina-setup@.service`: its units. The socket is root:greetd, mode 0660. -- `proto-greeter`: a scripted stand-in for the greeter. With no human account it asks the helper for - one, then logs that account in through greetd's protocol and starts `patina-session --session`. +- `proto-greeter-direct`: a scripted stand-in for the greeter. With no human account it makes the + first one through AccountsService (`CreateUser`, `SetPassword`), then logs it in through greetd's + protocol and starts `patina-session --session`. Its steps go to `/tmp/proto-direct.log`. +- `50-patina-first-user.rules`: the polkit rule that lets the greeter user administer accounts only + while no human account can log in (none exist, or all are locked). -## Trying it on the test VM +The first design, a root helper service that made the account, was built and dropped: see the ADR, +and commit 99f1870 for its code. -The VM's `/usr` is read-only: make it writable for one boot with `bootc usroverlay`, and put the two -scripts in `/usr/libexec` (`restorecon` them). The units go in `/etc/systemd/system`. greetd, -`gtkgreet` and `cage` come from `rpm-ostree install`; GDM is disabled and greetd enabled. Set -`/etc/greetd/config.toml`'s `default_session.command` to `/usr/libexec/proto-greeter`. +## Trying it on the test VM -SELinux, enforcing, blocks the greeter from the helper's socket: see the ADR's prototype section. -`setenforce 0` shows the flow working. +The VM's `/usr` is read-only: make it writable for one boot with `bootc usroverlay`, and put +`proto-greeter-direct` in `/usr/libexec` (`restorecon` it). The rule goes in +`/etc/polkit-1/rules.d/`. greetd, `gtkgreet` and `cage` come from `rpm-ostree install`; GDM is +disabled and greetd enabled; `/etc/greetd/config.toml`'s `default_session.command` is +`/usr/libexec/proto-greeter-direct`. SELinux stays enforcing. If greetd gives up after repeated +greeter failures, `systemctl reset-failed greetd` before starting it again. diff --git a/linux/prototype/patina-setup.socket b/linux/prototype/patina-setup.socket @@ -1,13 +0,0 @@ -[Unit] -Description=Patina first-account helper (socket) - -[Socket] -ListenStream=/run/patina-setup.sock -SocketMode=0660 -SocketUser=root -SocketGroup=greetd -Accept=yes -MaxConnections=4 - -[Install] -WantedBy=sockets.target diff --git a/linux/prototype/patina-setup@.service b/linux/prototype/patina-setup@.service @@ -1,11 +0,0 @@ -[Unit] -Description=Patina first-account helper - -[Service] -ExecStart=/usr/libexec/patina-setupd -StandardInput=socket -StandardOutput=socket -StandardError=journal -NoNewPrivileges=yes -PrivateTmp=yes -TimeoutStartSec=30 diff --git a/linux/prototype/patina-setupd b/linux/prototype/patina-setupd @@ -1,86 +0,0 @@ -#!/usr/bin/python3 -"""The account helper of ADR-0012, as a prototype: makes the first user, once. - -Socket-activated (patina-setup.socket, Accept=yes), so each connection runs this once: one JSON -line in on stdin, one JSON line out on stdout. The socket is reachable only by root and the greeter's -group. It refuses once any human account exists, under a lock so two requests cannot both succeed, -and makes the account through AccountsService (D-Bus), as the experiment did. - - request: {"username": "alice", "fullname": "Alice Example", "password": "..."} - reply: {"ok": true, "username": "alice"} or {"ok": false, "error": "..."} -""" -import fcntl -import json -import pwd -import re -import subprocess -import sys - -LOCK = "/run/patina-setup.lock" -BUS = ["busctl", "--system", "call", "org.freedesktop.Accounts"] - - -def reply(ok, **fields): - sys.stdout.write(json.dumps({"ok": ok, **fields}) + "\n") - sys.stdout.flush() - sys.exit(0) - - -def humans(): - """Accounts a person could log in as: uid 1000 and up, with a shell.""" - return [p.pw_name for p in pwd.getpwall() - if 1000 <= p.pw_uid < 60000 and not p.pw_shell.endswith(("nologin", "false"))] - - -def log(*a): - print("patina-setupd:", *a, file=sys.stderr, flush=True) # goes to the journal; never the password - - -def call(path, iface, method, sig, *args): - r = subprocess.run(BUS[:3] + [BUS[3], path, iface, method, sig, *map(str, args)], - capture_output=True, text=True) - if r.returncode: - log(method, "failed:", r.stderr.strip()[:200]) - return r - - -line = sys.stdin.buffer.readline(4096) # bounded: one request -try: - req = json.loads(line) - name, full, password = req["username"], req["fullname"], req["password"] - assert all(isinstance(x, str) for x in (name, full, password)) -except Exception: - reply(False, error="bad request") - -if not re.fullmatch(r"[a-z][a-z0-9_-]{0,30}", name): - reply(False, error="the user name must be lower case letters, digits, - and _, starting with a letter") -if not (1 <= len(full) <= 64) or re.search(r"[:\x00-\x1f\x7f]", full): - reply(False, error="bad full name") -if not (1 <= len(password) <= 256) or "\n" in password: - reply(False, error="bad password") - -with open(LOCK, "w") as lock: - fcntl.flock(lock, fcntl.LOCK_EX) # a second request waits here, then finds the account made - if humans(): - log("refused: already set up", humans()) - reply(False, error="already set up") - try: - pwd.getpwnam(name) - reply(False, error="that name is taken") - except KeyError: - pass - - made = call("/org/freedesktop/Accounts", "org.freedesktop.Accounts", "CreateUser", "ssi", name, full, 1) - if made.returncode: - reply(False, error="could not create the account") - uid = pwd.getpwnam(name).pw_uid - path = f"/org/freedesktop/Accounts/User{uid}" - crypted = subprocess.run(["openssl", "passwd", "-6", "-stdin"], input=password + "\n", - capture_output=True, text=True).stdout.strip() - ok = crypted.startswith("$6$") and not call(path, "org.freedesktop.Accounts.User", "SetPassword", - "ss", crypted, "").returncode - if not ok: # leave the machine as it was: still with no user - log("rolling back", name, "uid", uid) - call("/org/freedesktop/Accounts", "org.freedesktop.Accounts", "DeleteUser", "xb", uid, "true") - reply(False, error="could not set the password") - reply(True, username=name) diff --git a/linux/prototype/proto-greeter b/linux/prototype/proto-greeter @@ -1,88 +0,0 @@ -#!/usr/bin/python3 -"""A scripted stand-in for the Patina greeter (ADR-0012), to prove the architecture before any interface. - -greetd runs this as the greeter user. With no human account it asks the account helper -(patina-setupd) to make the first one; then it logs that account in through greetd's protocol -and starts the Patina session, which is what the real greeter does after its setup screen. -Messages to and from greetd are a 4 byte native-endian length and a JSON body, over $GREETD_SOCK. -""" -import json -import os -import pwd -import socket -import struct -import sys - -USER, FULL, PASSWORD = "erin", "Erin Prototype", "sectorf-proto" - - -def log(*a): - print("proto-greeter:", *a, file=sys.stderr, flush=True) - - -def humans(): - return [p.pw_name for p in pwd.getpwall() - if 1000 <= p.pw_uid < 60000 and not p.pw_shell.endswith(("nologin", "false"))] - - -def talk(sock_path, obj, framed): - s = socket.socket(socket.AF_UNIX) - s.connect(sock_path) - return s - - -def send(s, msg): - body = json.dumps(msg).encode() - s.sendall(struct.pack("=I", len(body)) + body) - - -def recvn(s, n): - buf = b"" - while len(buf) < n: - chunk = s.recv(n - len(buf)) - if not chunk: - raise EOFError("greetd closed the socket") - buf += chunk - return buf - - -def recv(s): - (n,) = struct.unpack("=I", recvn(s, 4)) - return json.loads(recvn(s, n)) - - -# 1. First run: no one can log in, so ask the helper for the first account. -if not humans(): - log("no human account: first-run setup") - h = socket.socket(socket.AF_UNIX) - h.settimeout(30) - h.connect("/run/patina-setup.sock") - h.sendall((json.dumps({"username": USER, "fullname": FULL, "password": PASSWORD}) + "\n").encode()) - h.shutdown(socket.SHUT_WR) - answer = json.loads(h.makefile().readline()) - log("helper says:", {k: v for k, v in answer.items() if k != "password"}) - if not answer.get("ok"): - sys.exit(1) -else: - log("accounts exist:", humans()) - -# 2. Log that account in through greetd, with the password just given. -g = socket.socket(socket.AF_UNIX) -g.connect(os.environ["GREETD_SOCK"]) -send(g, {"type": "create_session", "username": USER}) -r = recv(g) -while r["type"] == "auth_message": - log("greetd asks:", r["auth_message_type"], repr(r["auth_message"])) - secret = r["auth_message_type"] == "secret" - send(g, {"type": "post_auth_message_response", "response": PASSWORD if secret else None}) - r = recv(g) -if r["type"] != "success": - log("login refused:", r) - send(g, {"type": "cancel_session"}) - sys.exit(1) - -# 3. Start the Patina session, and leave: greetd takes it from here. -send(g, {"type": "start_session", "cmd": ["patina-session", "--session"], "env": []}) -r = recv(g) -log("start_session:", r) -sys.exit(0 if r["type"] == "success" else 1) diff --git a/linux/prototype/proto-greeter-direct b/linux/prototype/proto-greeter-direct @@ -0,0 +1,90 @@ +#!/usr/bin/python3 +"""The other design for ADR-0012's first account: the greeter asks AccountsService itself. + +No helper and no new SELinux domain of our own: the greeter, running as the greeter user in the +display-manager domain, calls AccountsService's CreateUser and SetPassword over D-Bus, and polkit +decides whether it may (a rule, /etc/polkit-1/rules.d/, that allows it only while no human account +exists). Otherwise like proto-greeter: with the account made, it logs it in through greetd. +Its steps go to /tmp/proto-direct.log, since the greeter's own stderr does not reach the journal. +""" +import json +import os +import pwd +import socket +import struct +import subprocess +import sys + +USER, FULL, PASSWORD = "erin", "Erin Prototype", "sectorf-proto" +LOG = "/tmp/proto-direct.log" +ACCOUNTS = ["busctl", "--system", "call", "org.freedesktop.Accounts"] + + +def log(*a): + with open(LOG, "a") as f: + f.write(" ".join(str(x) for x in a) + "\n") + + +def humans(): + return [p.pw_name for p in pwd.getpwall() + if 1000 <= p.pw_uid < 60000 and not p.pw_shell.endswith(("nologin", "false"))] + + +def accounts(path, iface, method, sig, *args): + r = subprocess.run(ACCOUNTS + [path, iface, method, sig, *map(str, args)], + capture_output=True, text=True) + log(method, "-> rc", r.returncode, r.stdout.strip()[:100], "|", r.stderr.strip()[:240]) + return r + + +def send(s, msg): + body = json.dumps(msg).encode() + s.sendall(struct.pack("=I", len(body)) + body) + + +def recvn(s, n): + buf = b"" + while len(buf) < n: + chunk = s.recv(n - len(buf)) + if not chunk: + raise EOFError("greetd closed the socket") + buf += chunk + return buf + + +def recv(s): + (n,) = struct.unpack("=I", recvn(s, 4)) + return json.loads(recvn(s, n)) + + +log("--- start; human accounts:", humans()) +if not humans(): + made = accounts("/org/freedesktop/Accounts", "org.freedesktop.Accounts", "CreateUser", "ssi", USER, FULL, 1) + if made.returncode: + sys.exit(1) + uid = pwd.getpwnam(USER).pw_uid + crypted = subprocess.run(["openssl", "passwd", "-6", "-stdin"], input=PASSWORD + "\n", + capture_output=True, text=True).stdout.strip() + path = f"/org/freedesktop/Accounts/User{uid}" + pw = accounts(path, "org.freedesktop.Accounts.User", "SetPassword", "ss", crypted, "") + if pw.returncode: + log("password refused: removing the account again") + accounts("/org/freedesktop/Accounts", "org.freedesktop.Accounts", "DeleteUser", "xb", uid, "true") + sys.exit(1) + +g = socket.socket(socket.AF_UNIX) +g.connect(os.environ["GREETD_SOCK"]) +send(g, {"type": "create_session", "username": USER}) +r = recv(g) +while r["type"] == "auth_message": + secret = r["auth_message_type"] == "secret" + send(g, {"type": "post_auth_message_response", "response": PASSWORD if secret else None}) + r = recv(g) +if r["type"] != "success": + log("login refused:", r) + send(g, {"type": "cancel_session"}) + sys.exit(1) +send(g, {"type": "start_session", "cmd": ["patina-session", "--session"], "env": []}) +r = recv(g) +log("start_session:", r) +sys.exit(0 if r["type"] == "success" else 1)