From 0200080b60444d5785e02341f2fa94fd36e096cc Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sat, 16 Oct 1999 12:31:49 +0000 Subject: [PATCH] YP/NIS code: remove unnecessary endgrent() calls which can cause fail on next try over chroot (descriptor closed). getgrnam() used already handles endgrent() properly and honors _gr_stayopen. Automatically call setgroupent(1) when _pw_stayopen is set (for YP/NIS code). --- lib/libc/gen/getpwent.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 9f9534488539..90dbb4a24cf5 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -231,6 +231,8 @@ setpassent(stayopen) _pw_keynum = 0; #ifdef YP _pw_stepping_yp = 0; + if (stayopen) + setgroupent(1); #endif _pw_stayopen = stayopen; return(1); @@ -429,7 +431,6 @@ unwind(grp) gr->gr_mem++; return(rv); } else { - endgrent(); latch = 0; _pw_stepping_yp = 0; gr = NULL; @@ -496,14 +497,11 @@ ingr(grp, name) return(0); while(*gr->gr_mem) { - if (!strcmp(*gr->gr_mem, name)) { - endgrent(); + if (!strcmp(*gr->gr_mem, name)) return(1); - } gr->gr_mem++; } - endgrent(); return(0); }