]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add support for PluginOptions
authorEric Bollengier <eric@baculasystems.com>
Mon, 11 Oct 2021 08:27:08 +0000 (10:27 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:55 +0000 (13:56 +0200)
bacula/src/filed/fd_plugins.c
bacula/src/filed/fd_plugins.h
bacula/src/filed/filed_conf.c
bacula/src/filed/job.c
bacula/src/filed/verify_vol.c
bacula/src/plugins/fd/antivirus-fd.c
bacula/src/plugins/fd/test-verify-fd.c

index 9f1dc1dc795830450a4119650757e42fc8af3310..187b6ef3a259648c0fb543866a57fb90e99af427 100644 (file)
@@ -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)) {
index bd0950fa0cf1ac0af8ed170921cac0c19f0889f8..e27e1fdff527ede38323610b248409bf8dd69bee 100644 (file)
@@ -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;
 
 
index 363a1d8818db12f8a60245ab98d3c7794624cd30..882ec8986b3ba459f271dfe27397027747010dd9 100644 (file)
@@ -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},
index 354dedf85418524d1b5773df87101e223f2179e5..9a1beea9f2322e0f793f4d8c308fce20c4615460 100644 (file)
@@ -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;
    }
index 889ab42fafafda56edeefd44127d6998b2ecbd7c..793a2ad75d5fb6b989da9beed5695c8205c89146 100644 (file)
@@ -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);
       }
    }
 
index 1f75d334cc8c46cf10da8c274eee5d6b302100a8..443deba090459a4e06df6baae5acb34185fc4e78 100644 (file)
@@ -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);
index 0830c76fbf230bdbec716b6a39f60696a5a19905..417238a922a734c84f8fb6b9d1bc4d9810ad55f1 100644 (file)
@@ -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);