From: Alain Spineux Date: Thu, 16 Jul 2020 14:46:09 +0000 (+0200) Subject: Allow backtrace to work before the load of the config file X-Git-Tag: Release-11.3.2~852 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87dfca9748d9c044b76c96608292a512848950a1;p=thirdparty%2Fbacula.git Allow backtrace to work before the load of the config file - working_directory is NULL until the config file has been loaded - there was a bug in signal_handler(), working_directory (wd) was set to "buf" and we were doing a snprintf(buf, sizeof(buf), "%s/bacula.%s.traceback", wd, pid_buf); where wd and buf point to the same location, that was generating funny path like /bacula.7647.traceback/bacula.7647.traceback - now we get something like /tmp/bacula.31150.traceback - no need of any check in "btraceback" --- diff --git a/bacula/src/lib/signal.c b/bacula/src/lib/signal.c index 92d77526b..e05a1450c 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -175,17 +175,13 @@ extern "C" void signal_handler(int sig) strcat(exepath, "/"); } strcat(exepath, exename); - if (!working_directory) { - working_directory = buf; - *buf = 0; - } - if (*working_directory == 0) { - strcpy((char *)working_directory, "/tmp/"); + if (working_directory == NULL) { + // We are still in the initialization part, working_directory is NULL + working_directory = "/tmp"; } if (chdir(working_directory) != 0) { /* dump in working directory */ berrno be; Pmsg2(000, "chdir to %s failed. ERR=%s\n", working_directory, be.bstrerror()); - strcpy((char *)working_directory, "/tmp/"); } unlink("./core"); /* get rid of any old core file */