feat(agent): run system install as root and attach to active session (VA-84) #89
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VA-84-system-root-session-attach"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A system install ran the agent as the hardened, unprivileged
vervain-agentuser withProtectHome=true, so it could not reach the logged-in user's Wayland socket, session D-Bus, or X authority. The desktop tab (KVM mode) was therefore dead on every system install; it worked only under a per-user install, and only for the user who ran it.Run the system service as root with no sandbox and no dedicated user, then attach to the machine's active graphical session so the desktop tab drives the already-logged-in desktop regardless of who is logged in. Remove the
ensure_vervain_agent_user/chown_state_dirmachinery and theUser=/Group=/ProtectHome/ProtectSystem(and the rest of the hardening) lines from the rendered system unit; state stays under/etc/vervain-agentand/var/lib/vervain-agent, owned by root. A least-privilege unit is out of scope; script a custom unit if needed.Add
active_session: on Linux, when running as root the agent discovers the active local session onseat0vialoginctl, then exportsXDG_RUNTIME_DIR,DBUS_SESSION_BUS_ADDRESS,WAYLAND_DISPLAY, andXDG_SESSION_TYPEbefore any worker thread or the lazily-opened portal session starts, so ashpd/zbus connect to that user's session bus. With no active graphical session it leaves the environment untouched and logs a clear "desktop tab unavailable until a user logs in" status rather than crashing or shipping black frames. Per-user installs are a no-op (they already live in the session). X11 attach is deferred to VA-86; the display-manager greeter login is VA-85.Replace the
--system/--userboolean pair oninstallanduninstallwith a single--install-type {user|system}clapValueEnum, defaulting tosystem. The not-root hint now points at--install-type user.Tests: pure parsers for the loginctl seat/session output, session selection (rejects remote/inactive/uid-less sessions, accepts
State=activewithout theActiveflag), and the Wayland socket scan; a unit guard that the rendered system unit has noUser=/sandbox lines; and a source guard that the dedicated-user / chown helpers stay removed. README install docs updated.#VA-84
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
A system install ran the agent as the hardened, unprivileged `vervain-agent` user with `ProtectHome=true`, so it could not reach the logged-in user's Wayland socket, session D-Bus, or X authority. The desktop tab (KVM mode) was therefore dead on every system install; it worked only under a per-user install, and only for the user who ran it. Run the system service as root with no sandbox and no dedicated user, then attach to the machine's active graphical session so the desktop tab drives the already-logged-in desktop regardless of who is logged in. Remove the `ensure_vervain_agent_user` / `chown_state_dir` machinery and the `User=`/`Group=`/`ProtectHome`/`ProtectSystem` (and the rest of the hardening) lines from the rendered system unit; state stays under `/etc/vervain-agent` and `/var/lib/vervain-agent`, owned by root. A least-privilege unit is out of scope; script a custom unit if needed. Add `active_session`: on Linux, when running as root the agent discovers the active local session on `seat0` via `loginctl`, then exports `XDG_RUNTIME_DIR`, `DBUS_SESSION_BUS_ADDRESS`, `WAYLAND_DISPLAY`, and `XDG_SESSION_TYPE` before any worker thread or the lazily-opened portal session starts, so ashpd/zbus connect to that user's session bus. With no active graphical session it leaves the environment untouched and logs a clear "desktop tab unavailable until a user logs in" status rather than crashing or shipping black frames. Per-user installs are a no-op (they already live in the session). X11 attach is deferred to VA-86; the display-manager greeter login is VA-85. Replace the `--system` / `--user` boolean pair on `install` and `uninstall` with a single `--install-type {user|system}` clap `ValueEnum`, defaulting to `system`. The not-root hint now points at `--install-type user`. Tests: pure parsers for the loginctl seat/session output, session selection (rejects remote/inactive/uid-less sessions, accepts `State=active` without the `Active` flag), and the Wayland socket scan; a unit guard that the rendered system unit has no `User=`/sandbox lines; and a source guard that the dedicated-user / chown helpers stay removed. README install docs updated. #VA-84 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>