-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Read-only sandbox paths mounts (Linux) #13315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
for example, `/dev/nvidiactl?` specifies that `/dev/nvidiactl` will | ||
only be mounted in the sandbox if it exists in the host filesystem. | ||
A list of paths bind-mounted into Nix sandbox environments. Use the | ||
syntax `target[=source][:ro][?]` to control the mount: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of ad hoc formats like this, I would prefer that structured options use JSON, e.g.
sandbox-paths = [ {"target": "/foo", "source": "/bar", "readOnly": true, "optional": true} ]
or perhaps
sandbox-paths = { "/foo" : {"source": "/bar", "readOnly": true, "optional": true} }
This also makes it more future-proof when we switch nix.conf
to JSON entirely.
For an example of how to do JSON options, see the external-builders
setting in this PR:
- https://github.com/DeterminateSystems/nix-src/pull/78/files#diff-fc61af5dc32777fbdca32b2c72c3a1842457dc92dfcf47919bd96b944b7a6479
- https://github.com/DeterminateSystems/nix-src/pull/78/files#diff-4f84c7126ef8b87cefd2d430990cceb5c920e1684f1e9c28bbb4104bd7632304
In this case it's slightly more complex because we have to handle the non-JSON case for backward compatibility, but that should be pretty easy (just check if the first non-whitespace character is [
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented this and the smaller changes in latest commit, please take a look.
2eaca52
to
97c779b
Compare
Signed-off-by: Samuli Thomasson <[email protected]>
some of the functional tests that run config check wouldn't tolerate some oddities in `PATH`, something like a null string entry (e.g. `::` in the middle or a trailing `:`) I think. This allows the test pass. Signed-off-by: Samuli Thomasson <[email protected]>
Signed-off-by: Samuli Thomasson <[email protected]>
Signed-off-by: Samuli Thomasson <[email protected]>
Signed-off-by: Samuli Thomasson <[email protected]>
97c779b
to
1b2c828
Compare
Motivation
This extends the
sandbox-paths
syntax to allowthe extra optional suffixextended JSON syntax for marking that path so as to be mounted read-only in the sandbox.:ro
The suffix is excluded from the mounted source or target path. It will only cause the mountThe new "readOnly" option enablesMS_RDONLY
flag to be set.MS_RDONLY
and a few other mount-point flags for the affected bind-mount.Context
...well, technically we make then another
mount(2)
call on the target path right after mounting the path for the first time, in order to do a second mount (or rather remount,MS_REMOUNT
) withMS_RDONLY
. For some reason singlemount
syscall can't both create a new bind-mount and assign the read-only flag to it (its mount-point really) ... or propagation properties for that matter.The
mount(8)
cli fromutil-linux
abstracts over this with a second syscall as necessary as well (more even sometimes, it seems).There's a better, modern API since about linux 5.12 with
open_tree()
,mount_setattr()
andmove_mount()
. Probably doesn't really make a difference until there's some need or want for those features though.One of the commits (2eaca52) is not related to to the bulk of the changes in this. it's a small change to fix a certain edge-case (think user launching
nix
or running tests with aPATH
that still works, for all intents and purposes, but looks like it fell through a slipstream portal sideways).add 👍 to pull requests you find important.
the nix maintainer team uses a github project board to schedule and track reviews