summaryrefslogtreecommitdiff
path: root/nis
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-11-22 11:11:24 -0500
committerUlrich Drepper <drepper@redhat.com>2010-11-22 11:11:24 -0500
commit3056dcdb783a177158a5617657d1a33f872358d6 (patch)
tree5ecaf81b3305f617e74d6241b2c86a5b87cf96b5 /nis
parentcf7c9078a5acdbb435498ace92cd81009637a971 (diff)
downloadglibc-3056dcdb783a177158a5617657d1a33f872358d6.tar.gz
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. Conflicts: ChangeLog
Diffstat (limited to 'nis')
-rw-r--r--nis/nss_compat/compat-initgroups.c19
1 files changed, 11 insertions, 8 deletions
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);
}