Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2cf0a4a

Browse files
humendaTobias Schaffner
authored and
Tobias Schaffner
committedSep 8, 2017
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.
1 parent d6ad402 commit 2cf0a4a

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed
 

‎src/libstd/os/raw.rs

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use fmt;
2121
target_arch = "s390x")),
2222
all(target_os = "android", any(target_arch = "aarch64",
2323
target_arch = "arm")),
24+
all(target_os = "l4re", target_arch = "x86_64"),
2425
all(target_os = "fuchsia", target_arch = "aarch64")))]
2526
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
2627
#[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64",
@@ -30,6 +31,7 @@ use fmt;
3031
target_arch = "s390x")),
3132
all(target_os = "android", any(target_arch = "aarch64",
3233
target_arch = "arm")),
34+
all(target_os = "l4re", target_arch = "x86_64"),
3335
all(target_os = "fuchsia", target_arch = "aarch64"))))]
3436
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
3537
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;

‎src/libstd/sys/unix/ext/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub mod fs;
3636
pub mod process;
3737
pub mod raw;
3838
pub mod thread;
39+
#[cfg(not(target_os = "l4re"))]
3940
pub mod net;
4041

4142
/// A prelude for conveniently writing platform-specific code.

‎src/libstd/sys/unix/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub mod fd;
4444
pub mod fs;
4545
pub mod memchr;
4646
pub mod mutex;
47+
#[cfg(not(target_os = "l4re"))]
4748
pub mod net;
4849
pub mod os;
4950
pub mod os_str;

‎src/libstd/sys/unix/process/process_unix.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -160,20 +160,22 @@ impl Command {
160160
t!(cvt_r(|| libc::dup2(fd, libc::STDERR_FILENO)));
161161
}
162162

163-
if let Some(u) = self.get_gid() {
164-
t!(cvt(libc::setgid(u as gid_t)));
165-
}
166-
if let Some(u) = self.get_uid() {
167-
// When dropping privileges from root, the `setgroups` call
168-
// will remove any extraneous groups. If we don't call this,
169-
// then even though our uid has dropped, we may still have
170-
// groups that enable us to do super-user things. This will
171-
// fail if we aren't root, so don't bother checking the
172-
// return value, this is just done as an optimistic
173-
// privilege dropping function.
174-
let _ = libc::setgroups(0, ptr::null());
163+
if cfg!(not(any(target_os = "l4re"))) {
164+
if let Some(u) = self.get_gid() {
165+
t!(cvt(libc::setgid(u as gid_t)));
166+
}
167+
if let Some(u) = self.get_uid() {
168+
// When dropping privileges from root, the `setgroups` call
169+
// will remove any extraneous groups. If we don't call this,
170+
// then even though our uid has dropped, we may still have
171+
// groups that enable us to do super-user things. This will
172+
// fail if we aren't root, so don't bother checking the
173+
// return value, this is just done as an optimistic
174+
// privilege dropping function.
175+
let _ = libc::setgroups(0, ptr::null());
175176

176-
t!(cvt(libc::setuid(u as uid_t)));
177+
t!(cvt(libc::setuid(u as uid_t)));
178+
}
177179
}
178180
if let Some(ref cwd) = *self.get_cwd() {
179181
t!(cvt(libc::chdir(cwd.as_ptr())));

0 commit comments

Comments
 (0)
Failed to load comments.