From 044b16f4e9ae773187f4fee8a9a0a54f9a51f13f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 5 Aug 1997 23:36:21 +0000 Subject: update for 2.0.5pre1 --- nis/nss_compat/compat-grp.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'nis/nss_compat/compat-grp.c') diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index de96dbbeb6..91d3b56bb5 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996 Free Software Foundation, Inc. +/* Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1996. @@ -18,6 +18,7 @@ Boston, MA 02111-1307, USA. */ #include +#include #include #include #include @@ -86,6 +87,26 @@ internal_setgrent (ent_t *ent) if (ent->stream == NULL) status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + else + { + /* We have to make sure the file is `closed on exec'. */ + int result, flags; + + result = flags = fcntl (fileno (ent->stream), F_GETFD, 0); + if (result >= 0) + { + flags |= FD_CLOEXEC; + result = fcntl (fileno (ent->stream), F_SETFD, flags); + } + if (result < 0) + { + /* Something went wrong. Close the stream and return a + failure. */ + fclose (ent->stream); + ent->stream = NULL; + status = NSS_STATUS_UNAVAIL; + } + } } else rewind (ent->stream); -- cgit v1.2.3