(uid: PyIntRef, vm: &VirtualMachine)
| 77 | |
| 78 | #[pyfunction] |
| 79 | fn getpwuid(uid: PyIntRef, vm: &VirtualMachine) -> PyResult<PasswdData> { |
| 80 | let uid_t = libc::uid_t::try_from(uid.as_bigint()) |
| 81 | .map(unistd::Uid::from_raw) |
| 82 | .ok(); |
| 83 | let user = uid_t |
| 84 | .map(User::from_uid) |
| 85 | .transpose() |
| 86 | .map_err(|err| err.into_pyexception(vm))? |
| 87 | .flatten(); |
| 88 | let user = user.ok_or_else(|| { |
| 89 | vm.new_key_error( |
| 90 | vm.ctx |
| 91 | .new_str(format!("getpwuid(): uid not found: {}", uid.as_bigint())) |
| 92 | .into(), |
| 93 | ) |
| 94 | })?; |
| 95 | Ok(PasswdData::from(user)) |
| 96 | } |
| 97 | |
| 98 | // TODO: maybe merge this functionality into nix? |
| 99 | #[cfg(not(target_os = "android"))] |
nothing calls this directly
no test coverage detected