about summary refs log tree commit diff
path: root/nscd
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 /nscd
parentb48061e1a534a2421c65e4258418d41a5335ba32 (diff)
downloadglibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.xz
glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'nscd')
-rw-r--r--nscd/connections.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 205ff423de..a5ca57aea5 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -499,13 +499,6 @@ fail:
 }
 
 
-#ifdef O_CLOEXEC
-# define EXTRA_O_FLAGS O_CLOEXEC
-#else
-# define EXTRA_O_FLAGS 0
-#endif
-
-
 /* Initialize database information structures.  */
 void
 nscd_init (void)
@@ -528,7 +521,7 @@ nscd_init (void)
 	if (dbs[cnt].persistent)
 	  {
 	    /* Try to open the appropriate file on disk.  */
-	    int fd = open (dbs[cnt].db_filename, O_RDWR | EXTRA_O_FLAGS);
+	    int fd = open (dbs[cnt].db_filename, O_RDWR | O_CLOEXEC);
 	    if (fd != -1)
 	      {
 		char *msg = NULL;
@@ -608,7 +601,7 @@ nscd_init (void)
 		    if (dbs[cnt].shared)
 		      {
 			dbs[cnt].ro_fd = open (dbs[cnt].db_filename,
-					       O_RDONLY | EXTRA_O_FLAGS);
+					       O_RDONLY | O_CLOEXEC);
 			if (dbs[cnt].ro_fd == -1)
 			  dbg_log (_("\
 cannot create read-only descriptor for \"%s\"; no mmap"),
@@ -648,23 +641,23 @@ cannot create read-only descriptor for \"%s\"; no mmap"),
 	    if (dbs[cnt].persistent)
 	      {
 		fd = open (dbs[cnt].db_filename,
-			   O_RDWR | O_CREAT | O_EXCL | O_TRUNC | EXTRA_O_FLAGS,
+			   O_RDWR | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC,
 			   S_IRUSR | S_IWUSR);
 		if (fd != -1 && dbs[cnt].shared)
 		  ro_fd = open (dbs[cnt].db_filename,
-				O_RDONLY | EXTRA_O_FLAGS);
+				O_RDONLY | O_CLOEXEC);
 	      }
 	    else
 	      {
 		char fname[] = _PATH_NSCD_XYZ_DB_TMP;
-		fd = mkostemp (fname, EXTRA_O_FLAGS);
+		fd = mkostemp (fname, O_CLOEXEC);
 
 		/* We do not need the file name anymore after we
 		   opened another file descriptor in read-only mode.  */
 		if (fd != -1)
 		  {
 		    if (dbs[cnt].shared)
-		      ro_fd = open (fname, O_RDONLY | EXTRA_O_FLAGS);
+		      ro_fd = open (fname, O_RDONLY | O_CLOEXEC);
 
 		    unlink (fname);
 		  }
@@ -782,24 +775,6 @@ cannot create read-only descriptor for \"%s\"; no mmap"),
 	      }
 	  }
 
-#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
-	/* We do not check here whether the O_CLOEXEC provided to the
-	   open call was successful or not.  The two fcntl calls are
-	   only performed once each per process start-up and therefore
-	   is not noticeable at all.  */
-	if (paranoia
-	    && ((dbs[cnt].wr_fd != -1
-		 && fcntl (dbs[cnt].wr_fd, F_SETFD, FD_CLOEXEC) == -1)
-		|| (dbs[cnt].ro_fd != -1
-		    && fcntl (dbs[cnt].ro_fd, F_SETFD, FD_CLOEXEC) == -1)))
-	  {
-	    dbg_log (_("\
-cannot set socket to close on exec: %s; disabling paranoia mode"),
-		     strerror (errno));
-	    paranoia = 0;
-	  }
-#endif
-
 	if (dbs[cnt].head == NULL)
 	  {
 	    /* We do not use the persistent database.  Just