Commit e30b356e authored by Max Kellermann's avatar Max Kellermann

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.
parent 09a08031
ver 0.18.7 (not yet released) 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) ver 0.18.6 (2013/12/24)
* input * input
......
...@@ -116,7 +116,11 @@ daemonize_set_user(void) ...@@ -116,7 +116,11 @@ daemonize_set_user(void)
/* init supplementary groups /* init supplementary groups
* (must be done before we change our uid) * (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 " FormatFatalSystemError("Failed to set supplementary groups "
"of user \"%s\"", "of user \"%s\"",
user_name); user_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment