From nobody@FreeBSD.org  Mon Sep 13 14:26:46 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 9B910106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Sep 2010 14:26:46 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 86AC58FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Sep 2010 14:26:46 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8DEQkIj085816
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 13 Sep 2010 14:26:46 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8DEQkPF085815;
	Mon, 13 Sep 2010 14:26:46 GMT
	(envelope-from nobody)
Message-Id: <201009131426.o8DEQkPF085815@www.freebsd.org>
Date: Mon, 13 Sep 2010 14:26:46 GMT
From: andy white <andywhite@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: syslogd doesn't support ipv6 addrs as destination (patch included)
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150530
>Category:       bin
>Synopsis:       [patch] syslogd(8) doesn't support ipv6 addrs as destination
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bapt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 13 14:30:05 UTC 2010
>Closed-Date:    Sat Oct 13 21:18:07 UTC 2012
>Last-Modified:  Sat Oct 13 21:18:07 UTC 2012
>Originator:     andy white
>Release:        6.4 (also verified in 8.0)
>Organization:
>Environment:
FreeBSD fbsd64.x.local 6.4-RELEASE FreeBSD 6.4-RELEASE #0: Wed Nov 26 11:43:51 UTC 2008     root@dessler.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
using a ipv4 or hostname (resolves to AAAA or A ) target works fine like this

local7.* @hostname or local7.* @192.168.1.1

but using a v6 address doesn't , like this

local7.* @2001:770:1cc:caab:2a0:77ff:f403:8398 or local7.* @[2001:770:1cc:caab:2a0:77ff:f403:8398]

This is because syslogd.c uses colon as the port separator and this get's broken as a v6 address has colons within it.
>How-To-Repeat:

use this

local7.* @[2001:770:1cc:caab:2a0:77ff:f403:8398]  

in your syslog.conf
>Fix:
Attached is a patch to parse an ipv6 address correctly. ipv6 address must be enclosed in square brackets [] inline with rfc3986. Patch is against 8.0

so valid syslog.conf entries are


local7.* @[2001:770:1cc:caab:2a0:77ff:f403:8398]  

and


local7.* @[2001:770:1cc:caab:2a0:77ff:f403:8398]:514

etc.

Patch attached with submission follows:

