Skip to content

Daemon: initialize supplementary groups when changing user - #70

Merged
MaxKellermann merged 1 commit into
MusicPlayerDaemon:masterfrom
acts-1631:fix-supplementary-groups
Nov 3, 2026
Merged

MaxKellermann merged 1 commit into
MusicPlayerDaemon:masterfrom
acts-1631:fix-supplementary-groups

Conversation

@acts-1631

Copy link
Copy Markdown
Contributor

The daemon_user path changes the primary GID and UID, but its initgroups() call is guarded by the obsolete _BSD_SOURCE macro. 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 calling setgid() and setuid(). Treat an initgroups() 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 use daemon_user or --daemon-user.

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.
@MaxKellermann
MaxKellermann merged commit 259931d into MusicPlayerDaemon:master Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants