@@ -1247,6 +1247,28 @@ fn os_seteuid(euid: u32, vm: &VirtualMachine) -> PyResult<()> {
12471247 unistd:: seteuid ( Uid :: from_raw ( euid) ) . map_err ( |err| convert_nix_error ( vm, err) )
12481248}
12491249
1250+ #[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
1251+ fn os_setreuid ( ruid : u32 , euid : u32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
1252+ unistd:: setuid ( Uid :: from_raw ( ruid) ) . map_err ( |err| convert_nix_error ( vm, err) ) ?;
1253+ unistd:: seteuid ( Uid :: from_raw ( euid) ) . map_err ( |err| convert_nix_error ( vm, err) )
1254+ }
1255+
1256+ // cfg from nix
1257+ #[ cfg( any(
1258+ target_os = "android" ,
1259+ target_os = "freebsd" ,
1260+ target_os = "linux" ,
1261+ target_os = "openbsd"
1262+ ) ) ]
1263+ fn os_setresuid ( ruid : u32 , euid : u32 , suid : u32 , vm : & VirtualMachine ) -> PyResult < ( ) > {
1264+ unistd:: setresuid (
1265+ Uid :: from_raw ( ruid) ,
1266+ Uid :: from_raw ( euid) ,
1267+ Uid :: from_raw ( suid) ,
1268+ )
1269+ . map_err ( |err| convert_nix_error ( vm, err) )
1270+ }
1271+
12501272#[ cfg( all( unix, not( target_os = "redox" ) ) ) ]
12511273pub fn os_openpty ( vm : & VirtualMachine ) -> PyResult {
12521274 match openpty ( None , None ) {
@@ -1622,12 +1644,24 @@ fn extend_module_platform_specific(vm: &VirtualMachine, module: &PyObjectRef) {
16221644 "setsid" => ctx. new_function( os_setsid) ,
16231645 "setegid" => ctx. new_function( os_setegid) ,
16241646 "seteuid" => ctx. new_function( os_seteuid) ,
1647+ "setreuid" => ctx. new_function( os_setreuid) ,
16251648 "openpty" => ctx. new_function( os_openpty) ,
16261649 "O_DSYNC" => ctx. new_int( libc:: O_DSYNC ) ,
16271650 "O_NDELAY" => ctx. new_int( libc:: O_NDELAY ) ,
16281651 "O_NOCTTY" => ctx. new_int( libc:: O_NOCTTY ) ,
16291652 } ) ;
16301653
1654+ // cfg taken from nix
1655+ #[ cfg( any(
1656+ target_os = "android" ,
1657+ target_os = "freebsd" ,
1658+ target_os = "linux" ,
1659+ target_os = "openbsd"
1660+ ) ) ]
1661+ extend_module ! ( vm, module, {
1662+ "setresuid" => ctx. new_function( os_setresuid) ,
1663+ } ) ;
1664+
16311665 // cfg taken from nix
16321666 #[ cfg( any(
16331667 target_os = "dragonfly" ,
0 commit comments