setgroups requires at least one group

Jeff DeFouw defouwj at purdue.edu
Tue Oct 8 21:47:00 EST 2002


On some operating systems (in this case BSD/OS 4.2) setgroups must be
given at least one group.  When no other groups are wanted, it is given
the same group as the desired effective group (as seen in sendmail).

For example, a patch against 2.5.5:

--- clientserver.c.orig Tue Oct  8 17:31:24 2002
+++ clientserver.c      Tue Oct  8 17:32:36 2002
@@ -301,9 +301,11 @@
 
        if (am_root) {
 #ifdef HAVE_SETGROUPS
+               gid_t gidset[1];
+               gidset[0] = gid;
                /* Get rid of any supplementary groups this process
                 * might have inheristed. */
-               if (setgroups(0, NULL)) {
+               if (setgroups(1, gidset)) {
                        rsyserr(FERROR, errno, "setgroups failed");
                        io_printf(fd, "@ERROR: setgroups failed\n");
                        return -1;

-- 
Jeff DeFouw <defouwj at purdue.edu>



More information about the rsync mailing list