summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-07-12 13:41:17 +1000
committerKarolin Seeger <kseeger@samba.org>2017-07-24 22:00:38 +0200
commitb51aa15406e5da172be870facdfbdbd1402973a6 (patch)
treea11f6909a7a0b34fb9f40db20e738449acb283c1 /ctdb/common
parent0f40c214585a765955c5340db53e28802604dfcd (diff)
downloadsamba-b51aa15406e5da172be870facdfbdbd1402973a6.tar.gz
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 <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> (cherry picked from commit 3e85cbfd7541d8f30ce1f3244ebcc44332b394fe)
Diffstat (limited to 'ctdb/common')
-rw-r--r--ctdb/common/pidfile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ctdb/common/pidfile.c b/ctdb/common/pidfile.c
index b3f29e3f07d..51c0c25c92e 100644
--- a/ctdb/common/pidfile.c
+++ b/ctdb/common/pidfile.c
@@ -22,6 +22,8 @@
#include <talloc.h>
+#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) {