-
Notifications
You must be signed in to change notification settings - Fork 814
chroot: on Linux, try to pivot_root before falling back to chroot #5874
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
Conversation
e5abfae
to
781fdb8
Compare
Unless --no-pivot or the equivalent API flag is set, try to pivot_root() to enter the rootfs during Run(). Fall back to using chroot() as before if that fails for any reason. Signed-off-by: Nalin Dahyabhai <[email protected]>
781fdb8
to
4adca28
Compare
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, nalind The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
if err := RunUsingChroot(g.Config, bundleDir, "/", new(bytes.Buffer), output, output); err != nil { | ||
t.Fatalf("run: %v: %s", err, output.String()) | ||
if err := RunUsingChroot(g.Config, bundleDir, "/", new(bytes.Buffer), output, output, noPivot); err != nil { | ||
t.Fatalf("run(noPivot=false): %v: %s", err, output.String()) |
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.
Ugh, just spotted the literal "=false" instead of using the passed-in value, opened #5876 to fix it.
FYI, this regressed running If you want a reproducer, you may clone ci-tron at commit https://gitlab.freedesktop.org/gfx-ci/ci-tron/-/commit/ffe8d5841f8b319e7072ec549c71f9c929335de9, then run |
Unless --no-pivot or the equivalent API flag is set, try to pivot_root() to enter the rootfs during Run(). Fall back to using chroot() as before if that fails for any reason.
What type of PR is this?
/kind design
What this PR does / why we need it:
When using chroot isolation, if we can pivot_root() instead of using chroot() for running the command, do that, because it's closer to what a proper runtime can do.
How to verify it
Extended unit tests!
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
We still need chroot() for things like unpacking layers while pulling images, so if you're hoping this means we no longer ever need CAP_SYS_CHROOT, sorry.
Does this PR introduce a user-facing change?