From ddf4e3c6aefc9299a79049b78c6540d6059610c8 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 17 Jul 2016 18:21:41 +0200 Subject: [PATCH] Fail when multipl mailcommand and other strings are specified in .conf. Fixes bug #2222 --- bacula/src/lib/parse_conf.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 26d81408da..dad7f5c30b 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -369,8 +369,8 @@ void store_name(LEX *lc, RES_ITEM *item, int index, int pass) free_pool_memory(msg); /* Store the name both pass 1 and pass 2 */ if (*(item->value)) { - scan_err2(lc, _("Attempt to redefine name \"%s\" to \"%s\"."), - *(item->value), lc->str); + scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"), + item->name, *(item->value), lc->str, lc->line_no, lc->line); return; } *(item->value) = bstrdup(lc->str); @@ -388,6 +388,11 @@ void store_strname(LEX *lc, RES_ITEM *item, int index, int pass) lex_get_token(lc, T_NAME); /* Store the name */ if (pass == 1) { + if (*(item->value)) { + scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"), + item->name, *(item->value), lc->str, lc->line_no, lc->line); + return; + } *(item->value) = bstrdup(lc->str); } scan_to_eol(lc); @@ -399,6 +404,11 @@ void store_str(LEX *lc, RES_ITEM *item, int index, int pass) { lex_get_token(lc, T_STRING); if (pass == 1) { + if (*(item->value)) { + scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"), + item->name, *(item->value), lc->str, lc->line_no, lc->line); + return; + } *(item->value) = bstrdup(lc->str); } scan_to_eol(lc); @@ -417,6 +427,11 @@ void store_dir(LEX *lc, RES_ITEM *item, int index, int pass) if (lc->str[0] != '|') { do_shell_expansion(lc->str, sizeof_pool_memory(lc->str)); } + if (*(item->value)) { + scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"), + item->name, *(item->value), lc->str, lc->line_no, lc->line); + return; + } *(item->value) = bstrdup(lc->str); } scan_to_eol(lc); @@ -442,6 +457,11 @@ void store_password(LEX *lc, RES_ITEM *item, int index, int pass) sprintf(&sig[j], "%02x", digest[i]); j += 2; } + if (*(item->value)) { + scan_err5(lc, _("Attempt to redefine \"%s\" from \"%s\" to \"%s\" referenced on line %d : %s\n"), + item->name, *(item->value), lc->str, lc->line_no, lc->line); + return; + } *(item->value) = bstrdup(sig); } scan_to_eol(lc); -- 2.39.5