summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-07-12 13:41:17 +1000
committerAmitay Isaacs <amitay@samba.org>2017-07-13 13:30:23 +0200
commit3e85cbfd7541d8f30ce1f3244ebcc44332b394fe (patch)
tree9161ce6da2a6ebe84b135787c94be098db6ef6c0 /ctdb/common
parentbebf90f7a101e0180e39e0332f2a1b1023ea0437 (diff)
downloadsamba-3e85cbfd7541d8f30ce1f3244ebcc44332b394fe.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>
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) {