From: Eric Bollengier Date: Tue, 12 May 2020 17:02:16 +0000 (+0200) Subject: BEE Backport bacula/src/stored/job.c X-Git-Tag: Release-11.3.2~1646 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66d2d1f4e317320f276ca81de97850da86e75190;p=thirdparty%2Fbacula.git BEE Backport bacula/src/stored/job.c This commit is the result of the squash of the following main commits: Author: Eric Bollengier Date: Fri Apr 24 20:16:22 2020 +0200 Reliably log user activity in a way that satisfies auditors Messages { name = Standard append = /tmp/bacula.log = all # To send the events into a log and in the catalog append = /tmp/audit.log = events, !events.bweb catalog = all, events } Users can create custom events with a console command: .events They can list events in the catalog with * list events +---------------------+------------+-----------+--------------------------------+ | time | type | source | events | +---------------------+------------+-----------+--------------------------------+ | 2020-04-24 17:04:07 | daemon | *Daemon* | Director startup | | 2020-04-24 17:04:12 | connection | *Console* | Connection from 127.0.0.1:8101 | | 2020-04-24 17:04:20 | command | *Console* | purge jobid=1 | +---------------------+------------+-----------+--------------------------------+ The event format in the log is: 24-Apr 17:04 Events: code=DC0001 from=zog8-dir ref=0x1fa5 type=daemon source=*Daemon* text=Director startup 24-Apr 17:04 Events: code=DC0002 from=zog8-dir ref=0x7fb58000c4b8 type=connection source=*Console* text=Connection from 127.0.0.1:8101 The reference (ref) is used to identify a console session, all activity from the same console will have the same reference. The source is the name of the restricted console, or *Console* if this is the default console. We have the following events: - cancel a job - delete volume - delete job - purge job - delete pool - delete client - daemon startup - daemon shutdown - console connection - console disconnection To add a new events: ua->send_events(type, format, arguments); Author: Kern Sibbald Date: Mon Aug 6 13:51:29 2018 +0200 Add M_SECURITY when connection is bad + fix bug where invalid probes sent to Dir Author: Eric Bollengier Date: Mon Aug 28 17:01:40 2017 +0200 Write the list of selected files to a temporary file if requested by a Plugin If we find a RestoreObject with the type FT_PLUGIN_FILELIST, we list all selected files in a temporary file to send it to the FD before the actual restore as a RestoreObject. Author: Eric Bollengier Date: Tue May 17 11:16:02 2016 +0200 Add BEEF marks for FileMedia feature Author: Eric Bollengier Date: Tue Apr 5 18:55:10 2016 +0200 Implement FileMedia feature and FO_OFFSETS for plugin - Allow plugins to use the FO_OFFSETS option - Add SQL support in cats - Add bvfs commands - Add FileMedia handling in the Storage Daemon - Add use FO_OFFSETS option in test plugin - Add new sql scripts to configure.in - Update catalog version to 1018 Author: Kern Sibbald Date: Sat Feb 1 23:16:04 2014 +0100 Implement SD-SD migrate/copy code Author: Kern Sibbald Date: Sat Jul 20 18:55:54 2013 +0200 Fix seg fault bug 7901 bsock released during cancel --- diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 22eaeec36a..79a22e86d0 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -164,6 +164,10 @@ bool job_cmd(JCR *jcr) new_plugins(jcr); /* instantiate the plugins */ generate_daemon_event(jcr, "JobStart"); generate_plugin_event(jcr, bsdEventJobStart, (void *)"JobStart"); + + /* Keep track of the important events */ + events_send_msg(jcr, "SJ0001", EVENTS_TYPE_JOB, jcr->director->hdr.name, (intptr_t)jcr, + "Job Start jobid=%d job=%s", jcr->JobId, jcr->Job); return true; } @@ -177,10 +181,7 @@ bool run_cmd(JCR *jcr) Dsm_check(200); Dmsg1(200, "Run_cmd: %s\n", jcr->dir_bsock->msg); - /* - * If we do not need the FD, - * we are doing a migration, copy, or virtual backup. - */ + /* If we do not need the FD, we are doing a virtual backup. */ if (jcr->no_client_used()) { do_vbackup(jcr); return false; @@ -236,7 +237,7 @@ bool run_cmd(JCR *jcr) memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); if (jcr->authenticated && !job_canceled(jcr)) { - Dmsg2(050, "Running jid=%d %p\n", jcr->JobId, jcr); + Dmsg2(800, "Running jid=%d %p\n", jcr->JobId, jcr); run_job(jcr); /* Run the job */ } Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr); @@ -328,17 +329,13 @@ void stored_free_jcr(JCR *jcr) flush_jobmedia_queue(jcr); delete jcr->jobmedia_queue; jcr->jobmedia_queue = NULL; - } - if (jcr->dir_bsock) { - Dmsg2(800, "Send terminate jid=%d %p\n", jcr->JobId, jcr); - jcr->dir_bsock->signal(BNET_EOD); - jcr->dir_bsock->signal(BNET_TERMINATE); - jcr->dir_bsock->destroy(); - } - if (jcr->file_bsock) { - jcr->file_bsock->destroy(); + /* ***BEEF*** */ + delete jcr->filemedia_queue; + jcr->filemedia_queue = NULL; } + free_bsock(jcr->file_bsock); + free_bsock(jcr->dir_bsock); if (jcr->job_name) { free_pool_memory(jcr->job_name); } @@ -360,8 +357,7 @@ void stored_free_jcr(JCR *jcr) free_restore_volume_list(jcr); if (jcr->RestoreBootstrap) { unlink(jcr->RestoreBootstrap); - free_pool_memory(jcr->RestoreBootstrap); - jcr->RestoreBootstrap = NULL; + bfree_and_null(jcr->RestoreBootstrap); } if (jcr->next_dev || jcr->prev_dev) { Qmsg0(NULL, M_FATAL, 0, _("In free_jcr(), but still attached to device!!!!\n"));