Skip to content

fix: resolve symlinked dotfiles and allowRead paths in sandbox#36

Open
tito wants to merge 2 commits intomainfrom
fix/symlinked-dotfiles-in-sandbox
Open

fix: resolve symlinked dotfiles and allowRead paths in sandbox#36
tito wants to merge 2 commits intomainfrom
fix/symlinked-dotfiles-in-sandbox

Conversation

@tito
Copy link
Copy Markdown
Contributor

@tito tito commented Mar 20, 2026

Summary

Fixes #25 (dotfiles part, as reported by @johanfleury)

Users who manage dotfiles with GNU Stow or similar tools have ~/.gitconfig, ~/.zshrc, etc. as symlinks. In deny-by-default mode, canMountOver() rejected symlinks entirely, so these files were silently skipped and invisible inside the sandbox, causing bwrap: Can't create file errors.

  • Shell config files (.bashrc, .zshrc, .profile, etc.) that are symlinks are now resolved: the real file is bound at the symlink path via --ro-bind <resolved> <symlink-path>
  • Home tool caches (.config, .cache, .npm, etc.) get the same treatment
  • User-specified allowRead paths that are symlinks are resolved and bound correctly, with a refactored bindReadPath helper to reduce duplication

Test plan

  • Integration test: symlinked shell config is readable in deny-by-default mode
  • Integration test: symlinked allowRead path is readable in deny-by-default mode
  • Manual test with GNU Stow managed dotfiles

tito added 2 commits March 19, 2026 19:32
Users who manage dotfiles with GNU Stow or similar tools have shell
configs (.zshrc, .gitconfig, etc.) as symlinks. In deny-by-default mode,
canMountOver() rejected symlinks entirely, so these files were silently
skipped, making them invisible inside the sandbox.

Changes:
- Shell config files (.bashrc, .zshrc, etc.) that are symlinks are now
  resolved: the real file is bound at the symlink path via --ro-bind
- Home tool caches (.config, .cache, etc.) get the same treatment
- User-specified allowRead paths that are symlinks are resolved and
  bound correctly, with a refactored bindReadPath helper
- Add integration tests verifying symlinked configs and allowRead paths
  are accessible inside the sandbox in deny-by-default mode
- Fix gosec G306/G301: use 0600/0750 permissions in tests
- Fix errcheck: use t.Cleanup instead of defer os.Remove
- Fix gofumpt: remove trailing blank line
- Fix test: use recognized shell config name (.inputrc) so
  buildDenyByDefaultMounts picks it up correctly
- Add legacy mode symlink test for completeness
@johanfleury
Copy link
Copy Markdown

Hey, just wanted to mention that the reason I faced this issue in the first place was because I was running greywall in my HOME directory (I ran grewayl -- curl ... just after installation to test it). I don’t have this issue when running in another directory.

I still think there’s something to fix here, but maybe this information changes the way you do it.

@tito
Copy link
Copy Markdown
Contributor Author

tito commented Mar 21, 2026

Thank you for comment, I'll have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bwrap: Can't create file at /etc/resolv.conf: No such file or directory

2 participants