]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-event: Improve error message
authorMartin Schwenke <mschwenke@ddn.com>
Sat, 11 Oct 2025 04:45:09 +0000 (15:45 +1100)
committerRalph Boehme <slow@samba.org>
Tue, 14 Oct 2025 16:53:36 +0000 (16:53 +0000)
The current message:

  Command script list finished with result=2

does not clearly explain the problem.

Improve it.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
ctdb/event/event_tool.c
ctdb/tests/UNIT/eventd/eventd_001.sh

index baf4763cb1f9dac66213f593be49c46e507a6355..b93b9454ad17fa315750003a65c09b7328c7fbf9 100644 (file)
@@ -385,6 +385,7 @@ static int event_command_script_list(TALLOC_CTX *mem_ctx,
        char *data_dir = NULL;
        char *etc_dir = NULL;
        char *t = NULL;
+       char *real_data_dir = NULL;
        struct event_script_list *data_list = NULL;
        struct event_script_list *etc_list = NULL;
        unsigned int i, j, matched;
@@ -410,14 +411,18 @@ static int event_command_script_list(TALLOC_CTX *mem_ctx,
                return ENOMEM;
        }
 
-       data_dir = realpath(data_dir, t);
-       if (data_dir == NULL) {
+       real_data_dir = realpath(data_dir, t);
+       if (real_data_dir == NULL) {
                if (errno != ENOENT) {
                        return errno;
                }
-               D_ERR("Command script list finished with result=%d\n", ENOENT);
+               D_ERR("Unable to find event script installation directory: %s\n",
+                     data_dir);
                return ENOENT;
        }
+       /* Some static analysers don't understand talloc */
+       TALLOC_FREE(data_dir);
+       data_dir = real_data_dir;
 
        etc_dir = path_etcdir_append(mem_ctx, subdir);
        if (etc_dir == NULL) {
index 7d4ee9e4e919339d66dee60da931dcefc2e26429..2d39ee5ab1b8f0d5ce939b6bcb89f2360d5e353b 100755 (executable)
@@ -21,7 +21,8 @@ Script 01.test does not exist in foobar
 EOF
 simple_test script enable foobar 01.test
 
+dir="${CTDB_BASE}/share/events/foobar"
 required_error ENOENT <<EOF
-Command script list finished with result=$(errcode ENOENT)
+Unable to find event script installation directory: ${dir}
 EOF
 simple_test script list foobar