(name: PyUtf8StrRef, vm: &VirtualMachine)
| 68 | |
| 69 | #[pyfunction] |
| 70 | fn getgrnam(name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<GroupData> { |
| 71 | let gr_name = name.as_str(); |
| 72 | if gr_name.contains('\0') { |
| 73 | return Err(exceptions::cstring_error(vm)); |
| 74 | } |
| 75 | let group = unistd::Group::from_name(gr_name).map_err(|err| err.into_pyexception(vm))?; |
| 76 | let group = group.ok_or_else(|| { |
| 77 | vm.new_key_error( |
| 78 | vm.ctx |
| 79 | .new_str(format!("getgrnam: group name {gr_name} not found")) |
| 80 | .into(), |
| 81 | ) |
| 82 | })?; |
| 83 | Ok(GroupData::from_unistd_group(group, vm)) |
| 84 | } |
| 85 | |
| 86 | #[pyfunction] |
| 87 | fn getgrall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> { |
no test coverage detected