aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-01-21 19:30:19 +0000
committerMark Johnston <markj@FreeBSD.org>2021-01-21 19:30:19 +0000
commit48a186863431ec7a23c6174bc376cafa59dd5fbf (patch)
tree0b6de4bbde8473ab40249f38afd143fdc296615d /lib/libc
parent6e411d8b14ec5402b7551073e2f9edc4d680dd49 (diff)
downloadsrc-48a186863431ec7a23c6174bc376cafa59dd5fbf.tar.gz
src-48a186863431ec7a23c6174bc376cafa59dd5fbf.zip
libc/nss: Ensure that setgroupent(3) actually works as advertised
Because the "files" and "compat" implementations failed to set the "stayopen", keyed lookups would close the database handle, contrary to the purpose of setgroupent(3). setpassent(3)'s implementation does not have this bug. PR: 165527 Submitted by: Andrey Simonenko MFC after: 1 month
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getgrent.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 6abccea30c6b..afb89cab308b 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -824,6 +824,7 @@ files_setgrent(void *retval, void *mdata, va_list ap)
rewind(st->fp);
else if (stayopen)
st->fp = fopen(_PATH_GROUP, "re");
+ st->stayopen = stayopen;
break;
case ENDGRENT:
if (st->fp != NULL) {
@@ -1271,6 +1272,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap)
rewind(st->fp);
else if (stayopen)
st->fp = fopen(_PATH_GROUP, "re");
+ st->stayopen = stayopen;
set_setent(dtab, mdata);
(void)_nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent",
compatsrc, 0);