Date: Mon, 17 Apr 2006 00:37:44 -0700 From: Julian Elischer <julian@elischer.org> To: Julian Elischer <julian@elischer.org> Cc: current@freebsd.org Subject: Re: [New]: change to syslog to allow specifying prot to send to.. Message-ID: <444345C8.8090201@elischer.org> In-Reply-To: <444344BF.7070202@elischer.org> References: <443310BF.4030600@elischer.org> <444344BF.7070202@elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?444345C8.8090201>