From 0a96784b09f85f33437936b5dcfa819a33fa5bac Mon Sep 17 00:00:00 2001 From: Marcin Cieslak Date: Thu, 12 Feb 2015 21:09:26 -0600 Subject: [PATCH] Replaced setgid() calls with setegid() so that it works with dot locking on FreeBSD. setegid() should be supported on modern POSIX systems. --- uip/inc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 */ -- 1.7.10.4