Fix bug about nonexistent groups in groups column

This commit is contained in:
Ben S 2014-06-27 12:46:08 +01:00
parent b337f9174d
commit 68cd6d5da1

View File

@ -73,8 +73,11 @@ impl Unix {
}
}
pub fn is_group_member(&self, gid: u32) -> bool {
*self.groups.get(&gid)
pub fn is_group_member(&mut self, gid: u32) -> bool {
// Groups that no longer exist have no members. If this method
// is called before a group with the given gid has been read,
// it doesn't exist, so insert false.
*self.groups.find_or_insert(gid, false)
}
pub fn get_user_name(&mut self, uid: u32) -> Option<String> {