]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Allow backtrace to work before the load of the config file
authorAlain Spineux <alain@baculasystems.com>
Thu, 16 Jul 2020 14:46:09 +0000 (16:46 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:58 +0000 (09:02 +0100)
- 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"

bacula/src/lib/signal.c

index 92d77526bea8d8166a4f5f2df43c60010ac89baf..e05a1450c2791e4d9aebc5b3a8d15f3ac57bef9e 100644 (file)
@@ -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 */