Skip to content

Commit 069a43a

Browse files
humendaTobias Schaffner
authored and
Tobias Schaffner
committed
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 8016eea commit 069a43a

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

src/libstd/os/raw.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use fmt;
2222
target_arch = "s390x")),
2323
all(target_os = "android", any(target_arch = "aarch64",
2424
target_arch = "arm")),
25+
all(target_os = "l4re", target_arch = "x86_64"),
2526
all(target_os = "fuchsia", target_arch = "aarch64")))]
2627
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8;
2728
#[cfg(not(any(target_os = "emscripten",
@@ -32,6 +33,7 @@ use fmt;
3233
target_arch = "s390x")),
3334
all(target_os = "android", any(target_arch = "aarch64",
3435
target_arch = "arm")),
36+
all(target_os = "l4re", target_arch = "x86_64"),
3537
all(target_os = "fuchsia", target_arch = "aarch64"))))]
3638
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8;
3739
#[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8;

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,22 @@ impl Command {
161161
t!(cvt_r(|| libc::dup2(fd, libc::STDERR_FILENO)));
162162
}
163163

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

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

0 commit comments

Comments
 (0)