Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Jul 2023 05:22:02 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a81b559dad5b - main - Fix saving STRUCTURED-DATA in RFC 5424 log format
Message-ID:  <202307070522.3675M2ul072714@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a81b559dad5b75548d1ea847db24147a4410ed92

commit a81b559dad5b75548d1ea847db24147a4410ed92
Author:     Vadim Goncharov <vadimnuclight@gmail.com>
AuthorDate: 2023-07-07 05:15:06 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2023-07-07 05:15:10 +0000

    Fix saving STRUCTURED-DATA in RFC 5424 log format
    
    When saving log files in RFC 5424 format presence of STRUCTURED-DATA
    in message caused line to not appear in log file at all, because
    a variable forgotten to initialize. This could be tested by (slightly
    modified) example from RFC:
    
        echo '<165>1 2003-10-11T22:14:15.003Z mymachine.example.com su 12345 ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][id@2 test="tast"] BOM"su root" failed for lonvick on /dev/pts/8" ' | nc -w1 -Uu /var/run/log
    
    While here, update stale information in comment to logmsg() that RFC 5424
    log format was not supported.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/717
---
 usr.sbin/syslogd/syslogd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 4600c807a7df..730575c24156 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1123,6 +1123,7 @@ parsemsg_rfc5424(const char *from, int pri, char *msg)
 	FAIL_IF("STRUCTURED-NAME", start == msg);			\
 } while (0)
 	IF_NOT_NILVALUE(structured_data) {
+		structured_data = msg;
 		/* SD-ELEMENT. */
 		while (*msg == '[') {
 			++msg;
@@ -1582,9 +1583,8 @@ evaluate_prop_filter(const struct prop_filter *filter, const char *value)
 
 /*
  * Logs a message to the appropriate log files, users, etc. based on the
- * priority. Log messages are always formatted according to RFC 3164,
- * even if they were in RFC 5424 format originally, The MSGID and
- * STRUCTURED-DATA fields are thus discarded for the time being.
+ * priority. Log messages are formatted according to RFC 3164 or
+ * RFC 5424 in subsequent fprintlog_*() functions.
  */
 static void
 logmsg(int pri, const struct logtime *timestamp, const char *hostname,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307070522.3675M2ul072714>