chiark / gitweb /
[PATCH] PATCH udev close on exec
[elogind.git] / tdb / tdb.c
index 34681ea78f28fea90617ad1699fae9e37abd7eef..e87ea3692eb555f2cea013cb94f98b14acd2cd0a 100644 (file)
--- a/tdb/tdb.c
+++ b/tdb/tdb.c
  * right time.  Probably too hard -- the process just doesn't know.
  */ 
 
+/* udev defines */
+#define STANDALONE
+#define TDB_DEBUG
+#define HAVE_MMAP      1
+
+
 #ifdef STANDALONE
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif
 
+#define _KLIBC_HAS_ARCH_SIG_ATOMIC_T
 #include <stdlib.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -58,6 +65,7 @@
 #include <signal.h>
 #include "tdb.h"
 #include "spinlock.h"
+#include "../udev_lib.h"
 #else
 #include "includes.h"
 #endif
@@ -1729,6 +1737,12 @@ TDB_CONTEXT *tdb_open_ex(const char *name, int hash_size, int tdb_flags,
                goto fail;      /* errno set by open(2) */
        }
 
+       /* 
+          Close file when execing another process.  
+          Prevents SELinux access errors.
+       */
+       set_cloexec_flag(tdb->fd, 1);
+
        /* ensure there is only one process initialising at once */
        if (tdb_brlock(tdb, GLOBAL_LOCK, F_WRLCK, F_SETLKW, 0) == -1) {
                TDB_LOG((tdb, 0, "tdb_open_ex: failed to get global lock on %s: %s\n",