This repository was archived by the owner on Nov 15, 2026. It is now read-only.
Repository navigation
fix(desktop): stop readd when the GNOME session ends - #83
Merged
Merged
Conversation
readd in local mode watches gnome-session's org.gnome.SessionManager on the session bus, and stops in order when its owner leaves the bus or the bus connection ends. The Flatpak gains --talk-name=org.gnome.SessionManager for it. ADR-0009 records the permission and amends ADR-0008 in part. Fixes #81
frostyard-machines
force-pushed
the
irulan/readd-exits-at-logout
branch
from
November 13, 2026 16:28
f4d0c21 to
151ea63
Compare
…rors dbus.Connect ran authentication and Hello with no deadline and no context: a bus that accepts and never answers held readd's start and its lock. Watch now dials the unix socket itself, with a 10 s deadline that readd's context also ends. Its errors keep only an errno, a deadline, a bus error's name or a fixed text: a net error prints the socket path, and readd logs the error. A signal that comes with the caller's stop no longer reads as the session's end. ADR-0009 names the bound, and states that gnome-session's methods include a shutdown or reboot of the machine.
…ocket A deadline on the socket could fire in godbus's reader after the owner lookup answered, and close the connection after the setup returned: the watch would read that as the session's end. The setup now has a context of its own (the dial included) whose end closes the socket, and the setup succeeds only when context.AfterFunc's stop says the close never ran. Every failure deregisters the close.
bketelsen
approved these changes
Nov 13, 2026
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
readd in local mode now stops when the GNOME session ends, also when lingering or another session keeps the user's systemd instance (Fixes #81).
internal/gnomesession(new):Watchconnects to the session bus at the given address, adds a match rule forNameOwnerChangedonorg.gnome.SessionManager, then asks the name's owner. Its channel closes when that owner leaves the bus, or the bus connection ends. With no owner, it returnsErrNoSession.cmd/readd: in desktop and local mode, before readd serves,watchSessionwatchesDBUS_SESSION_BUS_ADDRESS. When the session ends, readd stops asdaemon.shutdownstops it (workers end, the database closes, the lock is released) and exits 0. With no bus address, no GNOME session, or an unreachable bus, readd logs it once and runs as before. Lodge's readd is unchanged.finish-argsgain--talk-name=org.gnome.SessionManager, and no other permission.internal/packagechecktests the list.github.com/godbus/dbus/v5v5.2.4 (pure Go), only ininternal/gnomesessionand the test helperinternal/bustest;go-sources.jsonregenerated.Watchparses theunix:address itself, dials the socket, and gives the dial, authentication,Hello, the match rule and the owner lookup 10 s, which readd's own stop can end sooner. The bound is a context that closes the socket: the socket never takes a deadline, so no deadline can end a running watch. Its errors never carry the address or the socket path (only an errno, a deadline, a bus error name or a fixed text).internal/bustest(new, tests only): a privatedbus-daemonon a temporary socket; the tests never touch the machine's session bus. The Go tests now needdbus-daemonon PATH (CI's ubuntu-24.04 has it).Why
org.gnome.SessionManagerand not logindBoth need a talk permission; Flatpak has no see-only finish-arg.
--system-talk-name=org.freedesktop.login1is on the system bus. It reaches every user's sessions and the machine's power actions (PowerOff,Reboot,Suspend), which polkit allows an active session without a password on most distributions. logind also counts an SSH session as a session, so readd would have to tell session types apart.--talk-name=org.gnome.SessionManageris 1 name on the user's own session bus, owned by gnome-session for the life of the graphical session. Its methods are not all limited to that session:Logoutends it, andShutdownandRebootask for a shutdown or reboot of the machine. readd calls none of them: onlyAddMatchandGetNameOwneron the bus itself, and it does not register as a session client, so it never delays a logout.CreateMonitoras a rejected alternative for now.Risk tier
Risk tier: 3 —
risk:high(L1 paths). Each matched path, and why the change is safe:packaging/flatpak/org.frostyard.Frostread.json(L1, sandbox permissions): adds exactly 1 finish-arg,--talk-name=org.gnome.SessionManager, a session-bus talk permission to 1 name. No file system, device, network or system-bus change.TestFlatpakManifestpins the full list.packaging/flatpak/go-sources.json(L1, offline sources): generated bymake flatpak-sources; the only change is the godbus v5.2.4 module entries, with their checksums from the Go module proxy.cmd/readd/main.go(L1, sockets and the lock): no socket, mode or lock change. The new code only cancelsrunCtx(the samestopthatdaemon.shutdownuses), so the existing ordered stop runs. The bus connection is a client connection; readd still listens only on its private socket.cmd/readd/desktop_test.go(L1): 2 new tests; no existing test changed.internal/packagecheck/flatpak_manifest_test.go(L2): adds the new finish-arg to the expected list.Docs housekeeping
TEMPLATE.md(ADR-0009)docs/README.mdVerification
make checkgreen (host)make racegreenmake crossgreenmake flatpak-sourcesrun; onlygo-sources.jsonchangedmake vulncheck: No vulnerabilities found.git checkout origin/main -- cmd/readd/main.go packaging/flatpak/org.frostyard.Frostread.json, thengo test -count=1 -run 'TestDesktopStopsWhenTheGNOMESessionEnds|TestFlatpakManifest' ./cmd/readd/ ./internal/packagecheck/:TestDesktopStopsWhenTheGNOMESessionEnds:desktop_test.go:321: readd did not stop when the GNOME session endedTestFlatpakManifest:finish-args = [... --share=network], want [... --share=network --talk-name=org.gnome.SessionManager].memory/corrections.jsonlline. Revert test in a scratch worktree at 1e77089: with the deadline andcontext.AfterFuncremoved, and the dial error formatted raw:TestWatchBoundsAPeerThatNeverAnswers:watch did not return: the setup is unboundedTestWatchEndsWhenTheContextEndsDuringSetup:watch outlived its context: the setup does not take itTestWatchReportsNoAddress/a_socket_nothing_serves:the error carries the address: gnomesession: connect: dial unix .../frostread-secret-bus-path-7f3a ...TestDesktopLogsNoBusAddress:readd's log carries the bus addressAGENTS.mdrule (Code conventions) and 1.memory/corrections.jsonlline.TestWatchOutlivesItsSetupBoundguards against a deadline that stays set.Not checked here: a logout through Flatpak's D-Bus proxy on a real GNOME desktop. The next release's clean-install gate (plan 0002, Phase 10) must check it: with an SSH session open to the desktop, log out of GNOME, and confirm that readd's log shows "the GNOME session ended; readd stops" and
flatpak psshows no readd instance.Cross-review
openai/gpt-6.1-sol. Coders:deepseek/deepseek-flash(Go code and tests),anthropic/claude-opus-5-5(docs). Basec0da796eeeaa658faba55ce224b95de671dc6c07.151ea63: Not ready. 2 blocking findings (unbounded D-Bus setup; the bus socket path in readd's warning) and 2 low (cancellation could read as a session end; ADR wording onShutdown/Reboot). All 4 were fixed in1e77089.1e77089: Not ready. 1 blocking finding (a socket deadline could fire in godbus's reader after setup) and 1 low (the setup callback stayed registered after a failure). Both were fixed in08be219.08be219: Ready, Blocking: none, no new findings.08be219, theFlatpak (build and test)job included.