(gid: PyIntRef, vm: &VirtualMachine)
| 47 | |
| 48 | #[pyfunction] |
| 49 | fn getgrgid(gid: PyIntRef, vm: &VirtualMachine) -> PyResult<GroupData> { |
| 50 | let gr_gid = gid.as_bigint(); |
| 51 | let gid = libc::gid_t::try_from(gr_gid) |
| 52 | .map(unistd::Gid::from_raw) |
| 53 | .ok(); |
| 54 | let group = gid |
| 55 | .map(unistd::Group::from_gid) |
| 56 | .transpose() |
| 57 | .map_err(|err| err.into_pyexception(vm))? |
| 58 | .flatten(); |
| 59 | let group = group.ok_or_else(|| { |
| 60 | vm.new_key_error( |
| 61 | vm.ctx |
| 62 | .new_str(format!("getgrgid: group id {gr_gid} not found")) |
| 63 | .into(), |
| 64 | ) |
| 65 | })?; |
| 66 | Ok(GroupData::from_unistd_group(group, vm)) |
| 67 | } |
| 68 | |
| 69 | #[pyfunction] |
| 70 | fn getgrnam(name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<GroupData> { |
nothing calls this directly
no test coverage detected