Repository navigation
Daemon: initialize supplementary groups when changing user - #70
Merged
MaxKellermann merged 1 commit intoNov 3, 2026
Merged
Conversation
The daemon_user path changed the primary group and user, but the initgroups() call was hidden behind the obsolete _BSD_SOURCE feature macro. Normal builds therefore retained supplementary groups inherited from the launcher. Initialize the configured user's supplementary groups before dropping the primary group and user, and abort if initialization fails.
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.
The
daemon_userpath changes the primary GID and UID, but itsinitgroups()call is guarded by the obsolete_BSD_SOURCEmacro. Normal builds skip it, which can leave supplementary groups inherited from the launcher active after the user change.Include
<grp.h>and initialize the configured user's supplementary groups before callingsetgid()andsetuid(). Treat aninitgroups()failure as fatal so the credential change fails closed.The systemd service already starts with
User=mpdscribble, so it is not affected. This fixes direct or non-systemd root launches that usedaemon_useror--daemon-user.