(vm: &VirtualMachine)
| 85 | |
| 86 | #[pyfunction] |
| 87 | fn getgrall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> { |
| 88 | // setgrent, getgrent, etc are not thread safe. Could use fgetgrent_r, but this is easier |
| 89 | static GETGRALL: parking_lot::Mutex<()> = parking_lot::Mutex::new(()); |
| 90 | let _guard = GETGRALL.lock(); |
| 91 | let mut list = Vec::new(); |
| 92 | |
| 93 | unsafe { libc::setgrent() }; |
| 94 | while let Some(ptr) = NonNull::new(unsafe { libc::getgrent() }) { |
| 95 | let group = unistd::Group::from(unsafe { ptr.as_ref() }); |
| 96 | let group = GroupData::from_unistd_group(group, vm).to_pyobject(vm); |
| 97 | list.push(group); |
| 98 | } |
| 99 | unsafe { libc::endgrent() }; |
| 100 | |
| 101 | Ok(list) |
| 102 | } |
| 103 | } |
nothing calls this directly
no test coverage detected