diff --git a/crates/rsjudge-runner/Cargo.toml b/crates/rsjudge-runner/Cargo.toml index a99f0b5..9c4c2db 100644 --- a/crates/rsjudge-runner/Cargo.toml +++ b/crates/rsjudge-runner/Cargo.toml @@ -13,3 +13,6 @@ caps = "0.5.5" nix = { version = "0.28.0", features = ["user"] } once_cell = "1.19.0" uzers = "0.11.3" + +[features] +setgroups = [] diff --git a/crates/rsjudge-runner/src/lib.rs b/crates/rsjudge-runner/src/lib.rs index 9a50c91..8bec2aa 100644 --- a/crates/rsjudge-runner/src/lib.rs +++ b/crates/rsjudge-runner/src/lib.rs @@ -26,12 +26,17 @@ impl RunAs for Command { // and no longer accessible outside it. // // Replace with `CommandExt::groups` once it's stable. + #[cfg(not(feature = "setgroups"))] unsafe { self.pre_exec(move || { setgroups(&groups)?; Ok(()) }) }; + + #[cfg(feature = "setgroups")] + self.groups(groups); + self } }