[New]: change to syslog to allow specifying prot to send to..
Julian Elischer
julian at elischer.org
Mon Apr 17 07:37:45 UTC 2006
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;
More information about the freebsd-current
mailing list