diff options
author | Max Kellermann <max@duempel.org> | 2013-12-29 13:58:39 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-29 13:59:05 +0100 |
commit | e30b356eb018adcfb3efbce97c81bc0d99934826 (patch) | |
tree | cd3d054e225b244a270ab4c56d6cdc3f28485a14 | |
parent | 09a0803116e642be4e983d1d09295afc788f37ca (diff) | |
download | mpd-e30b356eb018adcfb3efbce97c81bc0d99934826.tar.gz mpd-e30b356eb018adcfb3efbce97c81bc0d99934826.tar.xz mpd-e30b356eb018adcfb3efbce97c81bc0d99934826.zip |
daemon: no initgroups() when already running as the configured user
We can assume that initgroups() would be a no-op in that case, however
initgroups() is not allowed for unprivileged users anyway.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/Daemon.cxx | 6 |
2 files changed, 7 insertions, 1 deletions
@@ -1,4 +1,6 @@ ver 0.18.7 (not yet released) +* daemon: don't initialize supplementary groups when already running + as the configured user ver 0.18.6 (2013/12/24) * input diff --git a/src/Daemon.cxx b/src/Daemon.cxx index d40c49d5d..557c47777 100644 --- a/src/Daemon.cxx +++ b/src/Daemon.cxx @@ -116,7 +116,11 @@ daemonize_set_user(void) /* init supplementary groups * (must be done before we change our uid) */ - if (!had_group && initgroups(user_name, user_gid) == -1) { + if (!had_group && + /* no need to set the new user's supplementary groups if + we are already this user */ + user_uid != getuid() && + initgroups(user_name, user_gid) == -1) { FormatFatalSystemError("Failed to set supplementary groups " "of user \"%s\"", user_name); |