From 025153a3cc83c227e9a3dec95b94eb56dd5e3c58 Mon Sep 17 00:00:00 2001 From: David Levine Date: Sun, 2 Feb 2014 22:16:25 -0600 Subject: [PATCH] Restored setuid/setgid to slocal: it needs them when run as root, as a mail delivery agent. --- uip/slocal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/uip/slocal.c b/uip/slocal.c index a807d816..fb21c880 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -34,6 +34,10 @@ #include #include +/* Hopefully, grp.h declares initgroups(). If we run into a platform + where it doesn't, we could consider declaring it here as well. */ +#include + /* This define is needed for Berkeley db v2 and above to * make the header file expose the 'historical' ndbm APIs. * We define it unconditionally because this is simple and @@ -278,6 +282,16 @@ main (int argc, char **argv) chdir ("/"); umask (0077); + if (geteuid() == 0) { + if (setgid (pw->pw_gid) != 0) { + adios ("setgid", "unable to set group to %ld", (long) pw->pw_gid); + } + initgroups (pw->pw_name, pw->pw_gid); + if (setuid (pw->pw_uid) != 0) { + adios ("setuid", "unable to set user to %ld", (long) pw->pw_uid); + } + } + if (info == NULL) info = ""; -- 2.56.0