about summary refs log tree commit diff
path: root/library/std/src/sys/process/unix/vxworks.rs
diff options
context:
space:
mode:
authorJosh Triplett <josh@joshtriplett.org>2025-02-27 22:00:15 +0000
committerJosh Triplett <josh@joshtriplett.org>2025-05-20 18:25:05 +0200
commita3cf6f640828647e34afe96a626b3b4f6bbb22b1 (patch)
treed358007b1f6aa3b6d79eaac3abe480c2f0958b1a /library/std/src/sys/process/unix/vxworks.rs
parentf8e9e7636aabcbc29345d9614432d15b3c0c4ec7 (diff)
downloadrust-a3cf6f640828647e34afe96a626b3b4f6bbb22b1.tar.gz
rust-a3cf6f640828647e34afe96a626b3b4f6bbb22b1.zip
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 "/".
Diffstat (limited to 'library/std/src/sys/process/unix/vxworks.rs')
-rw-r--r--library/std/src/sys/process/unix/vxworks.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/std/src/sys/process/unix/vxworks.rs b/library/std/src/sys/process/unix/vxworks.rs
index fab3b36ebf3..f33b4a375da 100644
--- a/library/std/src/sys/process/unix/vxworks.rs
+++ b/library/std/src/sys/process/unix/vxworks.rs
@@ -27,6 +27,12 @@ impl Command {
                 "nul byte found in provided data",
             ));
         }
+        if self.get_chroot().is_some() {
+            return Err(io::const_error!(
+                ErrorKind::Unsupported,
+                "chroot not supported by vxworks",
+            ));
+        }
         let (ours, theirs) = self.setup_io(default, needs_stdin)?;
         let mut p = Process { pid: 0, status: None };