-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Chmod build root to make it read-only #11448
base: master
Are you sure you want to change the base?
Conversation
@@ -1970,6 +1970,9 @@ void LocalDerivationGoal::runChild() | |||
if (rmdir("real-root") == -1) | |||
throw SysError("cannot remove real-root directory"); | |||
|
|||
// Make build root read-only, so `mkdir /homeless-shelter` would fail. | |||
chmod_("/", 0555); |
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.
Could this break uid-range
builds (e.g. tests/nixos/containers/systemd-nspawn.nix
)? Those do expect the root to be writable.
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.
Hmm, I guess it could.
I had another idea. If we actually mkdir /homeless-shelter
and then make it read-only, and adjust the "home directory exists" error to be only triggered if the directory exists and is non-empty, I think it may solve the issue. Would you object to always having an empty /homeless-shelter
directory in the sandbox?
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.
Perhaps this should then be controlled by a derivation-provided setting like an "advanced attribute"?
Motivation
Currently, building Nix itself fails in single-user installation - see #11295. This is because some build steps run something like
mkdir -p $HOME/.cache
, and since $HOME is/homeless-shelter
and/
is writable, the directory/homeless-shelter
is created, which may cause the builder to fail.This PR just runs a
chmod
on the build root directory prior tochroot
, to make it read-only. This seems to solve the issue.Context
ubuntu-latest --no-daemon
#11397/proc/homeless-shelter
instead of/homeless-shelter
, which was reverted since it causedmkdir $HOME
to fail with ENOENT instead of EPERM, which caused builds to fail: Make $HOME=/proc/homeless-shelter instead of /homeless-shelter #11300Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.