1 commit 3056dcdb783a177158a5617657d1a33f872358d6
2 Author: Ulrich Drepper <drepper@redhat.com>
3 Date: Mon Nov 22 11:11:24 2010 -0500
5 Fix multiple nss_compat initgroups() bugs
7 Compat initgroups() is completely broken; the code will always set
8 skip_initgroups_dyn to true, so initgroups() will never be actually
9 called, but due to the nature of the code, setgrent() won't be called
10 either - thus, subsequent invocations of initgroups() will not return
11 the NIS group list anymore.
13 This is a simple patch that makes sure skip_initgroups_dyn is set only
14 in case initgroups is not available; it also attempts to handle the
15 unavailability of other NSS interfaces better.
21 diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c
22 index 07a3b92..de8d95c 100644
23 --- a/nis/nss_compat/compat-initgroups.c
24 +++ b/nis/nss_compat/compat-initgroups.c
25 @@ -474,18 +474,21 @@ internal_getgrent_r (ent_t *ent, char *buffer, size_t buflen, const char *user,
26 /* If the selected module does not support getgrent_r or
27 initgroups_dyn, abort. We cannot find the needed group
29 - if (nss_getgrent_r == NULL && nss_initgroups_dyn == NULL)
30 + if (nss_initgroups_dyn == NULL || nss_getgrgid_r == NULL)
32 + if (nss_setgrent != NULL)
35 + ent->need_endgrent = true;
37 + ent->skip_initgroups_dyn = true;
40 + if (ent->skip_initgroups_dyn && nss_getgrent_r == NULL)
41 return NSS_STATUS_UNAVAIL;
45 - if (nss_initgroups_dyn == NULL && nss_setgrent != NULL)
48 - ent->need_endgrent = true;
50 - ent->skip_initgroups_dyn = true;
52 return getgrent_next_nss (ent, buffer, buflen, user, group,
53 start, size, groupsp, limit, errnop);