From: Marcin Cieslak Date: Fri, 13 Feb 2015 03:09:26 +0000 (-0600) Subject: Replaced setgid() calls with setegid() so that it works with dot X-Git-Tag: mmh-0.2-RC1~48 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=0a96784b09f85f33437936b5dcfa819a33fa5bac;p=mmh Replaced setgid() calls with setegid() so that it works with dot locking on FreeBSD. setegid() should be supported on modern POSIX systems. --- diff --git a/uip/inc.c b/uip/inc.c index 8a05c6a..33672de 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -97,8 +97,16 @@ static int return_gid; ** easy case; we're not setuid root, so can drop group privs immediately. */ #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS() -#define DROPGROUPPRIVS() setgid(getgid()) -#define GETGROUPPRIVS() setgid(return_gid) +#define DROPGROUPPRIVS() \ + if (setegid(getgid()) != 0) { \ + advise ("setegid", "unable to set group to %ld", (long) getgid()); \ + _exit (-1); \ + } +#define GETGROUPPRIVS() \ + if (setegid(return_gid) != 0) { \ + advise ("setegid", "unable to set group to %ld", (long) return_gid); \ + _exit (-1); \ + } #define SAVEGROUPPRIVS() return_gid = getegid() #else /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */