Date: Tue, 28 Mar 2006 20:56:25 -0500 From: Tom Rhodes <trhodes@FreeBSD.org> To: Rink Springer <rink@rink.nu> Cc: arch@FreeBSD.org Subject: Re: [RFC] Syslogd service patch Message-ID: <20060328205625.658396e8.trhodes@FreeBSD.org> In-Reply-To: <20060328070332.GA53789@rink.nu> References: <20060328070332.GA53789@rink.nu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 28 Mar 2006 09:03:32 +0200 Rink Springer <rink@rink.nu> wrote: > Hi everyone, > > I've devised a patch for syslogd, which allows you to specify a service > name when logging remotely. > > This is all embedded in the current syntax. For logging remote under a > different service, you can use @1.2.3.4:service [1]; for binding to a > different service, you can use 'syslogd -b 1.2.3.4:service'. No breakage > is introduced as the default service remains 'syslog'. > > The patch is at http://rink.nu/tmp/syslogd.diff, which I'd like to > commit. Does anyone have questions or comments? > > [1] OpenBSD also has this functionality diff -rubB /usr/src/usr.sbin/syslogd/syslog.conf.5 syslogd/syslog.conf.5 --- /usr/src/usr.sbin/syslogd/syslog.conf.5 Thu Aug 18 17:01:27 2005 +++ syslogd/syslog.conf.5 Sat Mar 25 17:40:56 2006 @@ -336,7 +336,9 @@ sign). Selected messages are forwarded to the .Xr syslogd 8 -program on the named host. +program on the named host. host:service may be Need a new line here, perhaps reword to avoid starting a sentence with lower cased words. +used to specify a host with a different service (default is +syslog). ^^^^^^^ Add a period. .It A comma separated list of users. Selected messages are written to those users diff -rubB /usr/src/usr.sbin/syslogd/syslogd.8 syslogd/syslogd.8 --- /usr/src/usr.sbin/syslogd/syslogd.8 Wed Apr 13 05:19:41 2005 +++ syslogd/syslogd.8 Sat Mar 25 17:37:28 2006 @@ -38,7 +38,7 @@ .Nm .Op Fl 46Acdknosuv .Op Fl a Ar allowed_peer -.Op Fl b Ar bind_address +.Op Fl b Ar bind_address Oo Ar :service Oc .Op Fl f Ar config_file .Op Fl l Oo Ar mode : Oc Ns Ar path .Op Fl m Ar mark_interval @@ -127,7 +127,8 @@ will be substituted by 128. .It Xo .Sm off -.Ar domainname Op : Ar service +.Ar domainname +.Op : Ar service .Sm on .Xc Accept datagrams where the reverse address lookup yields @@ -153,10 +154,11 @@ options are ignored if the .Fl s option is also specified. -.It Fl b Ar bind_address +.It Fl b Ar bind_address Op :service Specify one specific IP address or hostname to bind to. If a hostname is specified, the IPv4 or IPv6 address which corresponds to it is used. +An optional service can be supplied as well. .It Fl c Disable the compression of repeated instances of the same line into a single line of the form diff -rubB /usr/src/usr.sbin/syslogd/syslogd.c syslogd/syslogd.c --- /usr/src/usr.sbin/syslogd/syslogd.c Sun Jan 15 18:50:37 2006 +++ syslogd/syslogd.c Sat Mar 25 17:28:49 2006 @@ -1715,7 +1715,7 @@ struct addrinfo hints, *res; int error, i, pri, syncfile; const char *p, *q; - char *bp; + char *bp, *cp; char buf[MAXLINE], ebuf[100]; dprintf("cfline(\"%s\", f, \"%s\", \"%s\")\n", line, prog, host); @@ -1869,8 +1869,13 @@ switch (*p) { case '@': + cp = strchr (p, ':'); + if (cp != NULL) + *cp++ = 0; ?? *cp++ = 0? Perhaps I'm just lost. + (void)strlcpy(f->f_un.f_forw.f_hname, ++p, sizeof(f->f_un.f_forw.f_hname)); + Is this new line on purpose? memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; @@ -1874,7 +1879,8 @@ 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, + error = getaddrinfo(f->f_un.f_forw.f_hname, + (cp == NULL) ? "syslog" : cp, &hints, &res); if (error) { logerror(gai_strerror(error)); @@ -2530,12 +2536,29 @@ { struct addrinfo hints, *res, *r; int error, maxs, *s, *socks; + char* cp, *tmpname; + + if (bindhostname != NULL) { + tmpname = strdup (bindhostname); + if (tmpname == NULL) { + logerror(strerror(errno)); + errno = 0; + die(0); + } + + cp = strchr(tmpname, ':'); + if (cp != NULL) + *cp++ = 0; + } memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_PASSIVE; hints.ai_family = af; hints.ai_socktype = SOCK_DGRAM; - error = getaddrinfo(bindhostname, "syslog", &hints, &res); + error = getaddrinfo(tmpname, (cp == NULL) ? "syslog" : cp, + &hints, &res); + if (tmpname != NULL) + free (tmpname); if (error) { logerror(gai_strerror(error)); errno = 0; -- Tom Rhodes
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060328205625.658396e8.trhodes>