diff options
| author | Jeremy Soller <jeremy@system76.com> | 2019-04-07 08:39:54 -0600 |
|---|---|---|
| committer | Jeremy Soller <jeremy@system76.com> | 2019-08-06 16:18:23 -0600 |
| commit | 0498da9a3dc061f604fcfb9b56bd889e07f2b7e2 (patch) | |
| tree | c297dc9d51cd63c0a1297426ae3633e3921dcb44 /src/libstd/sys/unix/process | |
| parent | 6a91782b72fca586b15ba68364bc7baab837af86 (diff) | |
| download | rust-0498da9a3dc061f604fcfb9b56bd889e07f2b7e2.tar.gz rust-0498da9a3dc061f604fcfb9b56bd889e07f2b7e2.zip | |
redox: convert to target_family unix
Diffstat (limited to 'src/libstd/sys/unix/process')
| -rw-r--r-- | src/libstd/sys/unix/process/process_common.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process/process_unix.rs | 19 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 3ff4f194cd1..9f81c67b477 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -12,6 +12,14 @@ use crate::collections::BTreeMap; use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE}; +cfg_if! { + if #[cfg(target_os = "redox")] { + const DEV_NULL: &'static str = "null:\0"; + } else { + const DEV_NULL: &'static str = "/dev/null\0"; + } +} + //////////////////////////////////////////////////////////////////////////////// // Command //////////////////////////////////////////////////////////////////////////////// @@ -298,7 +306,7 @@ impl Stdio { opts.read(readable); opts.write(!readable); let path = unsafe { - CStr::from_ptr("/dev/null\0".as_ptr() as *const _) + CStr::from_ptr(DEV_NULL.as_ptr() as *const _) }; let fd = File::open_c(&path, &opts)?; Ok((ChildStdio::Owned(fd.into_fd()), None)) diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index fc1e33137c8..327d82e60cf 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -183,14 +183,17 @@ impl Command { cvt(libc::setgid(u as gid_t))?; } if let Some(u) = self.get_uid() { - // When dropping privileges from root, the `setgroups` call - // will remove any extraneous groups. If we don't call this, - // then even though our uid has dropped, we may still have - // groups that enable us to do super-user things. This will - // fail if we aren't root, so don't bother checking the - // return value, this is just done as an optimistic - // privilege dropping function. - let _ = libc::setgroups(0, ptr::null()); + //FIXME: Redox kernel does not support setgroups yet + if cfg!(not(target_os = "redox")) { + // When dropping privileges from root, the `setgroups` call + // will remove any extraneous groups. If we don't call this, + // then even though our uid has dropped, we may still have + // groups that enable us to do super-user things. This will + // fail if we aren't root, so don't bother checking the + // return value, this is just done as an optimistic + // privilege dropping function. + let _ = libc::setgroups(0, ptr::null()); + } cvt(libc::setuid(u as uid_t))?; } |
