Skip to content

add_getresgid_support #1921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions vm/src/stdlib/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,25 @@ fn os_getresuid(vm: &VirtualMachine) -> PyResult<(u32, u32, u32)> {
}
}

// cfg from nix
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"
))]
fn os_getresgid(vm: &VirtualMachine) -> PyResult<(u32, u32, u32)> {
let mut rgid = 0;
let mut egid = 0;
let mut sgid = 0;
let ret = unsafe { libc::getresgid(&mut rgid, &mut egid, &mut sgid) };
if ret == 0 {
Ok((rgid, egid, sgid))
} else {
Err(errno_err(vm))
}
}

pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
let ctx = &vm.ctx;

Expand Down Expand Up @@ -1708,6 +1727,7 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: &PyObjectRef) {
extend_module!(vm, module, {
"setresuid" => ctx.new_function(os_setresuid),
"getresuid" => ctx.new_function(os_getresuid),
"getresgid" => ctx.new_function(os_getresgid),
});

// cfg taken from nix
Expand Down