fix(web): make ~/downloads writable from inside a session - #320
Merged
Conversation
`~/downloads` is a symlink to /var/lib/agent-box-downloads/<user>, so a
write through it resolves outside /home and ProtectSystem=strict denied it
with EROFS. The agent unit's ReadWritePaths named the SITES dir and not the
downloads one — so the hand-off the canonical guide documents ("mv
./report.pdf ~/downloads/", then give out ${AGENT_BOX_URL}downloads/…) has
never worked from a session:
$ touch /var/lib/agent-box-downloads/agent/probe
touch: ... Read-only file system
Same guard as its neighbour: listed only when web.enable is on, since that
is what gates the tmpfiles rule that creates the dir, and an unconditional
entry fails the whole namespace setup with 226/NAMESPACE on a default
web-less box.
The test is the interesting part. web-surface.nix already exercised this
drop — but as `sudo -u agent` from the driver's root shell, which skips
ProtectSystem entirely, so it passed against a read-only directory. Both
documented flows now write through `nsenter -t <MainPID> -m -- runuser -u
agent`, the handle is hoisted so neither can drift back, and each asserts
its own dir is in the unit's ReadWritePaths.
Fixes #316.
lionello
approved these changes
Aug 21, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #316.
~/downloadsis a symlink to/var/lib/agent-box-downloads/<user>, so a write through it resolves outside/homeandProtectSystem=strictdenies it. The agent unit'sReadWritePathsnamed the sites dir and not the downloads dir, so the hand-off the canonical guide documents has never worked from inside a session:Found while trying to publish a screenshot for #317 from a session.
The fix
One entry, under the same
web.enableguard as its neighbour — the tmpfiles rule that creates the dir is gated too, and an unconditional entry fails the namespace setup with 226/NAMESPACE on a default web-less box (the failure modememory-protection.nixexists to catch).Why the existing test did not catch it
web-surface.nixalready exercised the drop — but assudo -u agentfrom the driver's root shell, which skipsProtectSystementirely, so it passed against a read-only directory. The~/sitessubtest right below it had already learned this lesson and usednsenter; the downloads one had not.Both documented flows now write through
nsenter -t <MainPID> -m -- runuser -u agent, with the namespace handle hoisted above the subtests so neither can drift back, and each asserts its own directory is in the unit'sReadWritePaths.Checks run
nix run .#assemble+module-generated-up-to-date— oknix run .#update-golden+golden-snapshot— ok. The golden diff is exactly two lines,ReadWritePaths=/var/lib/agent-box-downloads/{agent,robot}, and only undertests/golden/web/— the ungated (web-off) unit is untouched, which is the 226/NAMESPACE guard holding.module-single-file,multi-user— oknix eval .#checks.x86_64-linux.{web-surface,memory-protection}.drvPath— both evaluate (VM tests are x86-only; CI runs them)