From owner-freebsd-current@FreeBSD.ORG Mon Apr 17 07:37:45 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6A20816A401 for ; Mon, 17 Apr 2006 07:37:45 +0000 (UTC) (envelope-from julian@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3084443D45 for ; Mon, 17 Apr 2006 07:37:45 +0000 (GMT) (envelope-from julian@elischer.org) Received: from unknown (HELO [192.168.2.5]) ([10.251.60.91]) by a50.ironport.com with ESMTP; 17 Apr 2006 00:37:44 -0700 Message-ID: <444345C8.8090201@elischer.org> Date: Mon, 17 Apr 2006 00:37:44 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Julian Elischer References: <443310BF.4030600@elischer.org> <444344BF.7070202@elischer.org> In-Reply-To: <444344BF.7070202@elischer.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: current@freebsd.org Subject: Re: [New]: change to syslog to allow specifying prot to send to.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Apr 2006 07:37:45 -0000 Julian Elischer wrote: > Julian Elischer wrote: > >> Does anyone think that this would be useful? >> >> the syslog.conf line would look like: >> >> >> *.* @logger.mynet.com:823 > > > Here's a rewritten patch > (against 4.x but the same should apply to current) > > comments? being the first to comment on my own mail, i-- should be --i to leave guaranteed room for '\0'. > > Index: syslogd.c > =================================================================== > RCS file: /usr/local/cvsroot/freebsd/src/usr.sbin/syslogd/syslogd.c,v > retrieving revision 1.59.2.28 > diff -u -r1.59.2.28 syslogd.c > --- syslogd.c 29 Feb 2004 20:59:19 -0000 1.59.2.28 > +++ syslogd.c 17 Apr 2006 07:30:26 -0000 > @@ -1750,13 +1750,32 @@ > > switch (*p) { > case '@': > - (void)strlcpy(f->f_un.f_forw.f_hname, ++p, > - sizeof(f->f_un.f_forw.f_hname)); > + { > + char *tp; > + /* > + * scan forward to see if there is a port > defined. > + * so we can't use strlcpy.. > + */ > + i = sizeof(f->f_un.f_forw.f_hname); > + tp = f->f_un.f_forw.f_hname; > + p++; > + > + while (*p && (*p != ':') && (i-- > 0)) { > + *tp++ = *p++; > + } > + *tp = '\0'; > + } > + /* See if we copied a domain and have a port */ > + if (*p == ':') > + p++; > + else > + p = NULL; > + > memset(&hints, 0, sizeof(hints)); > hints.ai_family = family; > hints.ai_socktype = SOCK_DGRAM; > - error = getaddrinfo(f->f_un.f_forw.f_hname, "syslog", > &hints, > - &res); > + error = getaddrinfo(f->f_un.f_forw.f_hname, > + p ? p: "syslog", &hints, &res); > if (error) { > logerror(gai_strerror(error)); > break;