Skip to content

generator: Fix orphaned /etc/shadow and /etc/gshadow entries before sysusers#2207

Draft
cgwalters wants to merge 1 commit into
bootc-dev:mainfrom
cgwalters:gshadow
Draft

generator: Fix orphaned /etc/shadow and /etc/gshadow entries before sysusers#2207
cgwalters wants to merge 1 commit into
bootc-dev:mainfrom
cgwalters:gshadow

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

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)

@github-actions github-actions Bot added the area/documentation Updates to the documentation label May 21, 2026
@bootc-bot bootc-bot Bot requested a review from jeckersb May 21, 2026 14:42
@cgwalters cgwalters marked this pull request as draft May 21, 2026 14:43
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread crates/lib/src/deploy.rs Outdated
Comment thread crates/lib/src/deploy.rs Outdated
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Updates to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint: Verify /etc/{,g}shadow

1 participant