From: Eric Bollengier Date: Mon, 11 Oct 2021 08:27:08 +0000 (+0200) Subject: Add support for PluginOptions X-Git-Tag: Beta-15.0.0~844 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f56b8421129870a9ce13adbecf114da4ecbabce5;p=thirdparty%2Fbacula.git Add support for PluginOptions --- diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index 9f1dc1dc7..187b6ef3a 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -214,6 +214,7 @@ void generate_plugin_event(JCR *jcr, bEventType eventType, void *value) */ switch(eventType) { case bEventPluginCommand: + case bEventPluginOptions: case bEventOptionPlugin: name = (char *)value; if (!get_plugin_name(jcr, name, &len)) { diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index bd0950fa0..e27e1fdff 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -468,6 +468,7 @@ typedef enum { bEventComponentInfo = 25, /* Plugin component */ bEventFeatures = 26, /* Ask for file list, ... "xxx,yyy,zzz" */ bEventVerifyStream = 27, /* Register to get a copy of the data stream during verify */ + bEventPluginOptions = 28, /* Sent when starting the job */ } bEventType; diff --git a/bacula/src/filed/filed_conf.c b/bacula/src/filed/filed_conf.c index 363a1d881..882ec8986 100644 --- a/bacula/src/filed/filed_conf.c +++ b/bacula/src/filed/filed_conf.c @@ -87,7 +87,7 @@ static RES_ITEM cli_items[] = { {"PidDirectory", store_dir, ITEM(res_client.pid_directory), 0, ITEM_REQUIRED, 0}, {"SubsysDirectory", store_dir, ITEM(res_client.subsys_directory), 0, 0, 0}, {"PluginDirectory", store_dir, ITEM(res_client.plugin_directory), 0, 0, 0}, - {"Plugin", store_alist_str, ITEM(res_client.plugins), 0, 0, 0}, + {"PluginOptions", store_alist_str, ITEM(res_client.plugins), 0, 0, 0}, {"SnapshotCommand", store_str, ITEM(res_client.snapshot_command), 0, 0, 0}, {"ScriptsDirectory", store_dir, ITEM(res_client.scripts_directory), 0, 0, 0}, {"MaximumConcurrentJobs", store_pint32, ITEM(res_client.MaxConcurrentJobs), 0, ITEM_DEFAULT, 20}, diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 354dedf85..9a1beea9f 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -2468,6 +2468,7 @@ static int fileset_cmd(JCR *jcr) POOL_MEM buf(PM_MESSAGE); BSOCK *dir = jcr->dir_bsock; int rtnstat; + char *p; #if HAVE_WIN32 jcr->Snapshot = (strstr(dir->msg, "vss=1") != NULL); @@ -2483,6 +2484,12 @@ static int fileset_cmd(JCR *jcr) pm_strcpy(buf, dir->msg); add_fileset(jcr, buf.c_str()); } + /* Foreach special configuration in the FD, we call the PluginOption event */ + if (me->plugins) { + foreach_alist(p, me->plugins) { + generate_plugin_event(jcr, bEventPluginOptions, (void *)p); + } + } if (!term_fileset(jcr)) { return 0; } diff --git a/bacula/src/filed/verify_vol.c b/bacula/src/filed/verify_vol.c index 889ab42fa..793a2ad75 100644 --- a/bacula/src/filed/verify_vol.c +++ b/bacula/src/filed/verify_vol.c @@ -273,7 +273,7 @@ void do_verify_volume(JCR *jcr) if (jcr->plugin_options_list) { foreach_alist(opts, jcr->plugin_options_list) { - generate_plugin_event(jcr, bEventPluginCommand, (void *)opts); + generate_plugin_event(jcr, bEventPluginOptions, (void *)opts); } } diff --git a/bacula/src/plugins/fd/antivirus-fd.c b/bacula/src/plugins/fd/antivirus-fd.c index 1f75d334c..443deba09 100644 --- a/bacula/src/plugins/fd/antivirus-fd.c +++ b/bacula/src/plugins/fd/antivirus-fd.c @@ -227,7 +227,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) */ switch (event->eventType) { - case bEventPluginCommand: + case bEventPluginOptions: Jmsg(ctx, M_INFO, "Got plugin command = %s\n", (char *)value); self->parse_cmd((char *)value); bfuncs->registerBaculaEvents(ctx, bEventVerifyStream); diff --git a/bacula/src/plugins/fd/test-verify-fd.c b/bacula/src/plugins/fd/test-verify-fd.c index 0830c76fb..417238a92 100644 --- a/bacula/src/plugins/fd/test-verify-fd.c +++ b/bacula/src/plugins/fd/test-verify-fd.c @@ -222,7 +222,7 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) */ switch (event->eventType) { - case bEventPluginCommand: + case bEventPluginOptions: Jmsg(ctx, M_INFO, "Got plugin command = %s\n", (char *)value); self->parse_cmd((char *)value); bfuncs->registerBaculaEvents(ctx, bEventVerifyStream);