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
This commit is contained in:
Mark Johnston 2020-10-09 15:19:29 +00:00
parent 812b09037d
commit b0eefff78b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=366576

View File

@ -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 */