Repository navigation
shadow-core: allocate system IDs from the top of the range #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,13 +340,13 @@ fn apply( | |
| // An empty field on an existing account keeps the ID it has; | ||
| // reallocating would orphan every file the account owns. | ||
| ("", Some(i)) => passwd.entries()[i].uid, | ||
| ("", None) => uid_alloc::next_uid(passwd.entries(), uid_min, uid_max, scope) | ||
| ("", None) => uid_alloc::next_uid(passwd.entries(), uid_min, uid_max, system, scope) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add a test for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
| .map_err(|e| line_error(line, &e.to_string()))?, | ||
| (given, _) => parse_id(given) | ||
| .ok_or_else(|| line_error(line, &format!("invalid user ID '{given}'")))?, | ||
| }; | ||
|
|
||
| let gid = resolve_gid(&mut group, line, uid, gid_min, gid_max, scope)?; | ||
| let gid = resolve_gid(&mut group, line, uid, gid_min, gid_max, system, scope)?; | ||
|
|
||
| match existing { | ||
| Some(i) => { | ||
|
|
@@ -422,6 +422,7 @@ fn resolve_gid( | |
| uid: u32, | ||
| gid_min: u32, | ||
| gid_max: u32, | ||
| system: bool, | ||
| scope: Scope, | ||
| ) -> Result<u32, NewusersError> { | ||
| // A number names a group directly. If no group has it, one is created | ||
|
|
@@ -459,7 +460,7 @@ fn resolve_gid( | |
| // is the convention every distribution follows; falling back to the | ||
| // allocator when it is taken keeps that a preference, not a requirement. | ||
| let gid = if group.entries().iter().any(|g| g.gid == uid) { | ||
| uid_alloc::next_gid(group.entries(), gid_min, gid_max, scope) | ||
| uid_alloc::next_gid(group.entries(), gid_min, gid_max, system, scope) | ||
| .map_err(|e| line_error(line, &e.to_string()))? | ||
| } else { | ||
| uid | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add the same case with
system = true? (directory holds 999 and 998, expect 997)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in db9a42b: with 999 and 998 held by the directory, a system allocation in 101..999 gives 997.