Repository navigation
shadow-core: allocate system IDs from the top of the range - #344
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
useradd -r, groupadd -r and newusers -r took the lowest free ID in SYS_UID_MIN..SYS_UID_MAX (101, 102, ...). shadow-utils counts down from SYS_UID_MAX instead (999, 998, ...), going one below the lowest system ID in use so a deleted account's ID is not handed out again, and only then filling the highest gap.
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
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 #342
next_uidandnext_gidtake asystemflag. For system accounts the next ID is one below the lowest system ID in use, starting atSYS_UID_MAX/SYS_GID_MAX, and once that reaches the bottom of the range, the highest free ID. Regular accounts keep the current rule.useradd -r,groupadd -randnewusers -rpass their flag through.test_uid_allocation_systemexpected 101 (the lowest ID); it now expects 999, which is what GNU gives on an empty range.Tests: unit tests for the countdown and the gap fallback, and root tests creating two system users and two system groups (999, then 998). All fail before, pass after.
cargo test --workspacerun as root in an Ubuntu 26.04 container: 947 passed (943 on main, plus the four new).cargo fmt --checkandcargo clippy --workspace --all-targets -- -D warningsare clean; thepamconfigurations were not run locally. Against GNU shadow 4.17.4 in the same container, 12 command sequences (useradd -r,groupadd -r,-u 500, an existing 998, a deleted system user,-U,-N, and regular users) now give the same files and exit codes.AI tools assisted with this contribution.