diff options
author | Martin Schwenke <martin@meltin.net> | 2018-07-12 13:27:16 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-07-31 12:36:28 +0200 |
commit | 792e170278134f030996cdab5607a88e53a52b00 (patch) | |
tree | eaa1db08747c72836cd136502d21ed7043c487de | |
parent | 0c65347e949b27d2532361e9395ac8ab9d3394ef (diff) | |
download | samba-792e170278134f030996cdab5607a88e53a52b00.tar.gz |
ctdb-event: Change event-tool script enable/disable to chmod file directly
They no longer go over the socket to eventd to enable and disable
scripts. Use the event script abstraction to chmod them directly.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13551
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 295826f1b83b6e59d24e4da43b290242c17f44af)
-rw-r--r-- | ctdb/event/event_tool.c | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c index 7760c971340..223e829c343 100644 --- a/ctdb/event/event_tool.c +++ b/ctdb/event/event_tool.c @@ -30,6 +30,7 @@ #include "common/cmdline.h" #include "common/logging.h" #include "common/path.h" +#include "common/event_script.h" #include "event/event_protocol_api.h" #include "event/event.h" @@ -298,44 +299,30 @@ static int event_command_script(TALLOC_CTX *mem_ctx, struct event_tool_context *ctx, const char *component, const char *script, - enum ctdb_event_script_action action) + bool enable) { - struct tevent_req *req; - struct ctdb_event_request_script request_script; - int ret = 0, result = 0; - bool ok; + char *subdir, *etc_dir; + int result = 0; - ret = ctdb_event_init(ctx, ctx->ev, &ctx->eclient); - if (ret != 0) { - D_ERR("Failed to initialize event client, ret=%d\n", ret); - return ret; + subdir = talloc_asprintf(mem_ctx, "events/%s", component); + if (subdir == NULL) { + return ENOMEM; } - request_script.component = component; - request_script.script = script; - request_script.action = action; - - req = ctdb_event_script_send(mem_ctx, - ctx->ev, - ctx->eclient, - &request_script); - if (req == NULL) { - D_ERR("Memory allocation error\n"); - return 1; + etc_dir = path_etcdir_append(mem_ctx, subdir); + if (etc_dir == NULL) { + return ENOMEM; } - tevent_req_poll(req, ctx->ev); - - ok = ctdb_event_script_recv(req, &ret, &result); - if (!ok) { - D_ERR("Failed to %s script, ret=%d\n", - (action == CTDB_EVENT_SCRIPT_DISABLE ? - "disable" : - "enable"), - ret); - return 1; + if (enable) { + result = event_script_chmod(etc_dir, script, true); + } else { + result = event_script_chmod(etc_dir, script, false); } + talloc_free(subdir); + talloc_free(etc_dir); + D_NOTICE("Command script finished with result=%d\n", result); if (result == EINVAL) { @@ -388,7 +375,7 @@ static int event_command_script_enable(TALLOC_CTX *mem_ctx, ctx, argv[0], argv[1], - CTDB_EVENT_SCRIPT_ENABLE); + true); } printf("Script %s is not a file or a link\n", etc_script); @@ -461,7 +448,7 @@ static int event_command_script_disable(TALLOC_CTX *mem_ctx, ctx, argv[0], argv[1], - CTDB_EVENT_SCRIPT_DISABLE); + false); } printf("Script %s is not a file or a link\n", etc_script); |