Minor panic_action fixes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 26 Jan 2014 17:29:55 +0000 (17:29 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 26 Jan 2014 17:30:03 +0000 (17:30 +0000)
raddb/radiusd.conf.in
src/lib/debug.c
src/main/radiusd.c

index 37a4ec3..09b7f1b 100644 (file)
@@ -122,7 +122,7 @@ pidfile = ${run_dir}/${name}.pid
 #  panic_action: Command to execute on server fault.
 #
 #  WARNING: DO NOT SET A PANIC ACTION ON PRODUCTION SERVERS WHICH DOES
-#  WARNING: NOT IMMEDIATELY RETURN.  DOING SO MAY PREVENT YOUR server
+#  WARNING: NOT IMMEDIATELY RETURN.  DOING SO MAY PREVENT YOUR SERVER
 #  WARNING: FROM RESTARTING.
 #
 #  Sets a command which will be executed if the server receives a fatal,
@@ -136,12 +136,12 @@ pidfile = ${run_dir}/${name}.pid
 #  - %e   The currently executing program e.g. /sbin/radiusd
 #  - %p   The PID of the currently executing program e.g. 12345
 #
-#  Standard ${} syntax substitutions are also allowed.
+#  Standard ${} substitutions are also allowed.
 #
-#  An example for opening an interactive session in GDB would be:
+#  An example panic action for opening an interactive session in GDB would be:
 #panic_action = "gdb %e %p"
 #
-#  An example for opening an automated session in GDB would be:
+#  An example panic action for opening an automated session in GDB would be:
 #panic_action = "gdb -silent -x ${raddbdir}/panic.gdb %e %p > ${logdir}/gdb.log 2>&1"
 
 #  max_request_time: The maximum time (in seconds) to handle a request.
index ee65ed8..3f42397 100644 (file)
@@ -280,6 +280,7 @@ static void NEVER_RETURNS _fr_fault(int sig)
  * @param cmd to execute on fault. If present %p will be substituted
  *        for the parent PID before the command is executed, and %e
  *        will be substituted for the currently running program.
+ * @param program Name of program currently executing (argv[0]).
  * @return 0 on success -1 on failure.
  */
 int fr_fault_setup(char const *cmd, char const *program)
@@ -292,7 +293,7 @@ int fr_fault_setup(char const *cmd, char const *program)
                p = strstr(cmd, "%e");
                if (p) {
                        snprintf(panic_action, sizeof(panic_action), "%.*s%s%s",
-                                (int)(p - cmd), cmd, program, p + 2);
+                                (int)(p - cmd), cmd, program ? program : "", p + 2);
                } else {
                        strlcpy(panic_action, cmd, sizeof(panic_action));
                }
index a09c83a..5b20248 100644 (file)
@@ -107,6 +107,13 @@ int main(int argc, char *argv[])
        int flag = 0;
        int from_child[2] = {-1, -1};
 
+       /*
+        *      If the server was built with debugging enabled always install
+        *      the basic fatal signal handlers.
+        */
+#ifndef NDEBUG
+       fr_fault_setup(NULL, NULL);
+#endif
 
 #ifdef OSFC2
        set_auth_parameters(argc,argv);