Created attachment 218439 [details] syslogd.c.diff Filters by hostname are not working as expected.
Without the patch syslogd(8) doesn't work correctly with an "-O syslog" option. It cannot translate messages from su/sudo, logger(1) to file or remote loghost, for example.
In RFC 3164 (bsd-format): The Domain Name MUST NOT be included in the HOSTNAME field. In RFC 5424 (ietf-format): The HOSTNAME field SHOULD contain the hostname and the domain name of the originator in FQDN format. Without the patch syslogd(8) uses trimdomain() for addresses received from socket by socklist_recv_sock() (via cvthname()) and addresses used by config filtering by readconfigfile() (via cfline()). So, hostname filtering works incorrectly with "-O syslog" in next cases: * using "+@" filtering - "localhost" (without domain name) is used for comparing with FQDN-names (ex. "localhost.localdomain"); * using "+server.localdomain" filtering, "-H" flag and localdomain clients - "server" (without domain name) is used for comparing with FQDN-names (ex. "bsd.localdomain").
Created attachment 218467 [details] syslogd.c.diff Also, RFC 5424 timestamp parsing has been optimized.
Review https://reviews.freebsd.org/D26644
A commit references this bug: Author: markj Date: Fri Oct 9 15:19:29 UTC 2020 New revision: 366576 URL: https://svnweb.freebsd.org/changeset/base/366576 Log: syslogd: Avoid trimming host names in RFC 5424 mode RFC 5424 says that implementations should log hostnames in FQDN format. Only trim host names in RFC 3164 mode. PR: 250014 Submitted by: Dmitry Wagin <dmitry.wagin@ya.ru> MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26644 Changes: head/usr.sbin/syslogd/syslogd.c
I was thinking some more about the timestamp change. We could also avoid parsing RFC 3164 timestamps when -T is specified, but the patch didn't do that. I'm also not sure about skipping the timestamp - if the timestamp field is corrupted, we are presumably supposed to drop the message, but that's not going to be detected if we skip it. Is that ok?
A commit references this bug: Author: markj Date: Mon Nov 9 13:54:30 UTC 2020 New revision: 367523 URL: https://svnweb.freebsd.org/changeset/base/367523 Log: MFC r366576: syslogd: Avoid trimming host names in RFC 5424 mode PR: 250014 Changes: _U stable/12/ stable/12/usr.sbin/syslogd/syslogd.c
Going to close this since the main problem has been fixed. If there is some interest in discussing comment 6 I can look further at the timestamp parsing code.