-
Notifications
You must be signed in to change notification settings - Fork 22
ACP: std::os::unix::process::CommandExt::chroot #551
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
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Comments
Implementation at rust-lang/rust#137759 . |
ACP approved in the @rust-lang/libs-api meeting. |
4 tasks
Tracking issue created. Thank you! |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
May 21, 2025
Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/". --- ACP: rust-lang/libs-team#551 This PR currently has the tracking issue set to "none"; if the ACP is approved, I'll file a tracking issue and update the PR.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
May 21, 2025
…nieu Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/". --- ACP: rust-lang/libs-team#551 This PR currently has the tracking issue set to "none"; if the ACP is approved, I'll file a tracking issue and update the PR.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
May 21, 2025
Rollup merge of rust-lang#137759 - joshtriplett:command-chroot, r=Amanieu Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/". --- ACP: rust-lang/libs-team#551 This PR currently has the tracking issue set to "none"; if the ACP is approved, I'll file a tracking issue and update the PR.
github-actions bot
pushed a commit
to model-checking/verify-rust-std
that referenced
this issue
May 23, 2025
…nieu Add `std::os::unix::process::CommandExt::chroot` to safely chroot a child process This adds a `chroot` method to the `CommandExt` extension trait for the `Command` builder, to set a directory to chroot into. This will chroot the child process into that directory right before calling chdir for the `Command`'s working directory. To avoid allowing a process to have a working directory outside of the chroot, if the `Command` does not yet have a working directory set, `chroot` will set its working directory to "/". --- ACP: rust-lang/libs-team#551 This PR currently has the tracking issue set to "none"; if the ACP is approved, I'll file a tracking issue and update the PR.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Problem statement
We provide
std::os::unix::fs::chroot
to provide a safe interface tochroot
. However, we don't provide any safe way to run a child process in a chroot.Solution sketch
Alternatives
The proposed interface automatically sets the current directory for the child process if it isn't yet set, to avoid ending up in the situation where the current directory is outside the chroot. We could, instead, leave the current directory untouched, and leave the user responsible for calling
current_dir
themselves. However, I think it's worth not exposing the weird situation to users. If users really want to end up in that weird situation (e.g. because they're trying to write code that busts out of a chroot) they can make direct syscalls.What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: