[Bug 128] New: template() broken in latest 3.3 git
https://bugzilla.balabit.com/show_bug.cgi?id=128 Summary: template() broken in latest 3.3 git Product: syslog-ng Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: unspecified Component: syslog-ng AssignedTo: bazsi@balabit.hu ReportedBy: algernon@balabit.hu Type of the Report: --- Estimated Hours: 0.0 Hi! While updating my 3.3 installation from an ancient version to latest git head, I noticed that template functions stopped working. If I have any kind of template in the config, I get a segmentation fault: ,---- | Program received signal SIGSEGV, Segmentation fault. | log_template_reset_compiled (self=0x0) at templates.c:661 | 661 while (self->compiled_template) | (gdb) bt | #0 log_template_reset_compiled (self=0x0) at templates.c:661 | #1 0x00007ffff7b9f302 in log_template_compile (self=0x0, template=0x63d7e0 "foo: bar", error=0x7fffffffb5d8) at templates.c:788 | #2 0x00007ffff5e96761 in affile_parse (lexer=<value optimized out>, instance=<value optimized out>, arg=<value optimized out>) at affile-grammar.y:592 | #3 0x00007ffff7b9bd72 in cfg_parser_parse (self=0x7ffff609ce30, cfg=<value optimized out>, yylloc=<value optimized out>, arg=<value optimized out>) at cfg-parser.h:83 | #4 plugin_parse_config (self=0x7ffff609ce30, cfg=<value optimized out>, yylloc=<value optimized out>, arg=<value optimized out>) at plugin.c:124 | #5 0x00007ffff7ba89f7 in main_parse (lexer=<value optimized out>, dummy=<value optimized out>, arg=<value optimized out>) at cfg-grammar.y:592 | #6 0x00007ffff7b7ee93 in cfg_parser_parse (self=0x611720, lexer=0x6188a0, parser=0x7ffff7dd92a0, result=<value optimized out>, arg=<value optimized out>) at cfg-parser.h:83 | #7 cfg_run_parser (self=0x611720, lexer=0x6188a0, parser=0x7ffff7dd92a0, result=<value optimized out>, arg=<value optimized out>) at cfg.c:370 | #8 0x00007ffff7b7efa6 in cfg_read_config (self=0x611720, fname=0x7ffff7bb7068 "/home/algernon/tmp/sng/install/3.3/etc/syslog-ng.conf", syntax_only=<value optimized out>, preprocess_into=0x0) at cfg.c:392 | #9 0x00007ffff7b970c1 in main_loop_init () at mainloop.c:611 | #10 0x0000000000401865 in main (argc=1, argv=0x7fffffffdc78) at main.c:242 | (gdb) `---- The config that triggers this is as follows: ,---- | @version: 3.3 | @include "scl.conf" | | source s_local { internal(); }; | destination d_local { file("/tmp/template-test" template("foo: bar")); }; | log { source(s_local); destination(d_local); }; `---- After bisecting the problem, I ended up with the following commit: ,---- | 2443b07b90c822414a628aae6a9ca513357b52fc is the first bad commit | commit 2443b07b90c822414a628aae6a9ca513357b52fc | Author: Balazs Scheidler <bazsi@balabit.hu> | Date: Sat Jun 11 14:09:01 2011 +0200 | | template: make template compilation thread safe | | Instead of doing template compilation on-demand, require the application | code to do it explicitly, at initialization, in order to avoid having to | acquire a lock during runtime. | | This patch contains an incompatible API change, and requires updating | all call-sites. | | The change makes it also possible to change template string of a constructed | LogTemplate class multiple times with a call to log_template_compile(). | | Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> | | :040000 040000 a40fc910d215dac2184aa02ae1498c6748e3e64a dea1d2a7fc02d1d0ec8e095f2f62499ce42b895a M lib | :040000 040000 1641cf3152897406874716d4f090b5cc795292ab f66d2e5c482c3ff91b9d4219812766d66067c7a1 M modules | :040000 040000 2c2a37fd3a4f9c5bddc81813605c20ece033ce2f dff570d331b8e7ada6c1202761066878b9bb3910 M tests `---- I'm not quite sure why this happens yet, I'll keep digging. I'll post a patch if and when I figure out what exactly broke. Meanwhile, this bug report will serve as a reminder for me to keep looking. -- 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=128 --- Comment #1 from Gergely Nagy <algernon@balabit.hu> 2011-07-03 23:28:56 ---
While updating my 3.3 installation from an ancient version to latest git head, I noticed that template functions stopped working. If I have any kind of template in the config, I get a segmentation fault:
Correction: some templates do work. value-pairs()' templates do work fine, which suggests the bug is not necessarily around the templates itself, but somewhere around the callers. -- 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=128 Gergely Nagy <algernon@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bazsi@balabit.hu |algernon@balabit.hu Status|NEW |ASSIGNED --- Comment #2 from Gergely Nagy <algernon@balabit.hu> 2011-07-03 23:54:27 --- Created an attachment (id=40) --> (https://bugzilla.balabit.com/attachment.cgi?id=40) Patch fixing the problem. Reviewed the commit bisecting arrived to, specifically looking at what the different parser components do with templates, and found that the template() parser in cfg-grammar.y broke in that patch: last_writer_options->template was initialized in that block prior to the patch, but the patch removed the initialization, leaving only the CHECK_ERROR call. The attached patch fixes this, by reintroducing the initialization. This problem might be present in more cases too, I haven't verified all of them yet. If further cases are found, I will update the patch. -- 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=128 Balazs Scheidler <bazsi@balabit.hu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bazsi@balabit.hu Resolution| |FIXED Status|ASSIGNED |RESOLVED --- Comment #3 from Balazs Scheidler <bazsi@balabit.hu> 2011-07-14 12:29:48 --- integrated, thanks. -- Configure bugmail: https://bugzilla.balabit.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
On 14 Jul 2011, bugzilla@bugzilla.balabit.com told this:
https://bugzilla.balabit.com/show_bug.cgi?id=128
Balazs Scheidler <bazsi@balabit.hu> changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bazsi@balabit.hu Resolution| |FIXED Status|ASSIGNED |RESOLVED
--- Comment #3 from Balazs Scheidler <bazsi@balabit.hu> 2011-07-14 12:29:48 --- integrated, thanks.
This is seemingly still broken :( (and so are my fingers, sorry for the last email with a subject line describing this and completely different content). My syslog-ng-3.3 config is derived directly from a syslog-ng-3.0 config saving only an adjustment of tcp() and udp(). The config is attached. syslog-ng-3.0 emits things looking like this: Jul 18 14:52:17 fold info: p6IDqFJu004668: Milter add: header: X-DCC-URT-Metrics: spindle 1060; Body=many Fuz1=many Fuz2=many Jul 18 14:52:17 fold info: p6IDqFJu004668: to=<nix@esperi.org.uk>, delay=00:00:01, xdelay=00:00:00, mailer=local, pri=144021, dsn=2.0.0, stat=Sent Jul 18 14:52:38 fold notice: ruleset=check_relay, arg1=[41.201.240.140], arg2=41.201.240.140, relay=[41.201.240.140], reject=550 5.7.1 Fix reverse DNS for 41.201.240.140 Jul 18 14:52:56 fold info: p6IDqtS6004673: from=<linux-kernel-owner@vger.kernel.org>, size=2651, class=-60, nrcpts=1, msgid=<20110718135243.GA5349@suse.de>, bodytype=8BITMIME, proto=ESMTP, daemon=MTA, relay=vger.kernel.org [209.132.180.67] Jul 18 14:52:56 fold info: p6IDqtS6004673: Milter add: header: X-DCC-URT-Metrics: spindle 1060; Body=1 Fuz1=1 Fuz2=1 i.e. ordinary-looking log messages, slightly adjusted. syslog-ng-3.3 from git head as of yesterday (including the attempted fix) emits this: priority_templatepriority_templatepriority_templatepriority_template[...] endlessly: one 'priority_template' per message, no linefeeds. It looks like template priority_template { template("$S_DATE $HOST $PRIORITY: $MESSAGE\n"); template_escape(no); }; destination by-facility { file("/var/log/by-facility/$FACILITY" template(priority_template) suppress(30)); }; is emitting the *words* 'priority_template' into the file. Full syslog-ng.conf attached, sorry that it's so ugly and verbose, I want a proper lisp-style macro system. :) or perhaps I can just generate it from m4... probably there is a really neat way of doing what I'm doing in here in about six lines, but I haven't revised it much since the syslog-ng-2.x days and I couldn't find a neater approach then. @version: 3.3 # # syslog config for primary log host # # Nix <nix@esperi.org.uk> # # # Options # options { keep_hostname(no); create_dirs(1); perm(0644); dir_perm(0755); log_fifo_size(1000); use_dns(yes); dns_cache(yes); use_fqdn(no); flush_lines(100); flush_timeout(1000); stats_freq(3600); chain_hostnames(yes); }; # # Sources # source local { unix-stream("/dev/log" flags(no-multi-line)); internal(); file("/proc/kmsg" program_override("kernel: ") flags(kernel no-multi-line)); }; source remote { tcp(ip(0.0.0.0) port(601) max-connections(50) log_fetch_limit(100) log_iw_size(5192) flags(no-multi-line)); udp(ip(0.0.0.0) port(514) log_fetch_limit(100) log_iw_size(1100) flags(no-multi-line)); }; source netconsole { udp(ip(0.0.0.0) port(24183) log_fetch_limit(100) log_iw_size(1100) flags(no-parse)); }; # # Templates # # A template containing the priority, for by-facility log messages template priority_template { template("$S_DATE $HOST $PRIORITY: $MESSAGE\n"); template_escape(no); }; # A bare template, for netconsole messages. template bare { template("$MSG\n"); template_escape(no); }; # A template containing the facility and priority, for by-priority # messages (which are logged to this-or-greater files, so many # priorities are intermixed) template facility_template { template("$S_DATE $HOST $FACILITY $PRIORITY: $MESSAGE\n"); template_escape(no); }; # An `original syslogd' message, for programs to parse template machine_readable_template { template("$S_DATE $HOST: $MESSAGE\n"); template_escape(no); }; # # Destinations # # We have the following divisions of logfiles: # by-facility: # logs with priority in the template, above debugging priority [archived] # by-facility/machine-readable: # as by-facility, but without the different template [not archived] # by-facility/machine-readable/{blah}.debug: # as machine-readable, debug-priority alone # debug-priority stuff alone. # by-priority: # logs with facility in the template, including higher priority levels, # except for debug, which logs debug priority alone [not archived] # by-priority/machine-readable: # as by-priority, but without the different template [not archived] destination by-facility { file("/var/log/by-facility/$FACILITY" template(priority_template) suppress(30)); }; destination by-facility-spam { file("/var/log/by-facility/spam" template(priority_template) suppress(30)); }; destination by-facility-machine-readable { file("/var/log/by-facility/machine-readable/$FACILITY" template(machine_readable_template) suppress(30)); }; destination by-facility-machine-readable-spam { file("/var/log/by-facility/machine-readable/spam" template(machine_readable_template) suppress(30)); }; destination by-facility-fallback { file("/var/log/by-facility/null" template(priority_template) suppress(30)); }; destination by-facility-machine-readable-fallback { file("/var/log/by-facility/machine-readable/null" template(machine_readable_template) suppress(30)); }; destination by-facility-machine-readable-debugging { file("/var/log/by-facility/machine-readable/$FACILITY.debug" template(machine_readable_template) suppress(30)); }; destination by-priority-emerg { file("/var/log/by-priority/emerg" template(facility_template) suppress(30)); }; destination by-priority-alert { file("/var/log/by-priority/alert" template(facility_template) suppress(30)); }; destination by-priority-crit { file("/var/log/by-priority/crit" template(facility_template) suppress(30)); }; destination by-priority-err { file("/var/log/by-priority/err" template(facility_template) suppress(30)); }; destination by-priority-warning { file("/var/log/by-priority/warning" template(facility_template) suppress(30)); }; destination by-priority-notice { file("/var/log/by-priority/notice" template(facility_template) suppress(30)); }; destination by-priority-info { file("/var/log/by-priority/info" template(facility_template) suppress(30)); }; destination by-priority-debug { file("/var/log/by-priority/debug" template(facility_template) suppress(30)); }; destination by-priority-fallback { file("/var/log/by-priority/null" template(facility_template) suppress(30)); }; destination by-priority-machine-readable-emerg { file("/var/log/by-priority/machine-readable/emerg" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-alert { file("/var/log/by-priority/machine-readable/alert" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-crit { file("/var/log/by-priority/machine-readable/crit" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-err { file("/var/log/by-priority/machine-readable/err" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-warning { file("/var/log/by-priority/machine-readable/warning" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-notice { file("/var/log/by-priority/machine-readable/notice" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-info { file("/var/log/by-priority/machine-readable/info" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-debug { file("/var/log/by-priority/machine-readable/debug" template(machine_readable_template) suppress(30)); }; destination by-priority-machine-readable-fallback { file("/var/log/by-priority/machine-readable/null" template(machine_readable_template) suppress(30)); }; destination external-firewall-warnings { file("/var/log/firewall" template(machine_readable_template) suppress(30)); }; destination root-and-nix { usertty(root); usertty(nix); }; destination netconsole { file("/var/log/$HOST-netconsole.log" template(bare)); }; # # Filters. # # Filter stuff equal to or greater than priority (foo). # filter emerg { priority(emerg); }; filter alert { priority(alert .. emerg); }; filter crit { priority(crit .. emerg); }; filter err { priority(err .. emerg); }; filter warning { priority(warning .. emerg); }; filter notice { priority(notice .. emerg); }; filter info { priority(info .. emerg); }; # Filter out non-debugging stuff and debugging-only stuff filter not-debug { not(priority(debug)); }; filter debug-only { priority(debug); }; # Filter out stuff which is likely to be spam-notice-related filter mail-notice-only { priority(notice) and facility(mail); }; # External-firewall-related stuff (for dshield reports) filter external-firewall { facility(local1) or (facility(kern) and match(" packet denied IN=adsl " value("MESSAGE"))); }; # # Loggers. # log { source(local); source(remote); filter(not-debug); destination(by-facility); destination(by-facility-machine-readable); }; log { source(local); source(remote); filter(debug-only); destination(by-facility-machine-readable-debugging); }; log { source(local); source(remote); filter(mail-notice-only); destination(by-facility-spam); destination(by-facility-machine-readable-spam); }; log { source(local); source(remote); filter(emerg); destination(by-priority-emerg); destination(by-priority-machine-readable-emerg); destination(root-and-nix); }; log { source(local); source(remote); filter(alert); destination(by-priority-alert); destination(by-priority-machine-readable-alert); }; log { source(local); source(remote); filter(crit); destination(by-priority-crit); destination(by-priority-machine-readable-crit); }; log { source(local); source(remote); filter(err); destination(by-priority-err); destination(by-priority-machine-readable-err); }; log { source(local); source(remote); filter(warning); destination(by-priority-warning); destination(by-priority-machine-readable-warning); }; log { source(local); source(remote); filter(notice); destination(by-priority-notice); destination(by-priority-machine-readable-notice); }; log { source(local); source(remote); filter(info); destination(by-priority-info); destination(by-priority-machine-readable-info); }; log { source(local); source(remote); filter(debug-only); destination(by-priority-debug); destination(by-priority-machine-readable-debug); }; log { source(local); source(remote); filter(external-firewall); destination(external-firewall-warnings); }; log { source(local); source(remote); destination(by-facility-fallback); destination(by-facility-machine-readable-fallback); destination(by-priority-fallback); destination(by-priority-machine-readable-fallback); flags(fallback); }; log { source(netconsole); destination(netconsole); };
Nix <nix@esperi.org.uk> writes:
Full syslog-ng.conf attached, sorry that it's so ugly and verbose, I want a proper lisp-style macro system. :)
Working on it! :] (3.3 also has block{}, which would make your config a lot more compact - I'll post a block{}-ized version aswell, when I had a little time looking at this issue). As for the template() bug, I'll look into that as soon as possible aswell (friday latest, unless something unexpected happens, perhaps earlier). -- |8]
On 19 Jul 2011, Gergely Nagy verbalised:
Nix <nix@esperi.org.uk> writes:
Full syslog-ng.conf attached, sorry that it's so ugly and verbose, I want a proper lisp-style macro system. :)
Working on it! :] (3.3 also has block{}, which would make your config a
Aha, still known broken, just didn't want it to fly under the rug.
lot more compact - I'll post a block{}-ized version aswell, when I had a little time looking at this issue).
Ooo. That feature looks really neat! Doesn't seem to be documented anywhere... ... ah. I should be following baszi's blog, shouldn't I?
As for the template() bug, I'll look into that as soon as possible aswell (friday latest, unless something unexpected happens, perhaps earlier).
Assuming I don't get to it first (looks at todo list, laughs despairingly). -- NULL && (void)
On Tue, 2011-07-19 at 13:14 +0100, Nix wrote:
On 19 Jul 2011, Gergely Nagy verbalised:
Nix <nix@esperi.org.uk> writes:
Full syslog-ng.conf attached, sorry that it's so ugly and verbose, I want a proper lisp-style macro system. :)
Working on it! :] (3.3 also has block{}, which would make your config a
Aha, still known broken, just didn't want it to fly under the rug.
lot more compact - I'll post a block{}-ized version aswell, when I had a little time looking at this issue).
Ooo. That feature looks really neat! Doesn't seem to be documented anywhere...
... ah. I should be following baszi's blog, shouldn't I?
As for the template() bug, I'll look into that as soon as possible aswell (friday latest, unless something unexpected happens, perhaps earlier).
Assuming I don't get to it first (looks at todo list, laughs despairingly).
I'm starting to think that I was not in the proper mood, when I've committed this patch: commit 2443b07b90c822414a628aae6a9ca513357b52fc Author: Balazs Scheidler <bazsi@balabit.hu> Date: Sat Jun 11 14:09:01 2011 +0200 template: make template compilation thread safe This broke both inline templates (which Gergely has fixed), and external templates, which Nix has noticed. This patch finally makes both work for me: commit 091f4c093b4836114badc8a7a4863bdac8757f42 Author: Balazs Scheidler <bazsi@balabit.hu> Date: Wed Jul 20 12:25:01 2011 +0200 cfg-grammar: fixed template expansion for externally defined templates This patch fixes template expansion even if the template is not defined inline, but rather as an external object, referenced at a destination. Reported-By: Nix <nix@esperi.org.uk> Signed-off-by: Balazs Scheidler <bazsi@balabit.hu> -- Bazsi
On 20 Jul 2011, Balazs Scheidler said:
This patch finally makes both work for me:
This causes test_template to fail: FAIL: error compiling template, template=$(echo $HOST $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo $HOST)" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo '$(echo $HOST)')" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo '$(echo $HOST)')" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo '"$(echo $(echo $HOST))"' $PID), error=Unknown template function echo FAIL: error compiling template, template=$(ipv4-to-int $SOURCEIP), error=Unknown template function ipv4-to-int FAIL: error compiling template, template=$(grep 'facility(local3)' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID $PROGRAM), error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local4)' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY' == 'local4') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY(' == 'local3(') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY(' == 'local4)') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep \'$FACILITY\'\ ==\ \'local4\' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(if 'facility(local4)' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if 'facility(local3)' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" lt "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" le "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" eq "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" ne "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" gt "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" ge "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" < "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" <= "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" == "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" != "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" > "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19" and "kicsi" == "nagy"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19" or "kicsi" == "nagy"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(echo ${HOST}@0 ${PID}@1), error=Unknown template function echo FAIL: error compiling template, template=$(echo $HOST $PID)@0, error=Unknown template function echo FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@0, error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@1, error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@2, error=Unknown template function grep FAIL: error compiling template, template=dani $(echo $HOST $DATE $(echo huha)) balint, error=Unknown template function echo WARNING: template: the default value for template-escape is changing to 'no' in version 3.0, please update your configuration file accordingly; WARNING: template: the meaning of the $MSG/$MESSAGE macros is changing in version 3.0, please prepend a $MSGHDR when upgrading to 3.0 config format; FAIL: test_template Not installing on the grounds that this is probably a bad sign (but it may be a testsuite error, I suppose). Also, you missed a call site, so the csvparser module won't compile anymore. Here's a patch, which does things the same way you did them in cfg-grammar.y, and which compiles, at least:
From 5b18af42d417f47ceae2ac1526cc572182394210 Mon Sep 17 00:00:00 2001 From: Nix <nix@esperi.org.uk> Date: Wed, 20 Jul 2011 15:51:55 +0100 Subject: [PATCH] Fix compilation of the CSV parser module.
Commit 091f4c093b4836114badc8a7a4863bdac8757f42 changed the prototype of cfg_check_inline_template(): adjust the CSV parser module's use of this function accordingly. Signed-off-by: Nick Alcock <nix@esperi.org.uk> --- modules/csvparser/csvparser-grammar.ym | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/csvparser/csvparser-grammar.ym b/modules/csvparser/csvparser-grammar.ym index 90f1438..5ab0ea1 100644 --- a/modules/csvparser/csvparser-grammar.ym +++ b/modules/csvparser/csvparser-grammar.ym @@ -80,10 +80,10 @@ parser_column_opt parser_opt : KW_TEMPLATE '(' string ')' { - LogTemplate *template = cfg_check_inline_template(configuration, $3); GError *error = NULL; + LogTemplate *template = cfg_check_inline_template(configuration, $3, error); - CHECK_ERROR(log_template_compile(template, $3, &error), @3, "Error compiling template (%s)", error->message); + CHECK_ERROR(template != NULL, @3, "Error compiling template (%s)", error->message); log_parser_set_template(last_parser, template); free($3); } -- 1.7.5.4.136.g9db10
Hi, On Wed, 2011-07-20 at 15:55 +0100, Nix wrote:
On 20 Jul 2011, Balazs Scheidler said:
This patch finally makes both work for me:
This causes test_template to fail:
FAIL: error compiling template, template=$(echo $HOST $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo $HOST)" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo '$(echo $HOST)')" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo "$(echo '$(echo $HOST)')" $PID), error=Unknown template function echo FAIL: error compiling template, template=$(echo '"$(echo $(echo $HOST))"' $PID), error=Unknown template function echo FAIL: error compiling template, template=$(ipv4-to-int $SOURCEIP), error=Unknown template function ipv4-to-int FAIL: error compiling template, template=$(grep 'facility(local3)' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID $PROGRAM), error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local4)' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY' == 'local4') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY(' == 'local3(') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep ('$FACILITY(' == 'local4)') $PID), error=Unknown template function grep FAIL: error compiling template, template=$(grep \'$FACILITY\'\ ==\ \'local4\' $PID), error=Unknown template function grep FAIL: error compiling template, template=$(if 'facility(local4)' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if 'facility(local3)' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" lt "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" le "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" eq "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" ne "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" gt "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY" ge "local3"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" < "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" <= "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" == "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" != "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" > "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19" and "kicsi" == "nagy"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(if '"$FACILITY_NUM" >= "19" or "kicsi" == "nagy"' alma korte), error=Unknown template function if FAIL: error compiling template, template=$(echo ${HOST}@0 ${PID}@1), error=Unknown template function echo FAIL: error compiling template, template=$(echo $HOST $PID)@0, error=Unknown template function echo FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@0, error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@1, error=Unknown template function grep FAIL: error compiling template, template=$(grep 'facility(local3)' $PID)@2, error=Unknown template function grep FAIL: error compiling template, template=dani $(echo $HOST $DATE $(echo huha)) balint, error=Unknown template function echo WARNING: template: the default value for template-escape is changing to 'no' in version 3.0, please update your configuration file accordingly; WARNING: template: the meaning of the $MSG/$MESSAGE macros is changing in version 3.0, please prepend a $MSGHDR when upgrading to 3.0 config format; FAIL: test_template
Not installing on the grounds that this is probably a bad sign (but it may be a testsuite error, I suppose).
It works for me: PASS: test_template The error messages indicate that your test suite couldn't load the "basicfuncs" plugin that contains an implementation for $(if) $(grep) and $(echo)
Also, you missed a call site, so the csvparser module won't compile anymore. Here's a patch, which does things the same way you did them in cfg-grammar.y, and which compiles, at least:
From 5b18af42d417f47ceae2ac1526cc572182394210 Mon Sep 17 00:00:00 2001 From: Nix <nix@esperi.org.uk> Date: Wed, 20 Jul 2011 15:51:55 +0100 Subject: [PATCH] Fix compilation of the CSV parser module.
Commit 091f4c093b4836114badc8a7a4863bdac8757f42 changed the prototype of cfg_check_inline_template(): adjust the CSV parser module's use of this function accordingly.
Signed-off-by: Nick Alcock <nix@esperi.org.uk>
Right, thanks, I've noticed this too, right before reading your email. Also pushed. -- Bazsi
On 22 Jul 2011, Balazs Scheidler verbalised:
The error messages indicate that your test suite couldn't load the "basicfuncs" plugin that contains an implementation for $(if) $(grep) and $(echo)
Indeed it can't, because it's looking for them in the install location, and I'm running tests before installation (which seems only sane with something as system-critical as a logging daemon, especially when it's a beta version and my last three intallations were failures and led to its being backed out ;) ). access("/usr/lib/syslog-ng/libbasicfuncs.so", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libbasicfuncs.la", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libconvertfuncs.so", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libconvertfuncs.la", F_OK) = -1 ENOENT (No such file or directory) The test_template_LDADD line has led to the right directories for these plugins being added to LD_LIBRARY_PATH, but dlopen() of course does not follow LD_LIBRARY_PATH, it's following the module-path, which is unset because all we've called is cfg_new(). This could all be fixed by setting module_path, but unfortunately the module-path variable consulted by the loader (as opposed to the global which is its ultimate source) is not that easy to set: you need to run the lexer, which means you need a configuration file, and none of the tests in tests/unit have one of those. Perhaps it would be best to move the lexer->args out of the lexer, or just provide an outside-lexer way to initialize it? (Or simply provide a trivial configuration file and parse it in the unit tests... that's probably least invasive.)
On Fri, 2011-07-22 at 13:18 +0100, Nix wrote:
On 22 Jul 2011, Balazs Scheidler verbalised:
The error messages indicate that your test suite couldn't load the "basicfuncs" plugin that contains an implementation for $(if) $(grep) and $(echo)
Indeed it can't, because it's looking for them in the install location, and I'm running tests before installation (which seems only sane with something as system-critical as a logging daemon, especially when it's a beta version and my last three intallations were failures and led to its being backed out ;) ).
access("/usr/lib/syslog-ng/libbasicfuncs.so", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libbasicfuncs.la", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libconvertfuncs.so", F_OK) = -1 ENOENT (No such file or directory) access("/usr/lib/syslog-ng/libconvertfuncs.la", F_OK) = -1 ENOENT (No such file or directory)
The test_template_LDADD line has led to the right directories for these plugins being added to LD_LIBRARY_PATH, but dlopen() of course does not follow LD_LIBRARY_PATH, it's following the module-path, which is unset because all we've called is cfg_new().
This could all be fixed by setting module_path, but unfortunately the module-path variable consulted by the loader (as opposed to the global which is its ultimate source) is not that easy to set: you need to run the lexer, which means you need a configuration file, and none of the tests in tests/unit have one of those. Perhaps it would be best to move the lexer->args out of the lexer, or just provide an outside-lexer way to initialize it? (Or simply provide a trivial configuration file and parse it in the unit tests... that's probably least invasive.)
hmm.. the test suite can run in a private directory too, as the testsuite is directly linked against the .so-s in the private directory, and it does work here, however funny ld options might break that. what distro are you using? -- Bazsi
participants (4)
-
Balazs Scheidler
-
bugzilla@bugzilla.balabit.com
-
Gergely Nagy
-
Nix