summaryrefslogtreecommitdiff
path: root/nscd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-08-14 07:38:41 +0000
committerJakub Jelinek <jakub@redhat.com>2007-08-14 07:38:41 +0000
commitc67c02731b6507c5351bca70451441d9a26113ef (patch)
treeafe8d99e55401fe7955475ab97a497cae2e23ab2 /nscd
parent39762d6a5c0e378f20b28da7450868bfef588fb0 (diff)
Updated to fedora-glibc-20070814T0725cvs/fedora-glibc-2_6_90-9
Diffstat (limited to 'nscd')
-rw-r--r--nscd/connections.c27
-rw-r--r--nscd/gai.c2
-rw-r--r--nscd/servicescache.c1
3 files changed, 24 insertions, 6 deletions
diff --git a/nscd/connections.c b/nscd/connections.c
index 32a1077819..72581071af 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -469,6 +469,13 @@ 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)
@@ -491,7 +498,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);
+ int fd = open (dbs[cnt].db_filename, O_RDWR | EXTRA_O_FLAGS);
if (fd != -1)
{
struct stat64 st;
@@ -570,7 +577,8 @@ nscd_init (void)
/* We also need a read-only descriptor. */
if (dbs[cnt].shared)
{
- dbs[cnt].ro_fd = open (dbs[cnt].db_filename, O_RDONLY);
+ dbs[cnt].ro_fd = open (dbs[cnt].db_filename,
+ O_RDONLY | EXTRA_O_FLAGS);
if (dbs[cnt].ro_fd == -1)
dbg_log (_("\
cannot create read-only descriptor for \"%s\"; no mmap"),
@@ -607,22 +615,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,
+ O_RDWR | O_CREAT | O_EXCL | O_TRUNC | EXTRA_O_FLAGS,
S_IRUSR | S_IWUSR);
if (fd != -1 && dbs[cnt].shared)
- ro_fd = open (dbs[cnt].db_filename, O_RDONLY);
+ ro_fd = open (dbs[cnt].db_filename,
+ O_RDONLY | EXTRA_O_FLAGS);
}
else
{
char fname[] = _PATH_NSCD_XYZ_DB_TMP;
- fd = mkstemp (fname);
+ fd = mkostemp (fname, EXTRA_O_FLAGS);
/* 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);
+ ro_fd = open (fname, O_RDONLY | EXTRA_O_FLAGS);
unlink (fname);
}
@@ -741,6 +750,11 @@ 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)
@@ -752,6 +766,7 @@ cannot set socket to close on exec: %s; disabling paranoia mode"),
strerror (errno));
paranoia = 0;
}
+#endif
if (dbs[cnt].head == NULL)
{
diff --git a/nscd/gai.c b/nscd/gai.c
index 23964b7fd7..f2db5299aa 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -17,6 +17,8 @@
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <alloca.h>
+#include <kernel-features.h>
+
/* This file uses the getaddrinfo code but it compiles it without NSCD
support. We just need a few symbol renames. */
#define __inet_aton inet_aton
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 89e107bae7..d6bf51d29f 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -24,6 +24,7 @@
#include <netdb.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <kernel-features.h>
#include "nscd.h"
#include "dbg_log.h"