-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Hi, I'm kinda new at rust, but I think I have found a bug in this crate
Basically the function group_access_list should return the list the current available groups for the process
...except it seems to always add the root group
The bug might be here:
let mut buff: Vec<gid_t> = vec![0; 1024];
[...]
let res = unsafe {
libc::getgroups(1024, buff.as_mut_ptr())
};
[...]
if res < 0 {...
else {
let mut groups = buff.into_iter()
The vector has 1024 elements inside, default 0. Then the libc::getgroups will get, say res = 42 groups
but buff.into_iter() goes through all 1024 elements.
The final groups.dedup_by_key(|i| i.gid()); removes multiple occurrences of the root group.
However, even that is probably kinda wrong since the docs say:
Removes all but the first of consecutive elements in the vector that resolve to the same key
...meaning that the list root,users,root will not get deduped, correct?
I have not checked for similar bugs elsewhere in the codebase