Repository navigation
find: -ls: don't panic on an unmapped owner uid/gid - #721
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #721 +/- ##
==========================================
+ Coverage 91.83% 91.86% +0.02%
==========================================
Files 35 35
Lines 7129 7153 +24
Branches 375 375
==========================================
+ Hits 6547 6571 +24
Misses 437 437
Partials 145 145 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
sylvestre
reviewed
Jun 9, 2026
|
|
||
| use super::{Matcher, MatcherIO, WalkEntry}; | ||
|
|
||
| /// Resolve a uid to its login name, falling back to the numeric id when the uid |
Contributor
There was a problem hiding this comment.
uucore already has these: entries::uid2usr / gid2grp (feature entries), which also serialize the non-thread-safe getpwuid/getgrgid behind a mutex. please reuse instead of reimplementing.
Contributor
Author
There was a problem hiding this comment.
Done — switched to uucore::entries::uid2usr / gid2grp with the numeric fallback and dropped the hand-rolled helpers. Thanks for the pointer!
leeewee
force-pushed
the
find-fix-ls-unmapped-uid
branch
from
June 10, 2026 02:26
0d72b62 to
a20c696
Compare
`find <file> -ls` panicked (exit 101) when the file's owning uid (or gid) had no `/etc/passwd` (`/etc/group`) entry: it resolved the name with `User::from_uid(...).unwrap().unwrap()`, and the inner unwrap aborts on the `Ok(None)` that an unmapped id returns. Unmapped owners are routine (extracted archives, NFS, deleted accounts, container images). Resolve the uid/gid via `uucore::entries::uid2usr`/`gid2grp`, falling back to the numeric id when there is no entry, matching GNU find (which prints the number). These helpers already serialize the non-thread-safe getpwuid/getgrgid behind a mutex, so reuse them rather than reimplementing the lookup. Add a -ls integration test that chowns a file to an unmapped id and checks the numeric fallback; it skips when the process lacks the privilege to do so.
leeewee
force-pushed
the
find-fix-ls-unmapped-uid
branch
from
June 10, 2026 02:32
a20c696 to
0731a94
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #717
find <file> -lspanicked (exit 101) when the file's owning uid (or gid) had no/etc/passwd(/etc/group) entry: it resolved the name withUser::from_uid(...).unwrap().unwrap(), and the inner unwrap aborts on theOk(None)that an unmapped id returns. Unmapped owners are routine (extracted archives, NFS, deleted accounts, container images).Resolve the uid/gid via
uucore::entries::uid2usr/gid2grp, falling back to the numeric id when there is no entry, matching GNU find (which prints the number). Per review, this reuses the existing uucore helpers (which serialize the non-thread-safegetpwuid/getgrgidbehind a mutex) rather than reimplementing the lookup.Adds a
-lsintegration test that chowns a file to an unmapped id and checks the numeric fallback; it skips when the process lacks the privilege to do so.