From: Martin Schwenke Date: Fri, 7 Sep 2018 04:35:15 +0000 (+1000) Subject: ctdb-event: Declare and construct data_script only if needed X-Git-Tag: tdb-1.3.17~271 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=108aca0a9e71f2efb699dfeb5e3a1d7e24002de7;p=thirdparty%2Fsamba.git ctdb-event: Declare and construct data_script only if needed Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c index 8350f202cea..b5972793fdb 100644 --- a/ctdb/event/event_tool.c +++ b/ctdb/event/event_tool.c @@ -515,7 +515,7 @@ static int event_command_script_enable(TALLOC_CTX *mem_ctx, struct event_tool_context *ctx = talloc_get_type_abort( private_data, struct event_tool_context); struct stat statbuf; - char *script, *etc_script, *data_script; + char *script, *etc_script; int ret; if (argc != 2) { @@ -533,11 +533,6 @@ static int event_command_script_enable(TALLOC_CTX *mem_ctx, return ENOMEM; } - data_script = path_datadir_append(mem_ctx, script); - if (data_script == NULL) { - return ENOMEM; - } - ret = lstat(etc_script, &statbuf); if (ret == 0) { if (S_ISLNK(statbuf.st_mode)) { @@ -555,6 +550,13 @@ static int event_command_script_enable(TALLOC_CTX *mem_ctx, return EINVAL; } else { if (errno == ENOENT) { + char *data_script; + + data_script = path_datadir_append(mem_ctx, script); + if (data_script == NULL) { + return ENOMEM; + } + ret = stat(data_script, &statbuf); if (ret != 0) { printf("Script %s does not exist in %s\n",