From b0eefff78b8b2f3848544d644a001c7efa434b34 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Fri, 9 Oct 2020 15:19:29 +0000 Subject: [PATCH] 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 MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D26644 --- usr.sbin/syslogd/syslogd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 7c5dcc66cfe0..8cd4cdde9db9 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -2300,7 +2300,9 @@ cvthname(struct sockaddr *f) hl = strlen(hname); if (hl > 0 && hname[hl-1] == '.') hname[--hl] = '\0'; - trimdomain(hname, hl); + /* RFC 5424 prefers logging FQDNs. */ + if (RFC3164OutputFormat) + trimdomain(hname, hl); return (hname); } @@ -2927,7 +2929,9 @@ cfline(const char *line, const char *prog, const char *host, hl = strlen(f->f_host); if (hl > 0 && f->f_host[hl-1] == '.') f->f_host[--hl] = '\0'; - trimdomain(f->f_host, hl); + /* RFC 5424 prefers logging FQDNs. */ + if (RFC3164OutputFormat) + trimdomain(f->f_host, hl); } /* save program name if any */