[Bug 235] New: String arguments to block parameters get mistreated
https://bugzilla.balabit.com/show_bug.cgi?id=235 Summary: String arguments to block parameters get mistreated Product: syslog-ng Version: 3.4.x Platform: All OS/Version: All Status: ASSIGNED Severity: blocker Priority: unspecified Component: syslog-ng AssignedTo: algernon@balabit.hu ReportedBy: algernon@balabit.hu Type of the Report: regression Estimated Hours: 0.0 I'm not quite sure who and where reported this bug first, but I'm recording it within Bugzilla, so we can keep track of it. With the config below, syslog-ng fails to start: ========================================================== @version: 3.5 block source s_logfile (filename(messages)) { file("/var/log/`filename`" ); }; source s_example { s_logfile(filename("logfile.log")); s_logfile(filename(logfile.log)); s_logfile(filename(foo bar baz)); }; ========================================================== Error parsing affile, syntax error, unexpected LL_IDENTIFIER in source block s_logfile at line 2, column 19: included from etc/block-syntax.conf line 8, column 36 file("/var/log/"logfile.log ^^^^^^^^^^^ The first line of s_example makes it fail badly. This is because the lexer recognises "logfile.log" as a block_string, and stores the quotation marks too, therefore the backtick expansion creates an invalid string. We should not store the "s in this case. I managed to bisect this down to cbd8b195e80f54f9b398456d434e39d9d23c2bdd, but have not managed to figure out how to fix the problem yet, without breaking anything else. syslog-ng 3.3 is not affected, but the last s_logfile() statement doesn't work there. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=235 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |3.4.2 -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=235 Balazs Scheidler <bazsi@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bazsi@balabit.hu --- Comment #1 from Balazs Scheidler <bazsi@balabit.hu> 2013-05-21 15:32:23 --- I have just pushed a "fix" for this in the 3.5 branch. The fix is quoted as it contains a largish refactoring in the area, so that unit testing becomes possible. The change itself is not very simple, as the change that broke this functionality allows the use of free-form text as block arguments, which means that quoted strings are injected as a quoted string, e.g. together with the quotation marks. The solution was to detect if the block argument is a single string literal, and if that's the case use the string's value if it is substituted within another string literal. e.g. block destination fooblock foobar() { filename("/var/log/`foobar`"); }; fooblock(foobar("foobar_value")); will result in filename("/var/log/foobar_value"); whereas if `foobar` is used outside a string literal, "foobar_value" (with the quotation marks) is inserted. This is the best solution I could come up with, it complicates the grammar/lexer a lot and gets cheesy to explain, but that's the most intuitive. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=235 --- Comment #2 from Balazs Scheidler <bazsi@balabit.hu> 2013-05-24 09:52:03 --- These are the related patches (should apply to 3.4 too): commit e326f5c7962b802ab2f1e314fbbf49d7dbc0d451 Author: Balazs Scheidler <bazsi@balabit.hu> Date: Tue May 21 11:54:54 2013 +0200 cfg-lexer: implement proper escape handling in backtick insertion This patch implements escaping when inserting a value using backticks. When backticks are used to insert values within string and qstrings and the value itself is a syslog-ng.conf string literal we need to inject its value, adapting the escaped characters. While implementing this function, I also did: - moved to cfg_lexer_subst_args() to a separate module - added GError based error handling - unit tests Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> commit 3ac89d6819e47358486932f3385029a63208432a Author: Balazs Scheidler <bazsi@balabit.hu> Date: Tue May 21 11:38:28 2013 +0200 cfg-lexer: added cfg_lexer_free_token() function The role of this function is to free any type of token returned by the lexer. Do note however that the YYSTYPE struct itself is managed by the caller, only its contents are freed. Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> commit 86166e44fb6f9838733b94c44e5fcc6c9f5c81ea Author: Balazs Scheidler <bazsi@balabit.hu> Date: Tue May 21 11:36:54 2013 +0200 cfg-lexer.h: added GError based error handling boilerplate Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> commit 66754e36a4a21112430597488fb85ead5e7306e1 Author: Balazs Scheidler <bazsi@balabit.hu> Date: Sat May 18 09:38:19 2013 +0200 cfg-args: split off from cfg-lexer.c This is a preparatory patch that slices off functionality from cfg-lexer.c to make it easier to write unit tests for. Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.balabit.com/show_bug.cgi?id=235 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution| |FIXED Status|ASSIGNED |RESOLVED --- Comment #3 from Gergely Nagy <algernon@balabit.hu> 2013-05-27 18:20:04 --- Backported the above fixes to 3.4, they're on the master branch already, closing the report. Thanks! -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
participants (1)
-
bugzilla@bugzilla.balabit.com