aboutsummaryrefslogtreecommitdiff
path: root/nss
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-18 14:56:51 +0200
commitcef9b65376a044309f74b77860ccf3c48a4ae315 (patch)
treec934a9b57903468b9a2754c1cf8f99f2a94c9269 /nss
parentb48061e1a534a2421c65e4258418d41a5335ba32 (diff)
downloadglibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.bz2
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'nss')
-rw-r--r--nss/Makefile2
-rw-r--r--nss/nss_db/db-open.c6
-rw-r--r--nss/nss_files/files-XXX.c35
-rw-r--r--nss/nss_files/files-alias.c35
-rw-r--r--nss/nss_files/files-have_o_cloexec.c23
5 files changed, 2 insertions, 99 deletions
diff --git a/nss/Makefile b/nss/Makefile
index de6c47a1db..fa0418e249 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -74,7 +74,7 @@ vpath %.c $(subdir-dirs) ../locale/programs ../intl
libnss_files-routines := $(addprefix files-,$(databases)) \
- files-initgroups files-have_o_cloexec files-init
+ files-initgroups files-init
libnss_db-dbs := $(addprefix db-,\
$(filter-out hosts network key alias,\
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index 42ce00fe3b..1c58bd1c54 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -36,11 +36,7 @@ internal_setent (const char *file, struct nss_db_map *mapping)
{
enum nss_status status = NSS_STATUS_UNAVAIL;
- int mode = O_RDONLY | O_LARGEFILE;
-#ifdef O_CLOEXEC
- mode |= O_CLOEXEC;
-#endif
- int fd = open_not_cancel_2 (file, mode);
+ int fd = open_not_cancel_2 (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/nss/nss_files/files-XXX.c b/nss/nss_files/files-XXX.c
index dbd38a346a..265331ef21 100644
--- a/nss/nss_files/files-XXX.c
+++ b/nss/nss_files/files-XXX.c
@@ -78,41 +78,6 @@ internal_setent (FILE **stream)
if (*stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
- else
- {
-#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
-# ifdef O_CLOEXEC
- if (__have_o_cloexec <= 0)
-# endif
- {
- /* We have to make sure the file is `closed on exec'. */
- int result;
- int flags;
-
- result = flags = fcntl (fileno (*stream), F_GETFD, 0);
- if (result >= 0)
- {
-# ifdef O_CLOEXEC
- if (__have_o_cloexec == 0)
- __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
- if (__have_o_cloexec < 0)
-# endif
- {
- flags |= FD_CLOEXEC;
- result = fcntl (fileno (*stream), F_SETFD, flags);
- }
- }
- if (result < 0)
- {
- /* Something went wrong. Close the stream and return a
- failure. */
- fclose (*stream);
- *stream = NULL;
- status = NSS_STATUS_UNAVAIL;
- }
- }
-#endif
- }
}
else
rewind (*stream);
diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c
index de4e36499e..cf872bb603 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -51,41 +51,6 @@ internal_setent (FILE **stream)
if (*stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
- else
- {
-#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
-# ifdef O_CLOEXEC
- if (__have_o_cloexec <= 0)
-# endif
- {
- /* We have to make sure the file is `closed on exec'. */
- int result;
- int flags;
-
- result = flags = fcntl (fileno (*stream), F_GETFD, 0);
- if (result >= 0)
- {
-# ifdef O_CLOEXEC
- if (__have_o_cloexec == 0)
- __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
- if (__have_o_cloexec < 0)
-# endif
- {
- flags |= FD_CLOEXEC;
- result = fcntl (fileno (*stream), F_SETFD, flags);
- }
- }
- if (result < 0)
- {
- /* Something went wrong. Close the stream and return a
- failure. */
- fclose (*stream);
- stream = NULL;
- status = NSS_STATUS_UNAVAIL;
- }
- }
-#endif
- }
}
else
rewind (*stream);
diff --git a/nss/nss_files/files-have_o_cloexec.c b/nss/nss_files/files-have_o_cloexec.c
deleted file mode 100644
index 295ecccb77..0000000000
--- a/nss/nss_files/files-have_o_cloexec.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (C) 2007-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <fcntl.h>
-#include <kernel-features.h>
-
-#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
-int __have_o_cloexec;
-#endif