From ddf24235c316c73a1f29fd7c6f6306e7fb8da7db Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 13 Oct 2008 15:48:21 +0000 Subject: [PATCH] kes Change IncludeDir to Exclude Dir Containing. kes Implement code to prohibit ExcludeDirContaining in an Exclude section (same for Plugin and Options). A bit of a kludge with RES_ITEM2 ... git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7775 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/dird_conf.c | 2 +- bacula/src/dird/inc_conf.c | 46 ++++++++++++++++++++++------------- bacula/src/findlib/find_one.c | 8 +++--- bacula/src/lib/parse_conf.h | 23 ++++++++++++++++++ bacula/technotes-2.5 | 4 +++ 5 files changed, 61 insertions(+), 22 deletions(-) diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 31c04092f6..80d7c77df3 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -491,7 +491,7 @@ struct s_jt migtypes[] = { {"oldestvolume", MT_OLDEST_VOL}, {"pooloccupancy", MT_POOL_OCCUPANCY}, {"pooltime", MT_POOL_TIME}, - {"pooluncopiedjobs", MT_POOL_UNCOPIED_JOBS}, + {"pooluncopiedjobs", MT_POOL_UNCOPIED_JOBS}, {"client", MT_CLIENT}, {"volume", MT_VOLUME}, {"job", MT_JOB}, diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 1372cb8520..7fa7399357 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -52,14 +52,16 @@ static void store_wild(LEX *lc, RES_ITEM *item, int index, int pass); static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass); static void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass); static void store_opts(LEX *lc, RES_ITEM *item, int index, int pass); -static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass); -static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass); -static void options_res(LEX *lc, RES_ITEM *item, int index, int pass); static void store_base(LEX *lc, RES_ITEM *item, int index, int pass); static void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass); -static void store_ignoredir(LEX *lc, RES_ITEM *item, int index, int pass); static void setup_current_opts(void); +/* Include and Exclude items */ +static void store_fname(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude); +static void store_plugin_name(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude); +static void options_res(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude); +static void store_excludedir(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude); + /* We build the current resource here as we are * scanning the resource configuration definition, @@ -82,10 +84,10 @@ static INCEXE res_incexe; * new Include/Exclude items * name handler value code flags default_value */ -static RES_ITEM newinc_items[] = { +static RES_ITEM2 newinc_items[] = { {"file", store_fname, {0}, 0, 0, 0}, {"plugin", store_plugin_name, {0}, 0, 0, 0}, - {"ignoredir", store_ignoredir, {0}, 0, 0, 0}, + {"excludedircontaining", store_excludedir, {0}, 0, 0, 0}, {"options", options_res, {0}, 0, 0, 0}, {NULL, NULL, {0}, 0, 0, 0} }; @@ -329,7 +331,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen) /* * * Store FileSet Include/Exclude info - * NEW style includes are handled in store_newinc() + * new style includes are handled in store_newinc() */ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) { @@ -350,7 +352,7 @@ void store_inc(LEX *lc, RES_ITEM *item, int index, int pass) /* - * Store NEW style FileSet FInclude/FExclude info + * Store new style FileSet Include/Exclude info * * Note, when this routine is called, we are inside a FileSet * resource. We treat the Include/Execlude like a sort of @@ -385,7 +387,7 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass) } } /* Call item handler */ - newinc_items[i].handler(lc, &newinc_items[i], i, pass); + newinc_items[i].handler(lc, &newinc_items[i], i, pass, item->code); i = -1; break; } @@ -570,16 +572,17 @@ static void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass) scan_to_eol(lc); } -/* Store ignoredir info */ -static void store_ignoredir(LEX *lc, RES_ITEM *item, int index, int pass) +/* Store exclude directory containing info */ +static void store_excludedir(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude) { int token; + if (exclude) { + scan_err0(lc, _("ExcludeDirContaining directive not permitted in Exclude.\n")); + /* NOT REACHED */ + } token = lex_get_token(lc, T_NAME); if (pass == 1) { - /* - * Pickup reader command - */ res_incexe.current_opts->ignoredir = bstrdup(lc->str); } scan_to_eol(lc); @@ -613,7 +616,7 @@ static void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass) * always increase the name buffer by 10 items because we expect * to add more entries. */ -static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass) +static void store_fname(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude) { int token; INCEXE *incexe; @@ -652,11 +655,15 @@ static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass) * always increase the name buffer by 10 items because we expect * to add more entries. */ -static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass) +static void store_plugin_name(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude) { int token; INCEXE *incexe; + if (exclude) { + scan_err0(lc, _("Plugin directive not permitted in Exclude\n")); + /* NOT REACHED */ + } token = lex_get_token(lc, T_SKIP_EOL); if (pass == 1) { /* Pickup Filename string @@ -681,6 +688,7 @@ static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass) break; default: scan_err1(lc, _("Expected a filename, got: %s"), lc->str); + /* NOT REACHED */ } } scan_to_eol(lc); @@ -691,10 +699,14 @@ static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass) /* * Come here when Options seen in Include/Exclude */ -static void options_res(LEX *lc, RES_ITEM *item, int index, int pass) +static void options_res(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude) { int token, i; + if (exclude) { + scan_err0(lc, _("Options section not permitted in Exclude\n")); + /* NOT REACHED */ + } token = lex_get_token(lc, T_SKIP_EOL); if (token != T_BOB) { scan_err1(lc, _("Expecting open brace. Got %s"), lc->str); diff --git a/bacula/src/findlib/find_one.c b/bacula/src/findlib/find_one.c index 410970071a..57965a16f9 100644 --- a/bacula/src/findlib/find_one.c +++ b/bacula/src/findlib/find_one.c @@ -257,19 +257,19 @@ bool has_file_changed(JCR *jcr, FF_PKT *ff_pkt) } /* - * In incremental/diffential or accurate backup, we - * say if the current file has changed. + * For incremental/diffential or accurate backups, we + * determine if the current file has changed. */ static bool check_changes(JCR *jcr, FF_PKT *ff_pkt) { - /* in special mode (like accurate backup), user can + /* in special mode (like accurate backup), the programmer can * choose his comparison function. */ if (ff_pkt->check_fct) { return ff_pkt->check_fct(jcr, ff_pkt); } - /* in normal modes (incr/diff), we use this default + /* For normal backups (incr/diff), we use this default * behaviour */ if (ff_pkt->incremental && diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index 395dee19d1..99d61ee369 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -34,8 +34,10 @@ */ struct RES_ITEM; /* Declare forward referenced structure */ +struct RES_ITEM2; /* Declare forward referenced structure */ class RES; /* Declare forware referenced structure */ typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass); +typedef void (INC_RES_HANDLER)(LEX *lc, RES_ITEM2 *item, int index, int pass, bool exclude); @@ -64,6 +66,27 @@ struct RES_ITEM { int32_t default_value; /* default value */ }; +struct RES_ITEM2 { + const char *name; /* Resource name i.e. Director, ... */ + INC_RES_HANDLER *handler; /* Routine storing the resource item */ + union { + char **value; /* Where to store the item */ + char **charvalue; + uint32_t ui32value; + int32_t i32value; + uint64_t ui64value; + int64_t i64value; + bool boolvalue; + utime_t utimevalue; + RES *resvalue; + RES **presvalue; + }; + int32_t code; /* item code/additional info */ + uint32_t flags; /* flags: default, required, ... */ + int32_t default_value; /* default value */ +}; + + /* For storing name_addr items in res_items table */ #define ITEM(x) {(char **)&res_all.x} diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 2c289780aa..526b8706d1 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -18,6 +18,10 @@ remove reader/writer in FOPTS???? General: 13Oct08 +kes Change IncludeDir to Exclude Dir Containing. +kes Implement code to prohibit ExcludeDirContaining in an + Exclude section (same for Plugin and Options). A bit + of a kludge with RES_ITEM2 ... ebl Add field to command list to restrict Runscript console command. ebl Use a separate JCR when running Console command with Runscript. -- 2.39.5