feat: add NixOS support#93
Draft
Filirom1 wants to merge 1 commit into
Draft
Conversation
On NixOS, executables live under /nix/store and PATH entries such as
/run/current-system/sw/bin are symlinks into the store. Inside the bwrap
sandbox /run is replaced with a tmpfs, so those symlinks become
dangling.
- Replaces the hardcoded /bin/true probe with exec.LookPath("true"),
which
works on NixOS and any distro that does not provide /bin/true.
- Mount /nix read-only in bwrap (like /usr, /opt) and add it to Landlock
read paths so store binaries are reachable inside the sandbox.
- resolveToolPath: resolve the directory component of shell/sleep paths
to
their real /nix/store location while preserving the basename so
multi-call binaries (coreutils) still dispatch via argv[0].
- resolvePathInEnv: rewrite PATH entries in the hardened env to their
real
paths and deduplicate, making the sandbox PATH consistent with what is
actually mounted.
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.
Problem
On NixOS, executables live under
/nix/storeandPATHentries such as/run/current-system/sw/binare symlink chains into the store. Inside the bwrap sandbox,/runis replaced with a tmpfs, so those symlinks become dangling — tools cannot be found and the sandbox fails.Additionally, the network namespace probe hardcoded
/bin/truewhich does not exist on NixOS, causinggreywall checkto falsely report✗ network isolation.Fixes #81. Related to #22.
Changes
linux_features.go: resolvetruefromPATHinstead of hardcoding/bin/trueso the network namespace probe works on NixOS and any distro without/bin/true.linux.go: mount/nixread-only (like/usr,/opt); resolve shell andsleeppaths throughresolveToolPathso the directory component points into/nix/storerather than the hidden/run/current-system/sw/bin.linux_landlock.go: add/nixto Landlock read-allowed paths.sanitize.go: rewritePATHentries through symlinks before passing them into the sandbox, so the sandboxPATHis consistent with what is actually mounted.Tests
On NixOS:
Before
After