[PATCH][BZ #15304] Don't add gid passed as argument to _nss_hesiod_initgroups_dyn

Siddhesh Poyarekar siddhesh@redhat.com
Tue Mar 26 09:39:00 GMT 2013


Hi,

All initgroups_dyn implementations add all groups associated with a
user except the gid passed by the caller of the function, to the
groups list.  Hesiod works differently (incorrectly) however, since it
adds a group (including the one passed in the function call) if it
does not already exist.  This works fine for the vanilla initgroups
function, where the gid passed into the function call is already added
in but not when nscd calls it, since the latter calls initgroups_dyn
with -1 as the gid.  Due to this, retreiving group lists for a user
over nscd results in an additional 4294967295 gid prepended to the
list.

This patch fixes the problem by removing the code that includes the
input gid in _nss_hesiod_initgroups_dyn.  Verified the fix on ppc64
and no regressions reported.  OK to commit?

Siddhesh

	[BZ #15304]
	* hesiod/nss_hesiod/hesiod-grp.c (_nss_hesiod_initgroups_dyn):
	Don't add gid passed as argument.

diff --git a/hesiod/nss_hesiod/hesiod-grp.c b/hesiod/nss_hesiod/hesiod-grp.c
index c2ae166..b11952f 100644
--- a/hesiod/nss_hesiod/hesiod-grp.c
+++ b/hesiod/nss_hesiod/hesiod-grp.c
@@ -191,33 +191,6 @@ _nss_hesiod_initgroups_dyn (const char *user, gid_t group, long int *start,
       return errno == ENOENT ? NSS_STATUS_NOTFOUND : NSS_STATUS_UNAVAIL;
     }
 
-  if (!internal_gid_in_list (groups, group, *start))
-    {
-      if (__builtin_expect (*start == *size, 0))
-	{
-	  /* Need a bigger buffer.  */
-	  gid_t *newgroups;
-	  long int newsize;
-
-	  if (limit > 0 && *size == limit)
-	    /* We reached the maximum.  */
-	    goto done;
-
-	  if (limit <= 0)
-	    newsize = 2 * *size;
-	  else
-	    newsize = MIN (limit, 2 * *size);
-
-	  newgroups = realloc (groups, newsize * sizeof (*groups));
-	  if (newgroups == NULL)
-	    goto done;
-	  *groupsp = groups = newgroups;
-	  *size = newsize;
-	}
-
-      groups[(*start)++] = group;
-    }
-
   save_errno = errno;
 
   p = *list;



More information about the Libc-alpha mailing list