Skip to content

Commit

Permalink
lib: Open tdb files with O_CLOEXEC
Browse files Browse the repository at this point in the history
After an exec() the fd's don't make sense anymore

Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
vlendec authored and jrasamba committed Jun 4, 2021
1 parent 87a0a20 commit b619195
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/tdb_wrap/tdb_wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b619195

Please sign in to comment.