From 44ba19c8859c03726155bb98cfe08cf2eab05512 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 12 Jul 2017 13:41:17 +1000 Subject: [PATCH] ctdb-common: Set close-on-exec when creating PID file 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 Reviewed-by: Amitay Isaacs (cherry picked from commit 3e85cbfd7541d8f30ce1f3244ebcc44332b394fe) --- ctdb/common/pidfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ctdb/common/pidfile.c b/ctdb/common/pidfile.c index b3f29e3..51c0c25 100644 --- a/ctdb/common/pidfile.c +++ b/ctdb/common/pidfile.c @@ -22,6 +22,8 @@ #include +#include "lib/util/blocking.h" + #include "common/pidfile.h" struct pidfile_context { @@ -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) { -- 2.9.4