[syslog-ng] Message and Header are being split incorrectly

Peter Czanik (pczanik) Peter.Czanik at oneidentity.com
Fri Jun 5 06:35:35 UTC 2020


FreeBSD 12.1 changed from the legacy syslog protocol to RFC 5424 format. When you use the system() source for local logs, this is handled automagically. But you can also fix it by hand: https://github.com/syslog-ng/syslog-ng/issues/2428


Peter Czanik (CzP) <peter.czanik at oneidentity.com>
Balabit (a OneIdentity company) / syslog-ng upstream

From: syslog-ng <syslog-ng-bounces at lists.balabit.hu> on behalf of Sass, Fabian <Fabian.Sass at f-i-ts.de>
Sent: Friday, June 5, 2020 08:28
To: syslog-ng at lists.balabit.hu <syslog-ng at lists.balabit.hu>
Subject: [syslog-ng] Message and Header are being split incorrectly

CAUTION: This email originated from outside of the organization. Do not follow guidance, click links, or open attachments unless you recognize the sender and know the content is safe.


since updating the Base OS to FreeBSD 12.1 syslog-ng 3.27.1 fails splitting a message and its headers.

Jun  5 08:12:00 myhostname 1 2020-06-05T08:12:00.042109+02:00 myhostname /usr/sbin/cron 71149 - - (root) RELOAD (tabs/root)

Jun  5 08:12:01 myhostname 1 2020-06-05T08:12:01.546089+02:00 myhostname named 54403 - - client @0xfffffff update 'some.domain/IN' denied

Using templates for the destination reveals that the $MSGHDR Macro only holds the value “1”, which is the wrongly extracted $PROGRAM macro.

$MESSAGE itself contains almost all information of the lines above, to be precise everything from (including) the $ISODATE to the end of the line.
However using templates and rewrite rules is in this case sufficient to restore the logformat that was used before the update.

The bigger issue is that changing the value of $PROGRAM has no effect when sending it to antoher syslog-ng loghost.
The behavior seems to be analog to this bug:

As you can see in my syslog-ng.conf the $PROGRAM macro is overwritten to “named” if named was logging to the local syslog-ng. The successful overwriting is verified using a separate logfile (destination d_test):

@version: 3.5


# options


options {










source s_all { unix-dgram("/var/run/log");

             unix-dgram("/var/run/logpriv" perm(0600));




# rewrite since syslog message splitting is broken since update to freebsd12...


rewrite r_msg {


        "named", value("PROGRAM") condition(message(".* named [0-9]+ - -.*"))


    subst(".* ([a-zA-Z/\._]+) ([0-9]+) - - (.*)", "$1[$2]: $3", value("MESSAGE"));



# destinations


destination d_test { file("/var/log/fabian_messages" template("$DATE $PROGRAM $HOST $MESSAGE\n")); };

destination d_test2 { file("/var/log/fabian_messages2"); };

destination d_messages { file("/var/log/messages" template("$DATE $HOST $MESSAGE\n")); };

destination d_loghost  { tcp("someiphere" port(514) template("$DATE $HOST $MESSAGE\n")); udp("anotheriphere" port(10525) template("$DATE $HOST $MESSAGE\n")); };



# logging


log { source(s_all); rewrite(r_msg); destination(d_messages); };

log { source(s_all); rewrite(r_msg); destination(d_loghost); };

log { source(s_all); rewrite(r_msg); destination(d_test); };

log { source(s_all); destination(d_test2); };

Am I missing something here, or is syslog-ng somehow behaving unintended?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20200605/757929e5/attachment-0001.html>

More information about the syslog-ng mailing list