From: Eric Bollengier Date: Fri, 8 Oct 2021 14:23:57 +0000 (+0200) Subject: Add new SECURITY object to be stored in the catalog X-Git-Tag: Beta-15.0.0~849 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b53a34cc354076bec00c772bf1bc243660f438d;p=thirdparty%2Fbacula.git Add new SECURITY object to be stored in the catalog --- diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 727198723..00614d329 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -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; diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 8fcc986cf..51034fb4a 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -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; diff --git a/bacula/src/filed/fd_plugins.c b/bacula/src/filed/fd_plugins.c index a092e7dc9..9f1dc1dc7 100644 --- a/bacula/src/filed/fd_plugins.c +++ b/bacula/src/filed/fd_plugins.c @@ -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; diff --git a/bacula/src/filed/fd_plugins.h b/bacula/src/filed/fd_plugins.h index 27329aa1a..bd0950fa0 100644 --- a/bacula/src/filed/fd_plugins.h +++ b/bacula/src/filed/fd_plugins.h @@ -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; diff --git a/bacula/src/filed/verify.c b/bacula/src/filed/verify.c index 20021e7f8..bfcb9b975 100644 --- a/bacula/src/filed/verify.c +++ b/bacula/src/filed/verify.c @@ -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: { diff --git a/bacula/src/filetypes.h b/bacula/src/filetypes.h index c72752561..f6426ecf6 100644 --- a/bacula/src/filetypes.h +++ b/bacula/src/filetypes.h @@ -71,12 +71,13 @@ #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 */