From 9737059e51dc668e61dc59a4348b0ef170dde0ea Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 18 Jul 2016 17:12:05 +0200 Subject: [PATCH] Allow multiple mailcommand+operatorcommand in Messages. Fixes bug #2222 --- bacula/src/lib/parse_conf.c | 8 ++++++-- bacula/src/lib/parse_conf.h | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index dad7f5c30b..c00a4e642e 100644 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -91,8 +91,8 @@ static bool find_config_file(const char *config_file, char *full_path, int max_p RES_ITEM msgs_items[] = { {"Name", store_name, ITEM(res_msgs.hdr.name), 0, 0, 0}, {"Description", store_str, ITEM(res_msgs.hdr.desc), 0, 0, 0}, - {"MailCommand", store_str, ITEM(res_msgs.mail_cmd), 0, 0, 0}, - {"OperatorCommand", store_str, ITEM(res_msgs.operator_cmd), 0, 0, 0}, + {"MailCommand", store_str, ITEM(res_msgs.mail_cmd), 0, ITEM_ALLOW_DUPS, 0}, + {"OperatorCommand", store_str, ITEM(res_msgs.operator_cmd), 0, ITEM_ALLOW_DUPS, 0}, {"Syslog", store_msgs, ITEM(res_msgs), MD_SYSLOG, 0, 0}, {"Mail", store_msgs, ITEM(res_msgs), MD_MAIL, 0, 0}, {"MailOnError", store_msgs, ITEM(res_msgs), MD_MAIL_ON_ERROR, 0, 0}, @@ -404,6 +404,10 @@ void store_str(LEX *lc, RES_ITEM *item, int index, int pass) { lex_get_token(lc, T_STRING); if (pass == 1) { + if (*(item->value) && (item->flags & ITEM_ALLOW_DUPS)) { + free(*(item->value)); + *(item->value) = NULL; + } 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); diff --git a/bacula/src/lib/parse_conf.h b/bacula/src/lib/parse_conf.h index 9b147d6fc4..5ae4c74172 100644 --- a/bacula/src/lib/parse_conf.h +++ b/bacula/src/lib/parse_conf.h @@ -119,10 +119,12 @@ struct RES_TABLE { #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1 /* maximum resource name length */ -#define ITEM_REQUIRED 0x1 /* item required */ -#define ITEM_DEFAULT 0x2 /* default supplied */ -#define ITEM_NO_EQUALS 0x4 /* Don't scan = after name */ -#define ITEM_LAST 0x8 /* Last item in list */ +/* Permitted bits in Flags field */ +#define ITEM_REQUIRED (1<<0) /* item required */ +#define ITEM_DEFAULT (1<<1) /* default supplied */ +#define ITEM_NO_EQUALS (1<<2) /* Don't scan = after name */ +#define ITEM_LAST (1<<3) /* Last item in list */ +#define ITEM_ALLOW_DUPS (1<<4) /* Allow duplicate directives */ /* Message Resource */ class MSGS { -- 2.39.5