From 5c72d87e942a86626fdc5b769b359d970568bf0c Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 16 Dec 2025 08:05:22 +0100 Subject: [PATCH] id -p crashes with panic when the real GID doesn't exist in /etc/group hard to reproduce in an automated test but here are the steps: * edit /etc/passwd * change one group id by another (non existing) * run "id -p " --- src/uu/id/src/id.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index dcdc69243..298619fd5 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -468,7 +468,7 @@ fn pretty(possible_pw: Option) { "{}", p.belongs_to() .iter() - .map(|&gr| entries::gid2grp(gr).unwrap()) + .map(|&gr| entries::gid2grp(gr).unwrap_or_else(|_| gr.to_string())) .collect::>() .join(" ") ); @@ -508,7 +508,7 @@ fn pretty(possible_pw: Option) { 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::>() .join(" ") );