Skip to content

Support nested user chrootenv environments - #61740

Merged
abbradar merged 3 commits into
NixOS:masterfrom
abbradar:nested-chrootenv
May 30, 2019
Merged

abbradar merged 3 commits into
NixOS:masterfrom
abbradar:nested-chrootenv

Conversation

@abbradar

Copy link
Copy Markdown
Member
Motivation for this change

Previously we couldn't run chrootenv-wrapped applications inside a chrootenv, we can now. My primary motivation was Lutris, although this is also helpful for development environments.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@abbradar abbradar added the 0.kind: enhancement Add something new or improve an existing system. label May 20, 2019
@abbradar abbradar mentioned this pull request May 20, 2019
5 of 10 tasks
@abbradar
abbradar requested a review from lukateras May 20, 2019 10:18
@ofborg ofborg Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. labels May 20, 2019
@infinisil

Copy link
Copy Markdown
Member

Ah darn, unfortunately #62091 introduced a conflict. It seems that that PR isn't needed anymore after this one, but I'm not so sure on that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that glibc doesn't provide a wrapper for this syscall.

@lukateras lukateras left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This is a huge improvement over current design, both on cleanup (tmpfs) and nesting fronts. I don't see any memory allocation issues.

@lukateras

Copy link
Copy Markdown
Member

Also see #55973, which replaces chrootenv entirely with bubblewrap.

@abbradar

abbradar commented May 28, 2019 via email

Copy link
Copy Markdown
Member Author

@L-as

L-as commented May 30, 2019

Copy link
Copy Markdown
Member

@infinisil mine is completely unneeded after this, since this PR doesn't do any nftw or ftw calls seemingly, which are buggy in glibc.

@abbradar
abbradar force-pushed the nested-chrootenv branch from b3b5b78 to 6328be9 Compare May 30, 2019 12:32
abbradar added 3 commits May 30, 2019 15:33
The problem with stacking chrootenv before was that CLONE_NEWUSER cannot
be used when a child uses chroot. So instead of that we use pivot_root
which replaces root in the whole namespace. This requires our new root
to be an actual fs so we mount tmpfs.
* Remove unused argument from pivot_root;
* Factor out tmpdir creation into a separate function;
* Remove unused fstype from bind mount;
* Use unlink instead of a treewalk to remove empty temporary directory.
To avoid symlink loops to /host in nested chrootenvs we need to remove
one level of indirection. This is also what's generally expected of
/host contents.
@abbradar
abbradar force-pushed the nested-chrootenv branch from 6328be9 to 06f27dc Compare May 30, 2019 12:35
@abbradar

Copy link
Copy Markdown
Member Author

Let's merge now; hopefully we can replace all this code with bwrap in the end ;)

@abbradar
abbradar merged commit 6723d59 into NixOS:master May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.kind: enhancement Add something new or improve an existing system. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants