about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPetr Baudis <pasky@ucw.cz>2010-08-22 16:37:10 +0200
committerPetr Baudis <pasky@suse.cz>2010-11-16 02:50:20 +0100
commitb9be604a7bcffd1fa5fc0141c0dfd2ddcbf09451 (patch)
tree29812b5d7bca239619c0a005a752469d5975f2a5
parent31eb5a4c4986367538ccb154dfce0c84276ba151 (diff)
downloadglibc-b9be604a7bcffd1fa5fc0141c0dfd2ddcbf09451.tar.gz
glibc-b9be604a7bcffd1fa5fc0141c0dfd2ddcbf09451.tar.xz
glibc-b9be604a7bcffd1fa5fc0141c0dfd2ddcbf09451.zip
Fix multiple nss_compat initgroups() bugs
Compat initgroups() is completely broken; the code will always set
skip_initgroups_dyn to true, so initgroups() will never be actually
called, but due to the nature of the code, setgrent() won't be called
either - thus, subsequent invocations of initgroups() will not return
the NIS group list anymore.

This is a simple patch that makes sure skip_initgroups_dyn is set only
in case initgroups is not available; it also attempts to handle the
unavailability of other NSS interfaces better.
-rw-r--r--ChangeLog6
-rw-r--r--nis/nss_compat/compat-initgroups.c19
2 files changed, 17 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index d253fde600..3d87811dc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-05-31  Petr Baudis <pasky@suse.cz>
+
+	[BZ #10085]
+	* nis/nss_compat/compat-initgroups.c (internal_getgrent_r): Fix
+	initialization of skip_initgroups_dyn.
+
 2010-05-17  Michael Matz <matz@suse.de>
 
 	[BZ #11610]
diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c
index 07a3b9282c..de8d95c7d1 100644
--- a/nis/nss_compat/compat-initgroups.c
+++ b/nis/nss_compat/compat-initgroups.c
@@ -474,18 +474,21 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user,
 	  /* If the selected module does not support getgrent_r or
 	     initgroups_dyn, abort. We cannot find the needed group
 	     entries.  */
-	  if (nss_getgrent_r == NULL && nss_initgroups_dyn == NULL)
+	  if (nss_initgroups_dyn == NULL || nss_getgrgid_r == NULL)
+	    {
+	      if (nss_setgrent != NULL)
+	        {
+		  nss_setgrent (1);
+		  ent->need_endgrent = true;
+		}
+	      ent->skip_initgroups_dyn = true;
+	    }
+
+	  if (ent->skip_initgroups_dyn && nss_getgrent_r == NULL)
 	    return NSS_STATUS_UNAVAIL;
 
 	  ent->files = false;
 
-	  if (nss_initgroups_dyn == NULL && nss_setgrent != NULL)
-	    {
-	      nss_setgrent (1);
-	      ent->need_endgrent = true;
-	    }
-	  ent->skip_initgroups_dyn = true;
-
 	  return getgrent_next_nss (ent, buffer, buflen, user, group,
 				    start, size, groupsp, limit, errnop);
 	}