lib: Open tdb files with O_CLOEXEC
authorVolker Lendecke <vl@samba.org>
Fri, 7 May 2021 05:32:37 +0000 (07:32 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 4 Jun 2021 16:47:34 +0000 (16:47 +0000)
After an exec() the fd's don't make sense anymore

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/tdb_wrap/tdb_wrap.c

index 864656f204768d149d4c16e76c2cc9ae8af13078..49585aa0b9fca9b4211f5277c540b076f3523852 100644 (file)
@@ -20,6 +20,7 @@
 */
 
 #include "replace.h"
+#include "system/filesys.h"
 #include "lib/util/dlinklist.h"
 #include "lib/util/debug.h"
 #include "tdb_wrap.h"
@@ -100,6 +101,11 @@ static struct tdb_wrap_private *tdb_wrap_private_open(TALLOC_CTX *mem_ctx,
        /* Doesn't fail, see talloc_pooled_object */
        result->name = talloc_strdup(result, name);
 
+       /*
+        * TDB files don't make sense after execve()
+        */
+       open_flags |= O_CLOEXEC;
+
        result->tdb = tdb_open_ex(name, hash_size, tdb_flags,
                                  open_flags, mode, &lctx, NULL);
        if (result->tdb == NULL) {