From: Kern Sibbald Date: Fri, 14 Dec 2007 16:10:52 +0000 (+0000) Subject: Apply patch from Michael Stapelberg X-Git-Tag: Release-3.0.0~2142 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=05590aec905c4819638be9f8655b96207a6d069d;p=bacula%2Fbacula Apply patch from Michael Stapelberg that implements double quoting include names in conf files, and also allows piping input by having the first character be a vertical bar (|). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6066 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/AUTHORS b/bacula/AUTHORS index 6a013edcd6..f188694af8 100644 --- a/bacula/AUTHORS +++ b/bacula/AUTHORS @@ -62,8 +62,9 @@ Marc Cousin Marc Schiffbauer Martin Simmons Meno Abels -Michael -buk- Scherer Michael Renner +Michael -buk- Scherer +Michael Stapelberg Michel Meyers Morgan Nic Bellamy diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index 3a4262ed22..d70c0d8061 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -297,6 +297,8 @@ static const char *lex_state_to_str(int state) case lex_identifier: return _("identifier"); case lex_string: return _("string"); case lex_quoted_string: return _("quoted_string"); + case lex_include: return _("include"); + case lex_include_quoted_string: return _("include_quoted_string"); case lex_utf8_bom: return _("UTF-8 Byte Order Mark"); case lex_utf16_le_bom: return _("UTF-16le Byte Order Mark"); default: return "??????"; @@ -567,11 +569,49 @@ lex_get_token(LEX *lf, int expect) } add_str(lf, ch); break; + case lex_include_quoted_string: + if (ch == L_EOF) { + token = T_ERROR; + break; + } + if (esc_next) { + add_str(lf, ch); + esc_next = false; + break; + } + if (ch == '\\') { + esc_next = true; + break; + } + if (ch == '"') { + /* Keep the original LEX so we can print an error if the included file can't be opened. */ + LEX* lfori = lf; + /* Skip the double quote when restarting parsing */ + lex_get_char(lf); + + lf->state = lex_none; + lf = lex_open_file(lf, lf->str, lf->scan_error); + if (lf == NULL) { + berrno be; + scan_err2(lfori, _("Cannot open included config file %s: %s\n"), + lfori->str, be.bstrerror()); + return T_ERROR; + } + break; + } + add_str(lf, ch); + break; case lex_include: /* scanning a filename */ if (ch == L_EOF) { token = T_ERROR; break; } + if (ch == '"') { + lf->state = lex_include_quoted_string; + break; + } + + if (B_ISSPACE(ch) || ch == '\n' || ch == L_EOL || ch == '}' || ch == '{' || ch == ';' || ch == ',' || ch == '"' || ch == '#') { /* Keep the original LEX so we can print an error if the included file can't be opened. */ diff --git a/bacula/src/lib/lex.h b/bacula/src/lib/lex.h index 513ad6188d..25544b568f 100644 --- a/bacula/src/lib/lex.h +++ b/bacula/src/lib/lex.h @@ -85,6 +85,7 @@ enum lex_state { lex_identifier, lex_string, lex_quoted_string, + lex_include_quoted_string, lex_include, lex_utf8_bom, /* we are parsing out a utf8 byte order mark */ lex_utf16_le_bom /* we are parsing out a utf-16 (little endian) byte order mark */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index de4d9708af..65c1f273e1 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -2,6 +2,10 @@ General: 14Dec07 +kes Apply patch from Michael Stapelberg + that implements double quoting include names in conf files, + and also allows piping input by having the first character + be a vertical bar (|). kes Apply patch from Bastian Friedrich that implement %f in RunScripts to pass the FileSet name. kes Skip leading | when lex input comes from a pipe as suggested