mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
Merge pull request #1961 from mrmiywj/support_setresgid_in_os_module
Support setresgid in os module
This commit is contained in:
1 file changed
+19
-2
+19
-2
@@ -1524,10 +1524,26 @@ fn os_getresgid(vm: &VirtualMachine) -> PyResult<(u32, u32, u32)> {
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn os_setregid(rgid: u32, egid: u32, vm: &VirtualMachine) -> PyResult<i32> {
|
||||
fn os_setresgid(rgid: u32, egid: u32, sgid: u32, vm: &VirtualMachine) -> PyResult<()> {
|
||||
unistd::setresgid(
|
||||
Gid::from_raw(rgid),
|
||||
Gid::from_raw(egid),
|
||||
Gid::from_raw(sgid),
|
||||
)
|
||||
.map_err(|err| convert_nix_error(vm, err))
|
||||
}
|
||||
|
||||
// cfg from nix
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "linux",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn os_setregid(rgid: u32, egid: u32, vm: &VirtualMachine) -> PyResult<()> {
|
||||
let ret = unsafe { libc::setregid(rgid, egid) };
|
||||
if ret == 0 {
|
||||
Ok(0)
|
||||
Ok(())
|
||||
} else {
|
||||
Err(errno_err(vm))
|
||||
}
|
||||
@@ -1798,6 +1814,7 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: &PyObjectRef) {
|
||||
"setresuid" => ctx.new_function(os_setresuid),
|
||||
"getresuid" => ctx.new_function(os_getresuid),
|
||||
"getresgid" => ctx.new_function(os_getresgid),
|
||||
"setresgid" => ctx.new_function(os_setresgid),
|
||||
"setregid" => ctx.new_function(os_setregid),
|
||||
"initgroups" => ctx.new_function(os_initgroups),
|
||||
"setgroups" => ctx.new_function(os_setgroups),
|
||||
|
||||
Reference in new issue
Block a user