1936c1936
< 			while (*p && (*p != ':') && (i-- > 0)) {
---
> 			while (*p && (*p != ':') && (*p != '[') && (i-- > 0)) {
1938a1939,1945
> 			if (*p == '[') {
> 				p++;
> 				while (*p && (*p != ']') && (i-- > 0)) {
> 					*tp++ = *p++;
> 				}
> 				p++;
> 			}			


>Release-Note:
>Audit-Trail:

From: CSS <css@morefoo.com>
To: bug-followup@FreeBSD.org,
 andywhite@gmail.com
Cc:  
Subject: Re: bin/150530: [patch] syslogd(8) doesn't support ipv6 addrs as destination
Date: Fri, 15 Apr 2011 17:06:36 -0400

 Just a quick note regarding this problem and patch.
 
 It applied cleanly to an 8.1 box, but seems to not fix the problem.   
 Running syslogd with debug info gives this message on startup:
 
 cfline("auth.info;authpriv.info                          
 @[2001:xxxx:xxxx:0000:0000:0000:0000:0002]:514", f, "*", "*")
 syslogd: servname not supported for ai_socktype: Bad file descriptor
 
 This is in a jail that only has IPv6 connectivity.

From: Andy white <andywhite@gmail.com>
To: bug-followup@FreeBSD.org,
 andywhite@gmail.com
Cc:  
Subject: Re: bin/150530: [patch] syslogd(8) doesn't support ipv6 addrs as destination
Date: Wed, 4 May 2011 23:03:36 +0100

 I tested in freebsd 8.2  without error.  What is your syslog.conf line ? =
 I assume your xxxx's in your output our from you anonymizing your config =
 ?
 
 fbsd82# cat /etc/syslog.conf | grep '\['
 auth.info;authpriv.info				=
 @[2001:770:1cc:0000:0000:0000:0000:0002]:514
 local7.* 					=
 @[2001:770:1cc:caab:2a0:77ff:f403:8398]:514
 
 fbsd82# /usr/src/usr.sbin/syslogd/syslogd -d | grep '2001'
 cfline("auth.info;authpriv.info				=
 @[2001:770:1cc:0000:0000:0000:0000:0002]:514", f, "*", "*")
 cfline("local7.* 					=
 @[2001:770:1cc:caab:2a0:77ff:f403:8398]:514", f, "*", "*")
 X X X X 6 X X X X X 6 X X X X X X X X X X X X X X FORW: =
 2001:770:1cc:0000:0000:0000:0000:0002
 X X X X X X X X X X X X X X X X X X X X X X X 7 X FORW: =
 2001:770:1cc:caab:2a0:77ff:f403:8398
 
 

From: Jim Pingle <jimp@pfsense.org>
To: bug-followup@FreeBSD.org, andywhite@gmail.com
Cc:  
Subject: Re: bin/150530: [patch] syslogd(8) doesn&#39;t support ipv6 addrs
 as destination
Date: Wed, 18 Apr 2012 17:23:41 -0400

 Just to add another data point to this PR:
 
 We integrated this patch into our pfSense 2.1 snapshot builds based on
 FreeBSD 8.3 and it's working for me here. I can forward @[ipv6ip] as
 expected using a binary built from the patched code.
 
 Jim

From: Pierre Guinoiseau <pierre@guinoiseau.eu>
To: bug-followup@FreeBSD.org, andywhite@gmail.com
Cc:  
Subject: Re: bin/150530: [patch] syslogd(8) doesn&#39;t support ipv6 addrs as
 destination
Date: Wed, 12 Sep 2012 01:04:25 +0200

 --ni93GHxFvA+th69W
 Content-Type: text/plain; charset=utf-8
 Content-Disposition: inline
 
 Hi,
 
 I applied this patch on FreeBSD 9.1-RC1 (in IPv6-only jails) and it works fine
 too. This bug is 2 years old, the patch is fine, and it is necessary for IPv6
 enabled setups, why is it still not fixed?
 
 Pierre
 
 
 --ni93GHxFvA+th69W
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (FreeBSD)
 
 iEYEARECAAYFAlBPw3kACgkQJikNJSAyef/hiwCfdH3Ly3ei0H264L9KnIexVs9x
 MjMAnj48J8qP2urpfUI76Dz5yX5gIpaK
 =AgeZ
 -----END PGP SIGNATURE-----
 
 --ni93GHxFvA+th69W--
Responsible-Changed-From-To: freebsd-bugs->bapt 
Responsible-Changed-By: bapt 
Responsible-Changed-When: Wed Sep 12 10:37:20 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150530 
State-Changed-From-To: open->closed 
State-Changed-By: bapt 
State-Changed-When: Wed Sep 12 10:40:33 UTC 2012 
State-Changed-Why:  
Fixed with a different patch, Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150530 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/150530: commit references a PR
Date: Wed, 12 Sep 2012 10:40:15 +0000 (UTC)

 Author: bapt
 Date: Wed Sep 12 10:39:47 2012
 New Revision: 240389
 URL: http://svn.freebsd.org/changeset/base/240389
 
 Log:
   Add support for ipv6 addresses as destination
   
   PR:		bin/150530
   Submitted by:	andy white <andywhite@gmail.com>
   Tested by:	Olivier Cochard-Labbe <olivier@cochard.me>
   MFC after:	1 month
 
 Modified:
   head/usr.sbin/syslogd/syslogd.c
 
 Modified: head/usr.sbin/syslogd/syslogd.c
 ==============================================================================
 --- head/usr.sbin/syslogd/syslogd.c	Wed Sep 12 10:16:39 2012	(r240388)
 +++ head/usr.sbin/syslogd/syslogd.c	Wed Sep 12 10:39:47 2012	(r240389)
 @@ -1931,6 +1931,7 @@ cfline(const char *line, struct filed *f
  	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 @@ cfline(const char *line, struct filed *f
  			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 */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: closed->patched 
State-Changed-By: bapt 
State-Changed-When: Wed Sep 12 11:01:57 UTC 2012 
State-Changed-Why:  
awaiting MFC 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150530 
State-Changed-From-To: patched->closed 
State-Changed-By: bapt 
State-Changed-When: Sat Oct 13 21:18:07 UTC 2012 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=150530 
>Unformatted:
