]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Add new SECURITY object to be stored in the catalog
authorEric Bollengier <eric@baculasystems.com>
Fri, 8 Oct 2021 14:23:57 +0000 (16:23 +0200)
committerEric Bollengier <eric@baculasystems.com>
Wed, 6 Sep 2023 07:49:01 +0000 (09:49 +0200)
bacula/src/dird/ua_output.c
bacula/src/filed/backup.c
bacula/src/filed/fd_plugins.c
bacula/src/filed/fd_plugins.h
bacula/src/filed/verify.c
bacula/src/filetypes.h

index 727198723c6505f412347bc3107a05a3b47f5a97..00614d329a527426163d617c31b7de52a450e17d 100644 (file)
@@ -683,6 +683,9 @@ static int do_list_cmd(UAContext *ua, const char *cmd, e_list_type llist)
                } else if (strcasecmp(ua->argv[j], NT_("RESTORE_FIRST")) == 0) {
                   rr.FileType = FT_RESTORE_FIRST;
 
+               } else if (strcasecmp(ua->argv[j], NT_("SECURITY")) == 0) {
+                  rr.FileType = FT_SECURITY_OBJECT;
+
                } else if (strcasecmp(ua->argv[j], NT_("ALL")) == 0) {
                   rr.FileType = 0;
 
index 8fcc986cf19c960216a9a85debb184541a321545..51034fb4ad9a5b8c4380d6cc256212493d175696 100644 (file)
@@ -367,6 +367,9 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
    case FT_LNK:
       Dmsg2(130, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link);
       break;
+   case FT_SECURITY_OBJECT:
+      Dmsg1(100, "FT_SECURITY_OBJECT saving: %s\n", ff_pkt->fname);
+      break;
    case FT_RESTORE_FIRST:
       Dmsg1(100, "FT_RESTORE_FIRST saving: %s\n", ff_pkt->fname);
       break;
@@ -1144,6 +1147,7 @@ bool encode_and_send_attributes(bctx_t &bctx)
                        ff_pkt->type, ff_pkt->link, 0, attribs, 0, 0,
                        attribsEx, 0, ff_pkt->delta_seq, 0);
       break;
+   case FT_SECURITY_OBJECT:
    case FT_PLUGIN_CONFIG:
    case FT_RESTORE_FIRST:
       comp_len = ff_pkt->restore_obj.object_len;
index a092e7dc9a3444b53d46dd627255ccf1ab5fa20b..9f1dc1dc795830450a4119650757e42fc8af3310 100644 (file)
@@ -76,6 +76,7 @@ static bRC baculaCheckChanges(bpContext *ctx, struct save_pkt *sp);
 static bRC baculaAcceptFile(bpContext *ctx, struct save_pkt *sp);
 static bRC baculaAccurateAttribs(bpContext *ctx, accurate_attribs_pkt *att);
 static void plugin_register_verify_data(bpContext *ctx);
+static bRC baculaAddPlugin(bpContext *ctx, const char *file);
 
 /*
  * These will be plugged into the global pointer structure for
@@ -116,6 +117,7 @@ static bFuncs bfuncs = {
    baculaCheckChanges,
    baculaAcceptFile,
    baculaAccurateAttribs,
+   baculaAddPlugin
 };
 
 /*
@@ -2265,7 +2267,7 @@ static bRC baculaAddExclude(bpContext *ctx, const char *file)
 }
 
 /**
- * Let the plugin define files/directories to be excluded
+ * Let the plugin define files/directories to be included
  *  from the main backup.
  */
 static bRC baculaAddInclude(bpContext *ctx, const char *file)
@@ -2304,6 +2306,46 @@ static bRC baculaAddInclude(bpContext *ctx, const char *file)
    return bRC_OK;
 }
 
+/**
+ * Let the plugin define plugin to be included
+ *  from the main backup.
+ */
+static bRC baculaAddPlugin(bpContext *ctx, const char *file)
+{
+   JCR *jcr;
+   findINCEXE *old;
+   bacula_ctx *bctx;
+
+   Dsm_check(999);
+   if (!is_ctx_good(ctx, jcr, bctx)) {
+      return bRC_Error;
+   }
+   if (!file) {
+      return bRC_Error;
+   }
+
+   /* Save the include context */
+   old = get_incexe(jcr);
+
+   /* Not right time to add include */
+   if (!old) {
+      return bRC_Error;
+   }
+   if (!bctx->include) {
+      bctx->include = old;
+   }
+
+   set_incexe(jcr, bctx->include);
+   add_file_to_fileset(jcr, file, false);
+
+   /* Restore the current context */
+   set_incexe(jcr, old);
+
+   Dmsg1(100, "Add include file=%s\n", file);
+   Dsm_check(999);
+   return bRC_OK;
+}
+
 static bRC baculaAddOptions(bpContext *ctx, const char *opts)
 {
    JCR *jcr;
index 27329aa1a4939cc8bbc19a0cad4236fe08abd291..bd0950fa0cf1ac0af8ed170921cac0c19f0889f8 100644 (file)
@@ -551,6 +551,8 @@ typedef struct s_baculaFuncs {
    bRC (*checkChanges)(bpContext *ctx, struct save_pkt *sp);
    bRC (*AcceptFile)(bpContext *ctx, struct save_pkt *sp); /* Need fname and statp */
    bRC (*getAccurateAttribs)(bpContext *ctx, accurate_attribs_pkt *att);
+   bRC (*AddPlugin)(bpContext *ctx, const char *file);
+
 } bFuncs;
 
 
index 20021e7f807ba2992acfa7438f3593f5accab053..bfcb9b975bc8e24689f1d74c1efdb17f9b7fcb77 100644 (file)
@@ -154,6 +154,7 @@ static int verify_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level)
       Jmsg(jcr, M_SKIPPED, 1, _("     File system change prohibited. Directory skipped: %s\n"), ff_pkt->fname);
       return 1;
    case FT_PLUGIN_CONFIG:
+   case FT_SECURITY_OBJECT:
    case FT_RESTORE_FIRST:
       return 1;                       /* silently skip */
    case FT_NOOPEN: {
index c72752561a1af5e1f7d906165090956066db7809..f6426ecf676afe5080bfe4c45dc6fee403fbe143 100644 (file)
 #define FT_PLUGIN_CONFIG 27           /* Object for Plugin configuration */
 #define FT_PLUGIN_CONFIG_FILLED 28    /* Object for Plugin configuration filled by Director */
 #define FT_PLUGIN_OBJECT 29           /* Opaque Plugin Object used for Object Management*/
+#define FT_SECURITY_OBJECT 30         /* Security report */
 
 /* Definitions for upper part of type word (see above). */
 #define AR_DATA_STREAM (1<<16)        /* Data stream id present */
 
 /* Quick way to know if a Filetype is about a plugin "Object" */
 #define IS_FT_OBJECT(x) (((x) == FT_RESTORE_FIRST) || ((x) == FT_PLUGIN_CONFIG_FILLED) || ((x) == FT_PLUGIN_CONFIG) \
-                           || ((x) == FT_PLUGIN_OBJECT))
+                         || ((x) == FT_PLUGIN_OBJECT) || ((x) == FT_SECURITY_OBJECT))
 
 #endif /* __BFILETYPES_H */