Skip to content

Commit

Permalink
feat(rsjudge-runner): 🚩 add setgroups flag, allow using groups method…
Browse files Browse the repository at this point in the history
… from std
  • Loading branch information
Jisu-Woniu committed Mar 24, 2024
1 parent ac60529 commit 2d6fb32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/rsjudge-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
5 changes: 5 additions & 0 deletions crates/rsjudge-runner/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 2d6fb32

Please sign in to comment.