From 5713de4d937ac7e03cbf32e926fb4044bd782d67 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Mon, 9 May 2022 20:50:20 -0400 Subject: [PATCH] fixup! uucore(perms): better support nameless uids, gids --- src/uucore/src/lib/features/perms.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/uucore/src/lib/features/perms.rs b/src/uucore/src/lib/features/perms.rs index ed9e1c001..edb714646 100644 --- a/src/uucore/src/lib/features/perms.rs +++ b/src/uucore/src/lib/features/perms.rs @@ -97,8 +97,8 @@ pub fn wrap_chown>( "{}\nfailed to change group of {} from {} to {}", out, path.quote(), - entries::gid2grp(gid).unwrap_or(gid.to_string()), - entries::gid2grp(dest_gid).unwrap_or(dest_gid.to_string()) + entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()), + entries::gid2grp(dest_gid).unwrap_or_else(|_| dest_gid.to_string()) ) } else { let uid = meta.uid(); @@ -107,10 +107,10 @@ pub fn wrap_chown>( "{}\nfailed to change ownership of {} from {}:{} to {}:{}", out, path.quote(), - entries::uid2usr(uid).unwrap_or(uid.to_string()), - entries::gid2grp(gid).unwrap_or(gid.to_string()), - entries::uid2usr(dest_uid).unwrap_or(dest_uid.to_string()), - entries::gid2grp(dest_gid).unwrap_or(dest_gid.to_string()) + entries::uid2usr(uid).unwrap_or_else(|_| uid.to_string()), + entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()), + entries::uid2usr(dest_uid).unwrap_or_else(|_| dest_uid.to_string()), + entries::gid2grp(dest_gid).unwrap_or_else(|_| dest_gid.to_string()) ) }; }; @@ -127,8 +127,8 @@ pub fn wrap_chown>( format!( "changed group of {} from {} to {}", path.quote(), - entries::gid2grp(gid).unwrap_or(gid.to_string()), - entries::gid2grp(dest_gid).unwrap_or(dest_gid.to_string()) + entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()), + entries::gid2grp(dest_gid).unwrap_or_else(|_| dest_gid.to_string()) ) } else { let gid = meta.gid(); @@ -136,10 +136,10 @@ pub fn wrap_chown>( format!( "changed ownership of {} from {}:{} to {}:{}", path.quote(), - entries::uid2usr(uid).unwrap_or(uid.to_string()), - entries::gid2grp(gid).unwrap_or(gid.to_string()), - entries::uid2usr(dest_uid).unwrap_or(dest_uid.to_string()), - entries::gid2grp(dest_gid).unwrap_or(dest_gid.to_string()) + entries::uid2usr(uid).unwrap_or_else(|_| uid.to_string()), + entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string()), + entries::uid2usr(dest_uid).unwrap_or_else(|_| dest_uid.to_string()), + entries::gid2grp(dest_gid).unwrap_or_else(|_| dest_gid.to_string()) ) }; } @@ -156,8 +156,8 @@ pub fn wrap_chown>( format!( "ownership of {} retained as {}:{}", path.quote(), - entries::uid2usr(dest_uid).unwrap_or(dest_uid.to_string()), - entries::gid2grp(dest_gid).unwrap_or(dest_gid.to_string()) + entries::uid2usr(dest_uid).unwrap_or_else(|_| dest_uid.to_string()), + entries::gid2grp(dest_gid).unwrap_or_else(|_| dest_gid.to_string()) ) }; }