diff options
| author | Sebastian Humenda <shumenda@gmx.de> | 2017-08-17 13:23:00 +0200 |
|---|---|---|
| committer | Tobias Schaffner <tschaff@genua.de> | 2017-09-08 14:36:56 +0200 |
| commit | 2cf0a4ad4690c587d755dc6e5383779dddb9b178 (patch) | |
| tree | 4bcbae74c880377bbf96b952041ae9f3b70ed8d5 /src/libstd/sys/unix/process | |
| parent | d6ad402a644d9e57f1a6d6c579fe04acf00e0e2e (diff) | |
| download | rust-2cf0a4ad4690c587d755dc6e5383779dddb9b178.tar.gz rust-2cf0a4ad4690c587d755dc6e5383779dddb9b178.zip | |
Match c_char definitions and enable signal reset for L4Re
* Match definition of c_char in os/raw.rs with the libc definition
Due to historic reasons, os/raw.rs redefines types for c_char from
libc, but these didn't match. Now they do :).
* Enable signal reset on exec for L4Re
L4Re has full signal emulation and hence it needs to reset the
signal set of the child with sigemptyset. However, gid and uid
should *not* be set.
Diffstat (limited to 'src/libstd/sys/unix/process')
| -rw-r--r-- | src/libstd/sys/unix/process/process_unix.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index ae24021fb6c..870db820027 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -160,20 +160,22 @@ impl Command { t!(cvt_r(|| libc::dup2(fd, libc::STDERR_FILENO))); } - if let Some(u) = self.get_gid() { - t!(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()); + if cfg!(not(any(target_os = "l4re"))) { + if let Some(u) = self.get_gid() { + t!(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()); - t!(cvt(libc::setuid(u as uid_t))); + t!(cvt(libc::setuid(u as uid_t))); + } } if let Some(ref cwd) = *self.get_cwd() { t!(cvt(libc::chdir(cwd.as_ptr()))); |
