Bacula-users

Re: [Bacula-users] Admin Job with console command crashing director

2013-04-18 19:17:51
Subject: Re: [Bacula-users] Admin Job with console command crashing director
From: Marcin Haba <ganiuszka AT gmail DOT com>
To: Ana Emília Machado de Arruda <emiliaarruda AT gmail DOT com>
Date: Fri, 19 Apr 2013 01:13:21 +0200
2013/4/17 Ana Emília Machado de Arruda <emiliaarruda AT gmail DOT com>:
> Hello,
>
> I´m trying to run a console command from an admin job and this is crashing
> my director. A simple Console = "list jobs", inside a RunScript directive,
> crashes the director (bacula-dir dead but subsys locked) and it generates a
> "Bacula GDB traceback of bacula-dir on myDirector" mail.
>
> Below is my Admin Job with a "list jobs" console command. My goal is a "list
> nextvol job=\"my\job\" days=1" command. Tried "list jobs", "list clients",
> and so on, all of them result in the same. When it runs on client side this
> does not happen. When I enter bconsole after restarting bacula, I get the
> messages:
>
> 17-Apr 17:24 myDirector-dir JobId 17821: console command: run BeforeJob
> "list jobs"
> 17-Apr 17:24 myDirector-dir JobId 0: Automatically selected Catalog:
> MyCatalog
> 17-Apr 17:24 myDirector-dir JobId 0: Using Catalog "MyCatalog"
>

Hi,

I have the same result as yours. After adding listing command as
runscript console command, Bacula throws segmentation violation.

I researched this problem. It seems that in:
/usr/src/bacula-5.2.12-new/src/cats/sql.c lines 636-642:

   Dmsg0(800, "list_result finished first loop\n");
   if (type == VERT_LIST) {
      goto vertical_list;
   }

   Dmsg1(800, "list_result starts second loop looking at %d fields\n",
num_fields);
   list_dashes(mdb, send, ctx);
                          ^^^
variable ctx is broken, so it is not able to run list_dashes() without error.

It looks like runscript directives were designed for run shell
scripts/programs or bconsole commands which do not show results in
tabular output. It makes sense.

Summing, you found bug in Bacula.

I prepared patch for this. It blocks running bconsole output for
runscript. It works for me but I am not C++ programmer. Finally it
does not cause segmentation violation and Director crash. I am
attaching it to this message.

For your solution I think that better will be to put your bconsole
requests in a shell script.

Regards,
Marcin Haba (gani)

Attachment: bacula-runscript-listing-segfault.patch
Description: Binary data

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users