Skip to content

Commit

Permalink
ctdb-common: Set close-on-exec when creating PID file
Browse files Browse the repository at this point in the history
Otherwise, for example, the file descriptor for the main PID file will
leak all the way down to event scripts.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12898

Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
  • Loading branch information
martin-schwenke authored and Amitay Isaacs committed Jul 13, 2017
1 parent bebf90f commit 3e85cbf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ctdb/common/pidfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include <talloc.h>

#include "lib/util/blocking.h"

#include "common/pidfile.h"

struct pidfile_context {
Expand Down Expand Up @@ -61,6 +63,12 @@ int pidfile_create(TALLOC_CTX *mem_ctx, const char *pidfile,
goto fail;
}

if (! set_close_on_exec(fd)) {
close(fd);
ret = EIO;
goto fail;
}

pid_ctx->fd = fd;

lck = (struct flock) {
Expand Down

0 comments on commit 3e85cbf

Please sign in to comment.