Cyrus IMAPd 2.3.10 Released

Hajimu UMEMOTO ume at mahoroba.org
Sun Oct 28 14:21:41 EDT 2007


Hi,

>>>>> On Sun, 28 Oct 2007 09:57:45 -0400
>>>>> Ken Murchison <murch at andrew.cmu.edu> said:

murch> I don't have easy access to a BSD platform.  Would somebody be willing 
murch> to write and test such a patch?

How about this patch?

Index: lib/auth_unix.c
diff -u -p lib/auth_unix.c.orig lib/auth_unix.c
--- lib/auth_unix.c.orig	2007-09-28 05:02:45.000000000 +0900
+++ lib/auth_unix.c	2007-10-29 03:14:22.000000000 +0900
@@ -45,6 +45,9 @@
  */
 
 #include <config.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
 #include <stdlib.h>
 #include <pwd.h>
 #include <grp.h>
@@ -225,7 +228,12 @@ static struct auth_state *mynewstate(con
     struct group *grp;
 #ifdef HAVE_GETGROUPLIST
     gid_t gid, *groupids = NULL;
-    int ret, ngroups = 0;
+    int ret = -1;
+#ifdef __GLIBC__
+    int ngroups = 0;
+#else
+    int ngroups = 5;
+#endif
 #else
     char **mem;
 #endif
@@ -248,22 +256,33 @@ static struct auth_state *mynewstate(con
 #ifdef HAVE_GETGROUPLIST
     gid = pwd ? pwd->pw_gid : (gid_t) -1;
 
+#ifdef __GLIBC__
     /* get number of groups user is member of into ngroups */
     getgrouplist(identifier, gid, NULL, &ngroups);
+#endif
 
     /* get the actual group ids */
-    do {
+    while (ngroups <= NGROUPS) {
 	groupids = (gid_t *)xrealloc((gid_t *)groupids,
 				     ngroups * sizeof(gid_t));
 
 	newstate->ngroups = ngroups; /* copy of ngroups for comparision */
 	ret = getgrouplist(identifier, gid, groupids, &ngroups);
+	if (ret != -1)
+	    break;
+#ifdef __GLIBC__
 	/*
 	 * This is tricky. We do this as long as getgrouplist tells us to
 	 * realloc _and_ the number of groups changes. It tells us to realloc
 	 * also in the case of failure...
 	 */
-    } while (ret != -1 && ngroups != newstate->ngroups);
+	if (ngroups == newstate->ngroups)
+	    break;
+#else
+	if ((ngroups = newstate->ngroups * 2) > NGROUPS)
+	    ngroups = NGROUPS;
+#endif
+    }
 
     if (ret == -1) {
 	newstate->ngroups = 0;


Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume at mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/


More information about the Info-cyrus mailing list