Skip to content

id: Don't treat unresolved IDs as error by default#12252

Open
mhutter wants to merge 2 commits into
uutils:mainfrom
mhutter:fix/id-unknown-id-errors
Open

id: Don't treat unresolved IDs as error by default#12252
mhutter wants to merge 2 commits into
uutils:mainfrom
mhutter:fix/id-unknown-id-errors

Conversation

@mhutter
Copy link
Copy Markdown

@mhutter mhutter commented May 12, 2026

This brings the behavior of id in line with GNU coreutils, which only treats unresolved IDs as errors when providing any of the -u, -g or -G flags in combination with -n.

Fixes: #12246

@sylvestre
Copy link
Copy Markdown
Contributor

could you please add a test to make sure we don't regress? thanks

@mhutter
Copy link
Copy Markdown
Author

mhutter commented May 12, 2026

could you please add a test to make sure we don't regress? thanks

Any idea how I can test the behavior in the context of a non-existing UID/GID? Are there existing tests that test similar scenarios?

edit: I think I have a solution, will update the PR

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

Comment thread tests/by-util/test_id.rs Outdated
.code_is(exp_result.code());
}

// requiring root permissions.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this in the follow-up PR to address GID deduplication.

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 12, 2026

You cannot use unshare on the CI. See #12120 (comment) .

@mhutter
Copy link
Copy Markdown
Author

mhutter commented May 12, 2026

Then the test should just short-circuit in CI. That way at least we have a way to test the desired behavior locally.

@mhutter
Copy link
Copy Markdown
Author

mhutter commented May 13, 2026

@sylvestre WDYT?

One of the CI Checks failed for unrelated reasons (timeout)

@oech3
Copy link
Copy Markdown
Contributor

oech3 commented May 13, 2026

Would you add

# some test needs unshare
sudo sysctl -w kernel.unprivileged_userns_clone=1 ||:
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 ||:

to one of the *.yml to catch regression?

@mhutter mhutter force-pushed the fix/id-unknown-id-errors branch from 54ecbc0 to 3d429e9 Compare May 13, 2026 13:32
@mhutter
Copy link
Copy Markdown
Author

mhutter commented May 13, 2026

@oech3 thanks, didn't realize this was an option on GitHub CI.

  • I used || true instead of || : to be consistent with existing code; hope that's okay
  • I have added the commands to one of the tests that only runs on Ubuntu; in the Windows builds the commands fail even with || true

mhutter added 2 commits May 13, 2026 15:43
This brings the behavior of `id` in line with GNU coreutils, which only treats unresolved IDs as
errors when providing any of the `-u`, `-g` or `-G` flags in combination with `-n`.

Fixes: uutils#12246
Signed-off-by: Manuel Hutter <manuel@hutter.io>
Signed-off-by: Manuel Hutter <manuel@hutter.io>
@mhutter mhutter force-pushed the fix/id-unknown-id-errors branch from 3d429e9 to 6416599 Compare May 13, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

id returns wrong exit code when user does not exist

3 participants