ctdbd: Complain loudly if CTDB_DEBUG_HUNG_SCRIPT script isn't executable
authorMartin Schwenke <martin@meltin.net>
Tue, 5 Feb 2013 03:25:01 +0000 (14:25 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Tue, 5 Feb 2013 05:05:13 +0000 (16:05 +1100)
This is quite easy to misconfigure by failing to set the execute bit
on the script.  Better to complain loudly.

This is a debugging facilty rather than core CTDB functionality, so it
doesn't need a subtle mechanism to disable it at run-time.  To disable
the designated script at run-time either edit it to put an "exit 0" at
the top or move it aside and symlink to /bin/true.

This is implemented by actually removing the code that checks that the
file exists and is executable.  The output from the shell when the
system() function fails is just as useful.

Signed-off-by: Martin Schwenke <martin@meltin.net>
server/eventscript.c

index 24183a41e4c95821da9b903b830f6c45f32fcceb..ae744c834bdfb47466668b6b550b7ab9eee47a8c 100644 (file)
@@ -531,24 +531,12 @@ static void ctdb_run_debug_hung_script(struct ctdb_context *ctdb, struct ctdb_ev
                return;
        }
        if (pid == 0) {
-               struct stat st;
                char buf[200];
 
                if (getenv("CTDB_DEBUG_HUNG_SCRIPT") != NULL) {
                        debug_hung_script = getenv("CTDB_DEBUG_HUNG_SCRIPT");
                }
 
-               if (stat(debug_hung_script, &st) != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to stat the script to debug hung eventscript. Is it not installed correctly? (script:%s)\n", debug_hung_script));
-                       ctdb_kill(state->ctdb, state->child, SIGTERM);
-                       _exit(0);
-               }               
-               if (!(st.st_mode & S_IXUSR)) {
-                       DEBUG(DEBUG_DEBUG,("Debug script %s is not executable.\n", debug_hung_script));
-                       ctdb_kill(state->ctdb, state->child, SIGTERM);
-                       _exit(0);
-               }
-
                sprintf(buf, "%s %d", debug_hung_script, state->child);
                system(buf);