Skip to content

Commit ae3c51f

Browse files
authored
Merge pull request #9670 from sylvestre/id-unwrap
id -p crashes with panic when the real GID doesn't exist in /etc/group
2 parents 06d843f + 5c72d87 commit ae3c51f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/uu/id/src/id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ fn pretty(possible_pw: Option<Passwd>) {
468468
"{}",
469469
p.belongs_to()
470470
.iter()
471-
.map(|&gr| entries::gid2grp(gr).unwrap())
471+
.map(|&gr| entries::gid2grp(gr).unwrap_or_else(|_| gr.to_string()))
472472
.collect::<Vec<_>>()
473473
.join(" ")
474474
);
@@ -508,7 +508,7 @@ fn pretty(possible_pw: Option<Passwd>) {
508508
entries::get_groups_gnu(None)
509509
.unwrap()
510510
.iter()
511-
.map(|&gr| entries::gid2grp(gr).unwrap())
511+
.map(|&gr| entries::gid2grp(gr).unwrap_or_else(|_| gr.to_string()))
512512
.collect::<Vec<_>>()
513513
.join(" ")
514514
);

0 commit comments

Comments
 (0)