generator: Fix orphaned /etc/shadow and /etc/gshadow entries before sysusers#2207
Draft
cgwalters wants to merge 1 commit into
Draft
generator: Fix orphaned /etc/shadow and /etc/gshadow entries before sysusers#2207cgwalters wants to merge 1 commit into
cgwalters wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new systemd service and internal command to prune orphaned and duplicate entries from /etc/shadow and /etc/gshadow prior to systemd-sysusers execution. The implementation provides utilities for parsing shadow-style files, an RAII guard for file locking, and a systemd generator for conditional activation. Review feedback points out a potential race condition in file metadata retrieval and suggests optimizing string allocations during entry filtering.
…ysusers There's a bit of a trap in the movement from nss-altfiles to systemd-sysusers; if users/groups migrate from the former to the latter, they may leave orphaned entires in the shadow files. systemd-sysusers then tries to create those users/groups at boot it finds them already in the shadow files and fatally errors. Add a generator which enables a unit detects this situation and cleans up the shadow entries. Now in practice: we probably should have made sure that nss-altfiles users don't have shadow entries at all, but that ship has sailed. Fixes: bootc-dev#1179 Assisted-by: OpenCode (Claude Sonnet 4.6) Signed-off-by: Colin Walters <walters@verbum.org>
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.
There's a bit of a trap in the movement from nss-altfiles to systemd-sysusers; if users/groups migrate from the former to the latter, they may leave orphaned entires in the shadow files.
systemd-sysusers then tries to create those users/groups at boot it finds them already in the shadow files and fatally errors.
Add a generator which enables a unit detects this situation and cleans up the shadow entries.
Now in practice: we probably should have made sure that nss-altfiles users don't have shadow entries at all, but that ship has sailed.
Fixes: #1179
Assisted-by: OpenCode (Claude Sonnet 4.6)