Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 04 Apr 2006 17:35:11 -0700
From:      Julian Elischer <julian@elischer.org>
To:        current@freebsd.org
Subject:   change to syslog to allow specifying prot to send to..
Message-ID:  <443310BF.4030600@elischer.org>

next in thread | raw e-mail | index | archive | help
Does anyone think that  this would be useful?

the syslog.conf line would look like:


*.*                         @logger.mynet.com:823

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   5 Apr 2006 00:33:14 -0000
@@ -168,7 +168,7 @@
                struct {
                        char    f_hname[MAXHOSTNAMELEN];
                        struct addrinfo *f_addr;
-
+                       u_short port;
                } f_forw;               /* forwarding address */
                char    f_fname[MAXPATHLEN];
                struct {
@@ -1749,14 +1749,30 @@
                p++;
 
        switch (*p) {
+               char * tp;
+               char *tp2;
        case '@':
-               (void)strlcpy(f->f_un.f_forw.f_hname, ++p,
+               /*
+                * scan forward to see if there is a port defined.
+                */
+               tp2 = NULL;
+               tp = ++p;
+               while (*tp && (*tp++ != ':')) ;
+               if (*tp == ':') {
+                       *tp++ = '\0';
+                       if (*tp) {
+                               tp2 = tp;
+                       }
+               }
+
+               (void)strlcpy(f->f_un.f_forw.f_hname, p,
                        sizeof(f->f_un.f_forw.f_hname));
+               if (tp2) *--tp = ':';
                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,
+                               tp2 ? tp2: "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?443310BF.4030600>