2005-02-03 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
* milter-greylist.c: change gid and supplementary groups also
--- milter-greylist-1.6/milter-greylist.c.group 2004-11-27 15:43:17.000000000 +0100
+++ milter-greylist-1.6/milter-greylist.c 2005-02-03 10:43:26.349877397 +0100
@@ -48,6 +48,7 @@
#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
+#include <grp.h>
#include <unistd.h>
/* On IRIX, <unistd.h> defines a EX_OK that clashes with <sysexits.h> */
@@ -866,6 +867,19 @@
exit(EX_OSERR);
}
+ if (initgroups(conf.c_user, pw->pw_gid) != 0) {
+ syslog(LOG_ERR, "%s: can not change supplementary groups: %s\n",
+ argv[0], strerror(errno));
+ exit(EX_OSERR);
+ }
+
+ if (setgid(pw->pw_gid) != 0 ||
+ setegid(pw->pw_gid) != 0) {
+ syslog(LOG_ERR, "%s: cannot change GID: %s\n",
+ argv[0], strerror(errno));
+ exit(EX_OSERR);
+ }
+
if ((setuid(pw->pw_uid) != 0) ||
(seteuid(pw->pw_uid) != 0)) {
syslog(LOG_ERR, "%s: cannot change UID: %s\n",