Add std::os::unix::process::CommandExt::chroot to safely chroot a child process by joshtriplett · Pull Request #137759 · rust-lang/rust (original) (raw)

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.