]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix multiple nss_compat initgroups() bugs
authorUlrich Drepper <drepper@redhat.com>
Mon, 22 Nov 2010 16:11:24 +0000 (11:11 -0500)
committerAndreas Schwab <schwab@redhat.com>
Wed, 1 Dec 2010 14:35:20 +0000 (15:35 +0100)
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.

Conflicts:

ChangeLog
(cherry picked from commit 3056dcdb783a177158a5617657d1a33f872358d6)

ChangeLog
nis/nss_compat/compat-initgroups.c

index 45fc5eb5f2803d337754526890328f7328846141..de688e39e250f09d0d74b596f86202c8ba3757ab 100644 (file)
--- 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-09-27  Andreas Schwab  <schwab@redhat.com>
 
        [BZ #11611]
index 07a3b9282c37c9dd81c3c9421f06d6b2c5e71867..de8d95c7d1b81783d68c2a18fe8c349d20d07192 100644 (file)
@@ -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);
        }