[Midnightbsd-cvs] src [8199] trunk/usr.sbin/syslogd: add support for ipv6 addresses as destination.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 11:45:14 EDT 2016
Revision: 8199
http://svnweb.midnightbsd.org/src/?rev=8199
Author: laffer1
Date: 2016-09-17 11:45:14 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
add support for ipv6 addresses as destination.
Modified Paths:
--------------
trunk/usr.sbin/syslogd/syslog.conf.5
trunk/usr.sbin/syslogd/syslogd.c
Modified: trunk/usr.sbin/syslogd/syslog.conf.5
===================================================================
--- trunk/usr.sbin/syslogd/syslog.conf.5 2016-09-17 15:44:45 UTC (rev 8198)
+++ trunk/usr.sbin/syslogd/syslog.conf.5 2016-09-17 15:45:14 UTC (rev 8199)
@@ -28,7 +28,7 @@
.\" @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93
.\" $MidnightBSD$
.\"
-.Dd December 23, 2008
+.Dd September 12, 2012
.Dt SYSLOG.CONF 5
.Os
.Sh NAME
@@ -347,6 +347,14 @@
.Pq Ql :\&
then that port will be used as the destination port
rather than the usual syslog port.
+IPv6 addresses can be used
+by surrounding the address portion with
+square brackets
+.Po
+.Ql [\&
+and
+.Ql ]\&
+.Pc .
.It
A comma separated list of users.
Selected messages are written to those users
Modified: trunk/usr.sbin/syslogd/syslogd.c
===================================================================
--- trunk/usr.sbin/syslogd/syslogd.c 2016-09-17 15:44:45 UTC (rev 8198)
+++ trunk/usr.sbin/syslogd/syslogd.c 2016-09-17 15:45:14 UTC (rev 8199)
@@ -1931,6 +1931,7 @@
case '@':
{
char *tp;
+ char endkey = ':';
/*
* scan forward to see if there is a port defined.
* so we can't use strlcpy..
@@ -1939,9 +1940,19 @@
tp = f->f_un.f_forw.f_hname;
p++;
- while (*p && (*p != ':') && (i-- > 0)) {
+ /*
+ * an ipv6 address should start with a '[' in that case
+ * we should scan for a ']'
+ */
+ if (*p == '[') {
+ p++;
+ endkey = ']';
+ }
+ while (*p && (*p != endkey) && (i-- > 0)) {
*tp++ = *p++;
}
+ if (endkey == ']' && *p == endkey)
+ p++;
*tp = '\0';
}
/* See if we copied a domain and have a port */
More information about the Midnightbsd-cvs
mailing list