about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-22 19:00:11 +0000
committerbors <bors@rust-lang.org>2021-01-22 19:00:11 +0000
commit22ddcd1a13082b7be0fc99b720677efd2b733816 (patch)
tree2f1353a2d02e579821b1e90e37a0cce9efe4c5cd /src
parentb814b639836aa76b5c6deaa585367150bb2debf4 (diff)
parenta4db851302166616bb5fcbc89f240537a8164d49 (diff)
downloadrust-22ddcd1a13082b7be0fc99b720677efd2b733816.tar.gz
rust-22ddcd1a13082b7be0fc99b720677efd2b733816.zip
Auto merge of #72160 - slo1:libstd-setgroups, r=KodrAus
Add setgroups to std::os::unix::process::CommandExt

Should fix #38527. I'm not sure groups is the greatest name though.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/command/command-setgroups.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/ui/command/command-setgroups.rs b/src/test/ui/command/command-setgroups.rs
new file mode 100644
index 00000000000..28f2bfdd3a7
--- /dev/null
+++ b/src/test/ui/command/command-setgroups.rs
@@ -0,0 +1,26 @@
+// run-pass
+// ignore-windows - this is a unix-specific test
+// ignore-cloudabi
+// ignore-emscripten
+// ignore-sgx
+
+#![feature(rustc_private)]
+#![feature(setgroups)]
+
+extern crate libc;
+use std::process::Command;
+use std::os::unix::process::CommandExt;
+
+fn main() {
+    #[cfg(unix)]
+    run()
+}
+
+#[cfg(unix)]
+fn run() {
+    let max_ngroups = unsafe { libc::sysconf(libc::_SC_NGROUPS_MAX) };
+    let max_ngroups = max_ngroups as u32 + 1;
+    let vec: Vec<u32> = (0..max_ngroups).collect();
+    let p = Command::new("/bin/id").groups(&vec[..]).spawn();
+    assert!(p.is_err());
+}