about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-10-07 19:06:46 +0000
committerJakub Jelinek <jakub@redhat.com>2006-10-07 19:06:46 +0000
commitb75a89e7de5530eec2527cb9a8995e48d339a703 (patch)
tree0ba7ff50a8313d44958d0b5fa3082789dc15b566
parent16d1b47b4f3f9ae13535ea7a2c02bd207c069d5c (diff)
downloadglibc-b75a89e7de5530eec2527cb9a8995e48d339a703.tar.gz
glibc-b75a89e7de5530eec2527cb9a8995e48d339a703.tar.xz
glibc-b75a89e7de5530eec2527cb9a8995e48d339a703.zip
Adjust for fedora-2_5-branch.
-rw-r--r--fedora/.cvsignore2
-rw-r--r--fedora/branch.mk8
-rw-r--r--nis/nss_nisplus/nisplus-initgroups.c150
3 files changed, 155 insertions, 5 deletions
diff --git a/fedora/.cvsignore b/fedora/.cvsignore
index 02a03c3ffc..11718c84e2 100644
--- a/fedora/.cvsignore
+++ b/fedora/.cvsignore
@@ -1,5 +1,5 @@
 glibc-*.tar.bz2
 glibc-*.src.rpm
-glibc-fedora.patch
+glibc-*fedora.patch
 glibc.spec
 update.log
diff --git a/fedora/branch.mk b/fedora/branch.mk
index 5c112f2090..608931e4a9 100644
--- a/fedora/branch.mk
+++ b/fedora/branch.mk
@@ -1,7 +1,7 @@
 # This file is updated automatically by Makefile.
-glibc-branch := fedora
-glibc-base := HEAD
-DIST_BRANCH := devel
-COLLECTION := dist-fc4
+glibc-branch := fedora-2_5
+glibc-base := glibc-2_5-branch
+DIST_BRANCH := FC-6
+COLLECTION := dist-fc6
 fedora-sync-date := 2006-10-02 18:58 UTC
 fedora-sync-tag := fedora-glibc-20061002T1858
diff --git a/nis/nss_nisplus/nisplus-initgroups.c b/nis/nss_nisplus/nisplus-initgroups.c
new file mode 100644
index 0000000000..6588ec2533
--- /dev/null
+++ b/nis/nss_nisplus/nisplus-initgroups.c
@@ -0,0 +1,150 @@
+/* Copyright (C) 1997, 2001, 2002, 2003, 2005, 2006
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <atomic.h>
+#include <nss.h>
+#include <grp.h>
+#include <ctype.h>
+#include <errno.h>
+#include <string.h>
+#include <bits/libc-lock.h>
+#include <rpcsvc/nis.h>
+
+#include "nss-nisplus.h"
+#include "nisplus-parser.h"
+#include <libnsl.h>
+#include <nis_intern.h>
+#include <nis_xdr.h>
+
+#define NISOBJVAL(col, obj) \
+  ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_val)
+
+#define NISOBJLEN(col, obj) \
+  ((obj)->EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
+
+extern nis_name grp_tablename_val attribute_hidden;
+extern size_t grp_tablename_len attribute_hidden;
+extern enum nss_status _nss_grp_create_tablename (int *errnop);
+
+
+enum nss_status
+_nss_nisplus_initgroups_dyn (const char *user, gid_t group, long int *start,
+			     long int *size, gid_t **groupsp, long int limit,
+			     int *errnop)
+{
+  if (grp_tablename_val == NULL)
+    {
+      enum nss_status status = _nss_grp_create_tablename (errnop);
+
+      if (status != NSS_STATUS_SUCCESS)
+	return status;
+    }
+
+  nis_result *result;
+  char buf[strlen (user) + 12 + grp_tablename_len];
+
+  snprintf (buf, sizeof (buf), "[members=%s],%s", user, grp_tablename_val);
+
+  result = nis_list (buf, FOLLOW_LINKS | FOLLOW_PATH | ALL_RESULTS, NULL, NULL);
+
+  if (result == NULL)
+    {
+      *errnop = ENOMEM;
+      return NSS_STATUS_TRYAGAIN;
+    }
+
+  if (__builtin_expect (niserr2nss (result->status) != NSS_STATUS_SUCCESS, 0))
+    {
+      enum nss_status status = niserr2nss (result->status);
+
+      nis_freeresult (result);
+      return status;
+    }
+
+  if (NIS_RES_NUMOBJ (result) == 0)
+    {
+    errout:
+      nis_freeresult (result);
+      return NSS_STATUS_NOTFOUND;
+    }
+
+  gid_t *groups = *groupsp;
+  nis_object *obj = NIS_RES_OBJECT (result);
+  for (unsigned int cnt = 0; cnt < NIS_RES_NUMOBJ (result); ++cnt, ++obj)
+    {
+      if (__type_of (obj) != NIS_ENTRY_OBJ
+	  || strcmp (obj->EN_data.en_type, "group_tbl") != 0
+	  || obj->EN_data.en_cols.en_cols_len < 4)
+	continue;
+
+      char *numstr = NISOBJVAL (2, obj);
+      size_t len = NISOBJLEN (2, obj);
+      if (len == 0 || numstr[0] == '\0')
+	continue;
+
+      gid_t gid;
+      char *endp;
+      if (__builtin_expect (numstr[len - 1] != '\0', 0))
+	{
+	  char numstrbuf[len + 1];
+	  memcpy (numstrbuf, numstr, len);
+	  numstrbuf[len] = '\0';
+	  gid = strtoul (numstrbuf, &endp, 10);
+	  if (*endp)
+	    continue;
+	}
+      else
+	{
+	  gid = strtoul (numstr, &endp, 10);
+	  if (*endp)
+	    continue;
+	}
+
+      if (gid == group)
+	continue;
+
+      /* Insert this group.  */
+      if (*start == *size)
+	{
+	  /* Need a bigger buffer.  */
+	  long int newsize;
+
+	  if (limit > 0 && *size == limit)
+	    /* We reached the maximum.  */
+	    break;
+
+	  if (limit <= 0)
+	    newsize = 2 * *size;
+	  else
+	    newsize = MIN (limit, 2 * *size);
+
+	  gid_t *newgroups = realloc (groups, newsize * sizeof (*groups));
+	  if (newgroups == NULL)
+	    goto errout;
+	  *groupsp = groups = newgroups;
+	  *size = newsize;
+	}
+
+      groups[*start] = gid;
+      *start += 1;
+    }
+
+  nis_freeresult (result);
+  return NSS_STATUS_SUCCESS;
+}