Merge pull request #9670 from sylvestre/id-unwrap

id -p crashes with panic when the real GID doesn't exist in /etc/group
This commit is contained in:
Daniel Hofstetter 2025-12-16 09:48:27 +01:00 committed by GitHub
commit ae3c51ff60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -468,7 +468,7 @@ fn pretty(possible_pw: Option<Passwd>) {
"{}",
p.belongs_to()
.iter()
.map(|&gr| entries::gid2grp(gr).unwrap())
.map(|&gr| entries::gid2grp(gr).unwrap_or_else(|_| gr.to_string()))
.collect::<Vec<_>>()
.join(" ")
);
@ -508,7 +508,7 @@ fn pretty(possible_pw: Option<Passwd>) {
entries::get_groups_gnu(None)
.unwrap()
.iter()
.map(|&gr| entries::gid2grp(gr).unwrap())
.map(|&gr| entries::gid2grp(gr).unwrap_or_else(|_| gr.to_string()))
.collect::<Vec<_>>()
.join(" ")
);