syslogd: fix -b use with IPv6 literal addresses after ^/head@r309933
ClosedPublic

Authored by ngie on Mar 20 2017, 4:58 PM.

Details

Summary

syslogd: fix -b use with IPv6 literal addresses after ^/head@r309933

Don't assume all -b arguments don't contain a single colon to be a
filename/hostname. Check for an additional colon in the output to see
whether or not it should be assumed to be a filename/hostname.

PR: 217939
Submitted by: ae
Sponsored by: Dell EMC Isilon

Test Plan

Positive case:

The gamut of -b arguments I added to the bug:

$ grep ^syslogd_flags= /etc/rc.conf
syslogd_flags="-b :syslog -b ::1 -b [::1]:syslog -b 127.0.0.1:syslog -b localhost -b localhost:syslog"
$ sudo service syslogd restart
syslogd not running? (check /var/run/syslog.pid).
Starting syslogd.
$ sockstat | grep syslogd
root syslogd 34368 6 udp6 *:514 *:*
root syslogd 34368 7 udp4 *:514 *:*
root syslogd 34368 8 udp6 ::1:514 *:*
root syslogd 34368 9 udp4 127.0.0.1:514 *:*
root syslogd 34368 10 dgram /var/run/log
root syslogd 34368 11 dgram /var/run/logpriv

IN6ADDR_ANY[_INIT]:

$ sudo syslogd -b ::
$ sockstat | grep syslogd
root syslogd 34436 6 udp6 *:514 *:*
root syslogd 34436 7 dgram /var/run/log
root syslogd 34436 8 dgram /var/run/logpriv

INADDR_ANY:

$ sudo syslogd -s -b 0.0.0.0
$ sockstat | grep syslogd
root syslogd 34443 6 udp4 *:514 *:*
root syslogd 34443 7 dgram /var/run/log
root syslogd 34443 8 dgram /var/run/logpriv

Negative cases:

$ sudo syslogd -s -b ::1:syslog -d
Trying peer: ::1:syslog
syslogd: getaddrinfo failed for ::1:syslogsyslog: hostname nor servname provided, or not known
logmsg: pri 53, flags 4, from , msg syslogd: getaddrinfo failed for ::1:syslogsyslog: hostname nor servname provided, or not known
Logging to UNUSED

$ sudo syslogd -s -b 127.0.0.1::syslog -d
Trying peer: 127.0.0.1::syslog
syslogd: getaddrinfo failed for 127.0.0.1::syslogsyslog: hostname nor servname provided, or not known
logmsg: pri 53, flags 4, from , msg syslogd: getaddrinfo failed for 127.0.0.1::syslogsyslog: hostname nor servname provided, or not known
Logging to UNUSED

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngie created this revision.Mar 20 2017, 4:58 PM
This revision was automatically updated to reflect the committed changes.