summaryrefslogtreecommitdiff
path: root/ctdb/common
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2018-10-10 18:16:33 +1100
committerAmitay Isaacs <amitay@samba.org>2018-10-22 06:04:20 +0200
commit80549927bc1741a4b8af8b8e830de4d37fa0c4a8 (patch)
tree8b7b5dab10501079f803d848bac85a757b8da04a /ctdb/common
parentc9e1603a5d0c1a216439d4a2b0e7cdc05181e898 (diff)
downloadsamba-80549927bc1741a4b8af8b8e830de4d37fa0c4a8.tar.gz
ctdb-common: Set close-on-exec for startup fd
The startup_fd should not be propagated to the child processes created from a daemon. It should only be used in the daemon code to return the status of the startup. Another use of startup_fd is to notify the parent if the daemon process has exited. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13659 Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/common')
-rw-r--r--ctdb/common/sock_daemon.c8
-rw-r--r--ctdb/common/sock_daemon.h3
2 files changed, 9 insertions, 2 deletions
diff --git a/ctdb/common/sock_daemon.c b/ctdb/common/sock_daemon.c
index 90f6bce2fd3..e5e16f8af12 100644
--- a/ctdb/common/sock_daemon.c
+++ b/ctdb/common/sock_daemon.c
@@ -523,9 +523,15 @@ int sock_daemon_add_unix(struct sock_daemon_context *sockd,
return 0;
}
-void sock_daemon_set_startup_fd(struct sock_daemon_context *sockd, int fd)
+bool sock_daemon_set_startup_fd(struct sock_daemon_context *sockd, int fd)
{
+ if (! set_close_on_exec(fd)) {
+ D_ERR("Failed to set close-on-exec on startup fd\n");
+ return false;
+ }
+
sockd->startup_fd = fd;
+ return true;
}
/*
diff --git a/ctdb/common/sock_daemon.h b/ctdb/common/sock_daemon.h
index 972245a9650..7aa9d5dfd34 100644
--- a/ctdb/common/sock_daemon.h
+++ b/ctdb/common/sock_daemon.h
@@ -216,8 +216,9 @@ int sock_daemon_add_unix(struct sock_daemon_context *sockd,
*
* @param[in] sockd Socket daemon context
* @param[in] fd File descriptor
+ * @return true on success, false on error
*/
-void sock_daemon_set_startup_fd(struct sock_daemon_context *sockd, int fd);
+bool sock_daemon_set_startup_fd(struct sock_daemon_context *sockd, int fd);
/**
* @brief Async computation start to run a socket daemon