[BB#115] Drop supplementary groups

Supplementary groups are inherited from the calling process. Drop all
supplementary groups if the "Group" configuration directive is set to
change to a different user. Otherwise the process may have more rights
than expected.

Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Gaudenz Steinlin authored and Michael Adam committed 2013-11-01 06:38:53 +01:00
1 parent 3cc59ec3be
commit c8b8247f70
2 files changed
+11 -1

No files matched your search

+10
View File
@@ -296,6 +296,16 @@ change_user (const char *program)
exit (EX_NOPERM);
}
#ifdef HAVE_SETGROUPS
/* Drop all supplementary groups, otherwise these are inherited from the calling process */
if (setgroups (0, NULL) < 0) {
fprintf (stderr,
"%s: Unable to drop supplementary groups.\n",
program);
exit (EX_NOPERM);
}
#endif
log_message (LOG_INFO, "Now running as group \"%s\".",
config.group);
}