diff options
Diffstat (limited to 'library/std/src/sys/process/unix/common.rs')
| -rw-r--r-- | library/std/src/sys/process/unix/common.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/std/src/sys/process/unix/common.rs b/library/std/src/sys/process/unix/common.rs index a9c2510e6d4..e205a839005 100644 --- a/library/std/src/sys/process/unix/common.rs +++ b/library/std/src/sys/process/unix/common.rs @@ -88,6 +88,7 @@ pub struct Command { program_kind: ProgramKind, cwd: Option<CString>, + chroot: Option<CString>, uid: Option<uid_t>, gid: Option<gid_t>, saw_nul: bool, @@ -182,6 +183,7 @@ impl Command { program_kind, env: Default::default(), cwd: None, + chroot: None, uid: None, gid: None, saw_nul, @@ -206,6 +208,7 @@ impl Command { program_kind, env: Default::default(), cwd: None, + chroot: None, uid: None, gid: None, saw_nul, @@ -254,6 +257,12 @@ impl Command { pub fn pgroup(&mut self, pgroup: pid_t) { self.pgroup = Some(pgroup); } + pub fn chroot(&mut self, dir: &Path) { + self.chroot = Some(os2c(dir.as_os_str(), &mut self.saw_nul)); + if self.cwd.is_none() { + self.cwd(&OsStr::new("/")); + } + } #[cfg(target_os = "linux")] pub fn create_pidfd(&mut self, val: bool) { @@ -326,6 +335,10 @@ impl Command { pub fn get_pgroup(&self) -> Option<pid_t> { self.pgroup } + #[allow(dead_code)] + pub fn get_chroot(&self) -> Option<&CStr> { + self.chroot.as_deref() + } pub fn get_closures(&mut self) -> &mut Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>> { &mut self.closures |
