Re: Cyrus IMAPd 2.3.10 Released

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

>>>>> On Sun, 28 Oct 2007 09:57:45 -0400
>>>>> Ken Murchison <murch@xxxxxxxxxxxxxx> 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@xxxxxxxxxxxx  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux