Date: Thu, 13 Sep 2001 10:58:21 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Dag-Erling Smorgrav <des@FreeBSD.org> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/usr.sbin/syslogd syslogd.c Message-ID: <20010913105821.H10963@sunbay.com> In-Reply-To: <20010913105056.G10963@sunbay.com>; from ru@FreeBSD.org on Thu, Sep 13, 2001 at 10:50:56AM %2B0300 References: <200109130648.f8D6mfU01568@freefall.freebsd.org> <20010913105056.G10963@sunbay.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Sep 13, 2001 at 10:50:56AM +0300, Ruslan Ermilov wrote:
> On Wed, Sep 12, 2001 at 11:48:41PM -0700, Dag-Erling Smorgrav wrote:
> > des 2001/09/12 23:48:41 PDT
> >
> > Modified files:
> > usr.sbin/syslogd syslogd.c
> > Log:
> > The previous commit appeared to just shove the bug under the carpet rather
> > than really solve it. This approach (inspired by Ruslan's patch) solves
> > the real problem by stripping the local domain off the host name in the
> > config line structure.
> >
> Uhh, this actually strips ANY domain part whose length is that of the local
> domain. The correct patch (only lightly tested) would be:
>
> Index: syslogd.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.sbin/syslogd/syslogd.c,v
> retrieving revision 1.89
> diff -u -p -r1.89 syslogd.c
> --- syslogd.c 2001/09/13 06:48:41 1.89
> +++ syslogd.c 2001/09/13 07:50:08
> @@ -1545,16 +1545,13 @@ cfline(line, f, prog, host)
> if (host && *host == '*')
> host = NULL;
> if (host) {
> - int hl, dl;
> -
> /* XXX should check for NULL return */
> f->f_host = strdup(host);
> - hl = strlen(f->f_host);
> - if (f->f_host[hl-1] == '.')
> - f->f_host[--hl] = '\0';
> - dl = strlen(LocalDomain) + 1;
> - if (hl > dl && f->f_host[hl-dl] == '.')
> - f->f_host[hl-dl] = '\0';
> + if (*(bp = f->f_host + strlen(f->f_host) - 1) == '.')
> + *bp = '\0';
> + if ((bp = strchr(f->f_host, '.')) != NULL &&
> + strcasecmp(bp + 1, LocalDomain) == 0)
> + *bp = '\0';
> }
>
> /* save program name if any */
>
> Please commit it if you like.
>
More optimizations (apply over the previous patch):
--- syslogd.c~ Thu Sep 13 10:54:54 2001
+++ syslogd.c Thu Sep 13 10:56:45 2001
@@ -1545,13 +1545,13 @@
if (host && *host == '*')
host = NULL;
if (host) {
- /* XXX should check for NULL return */
- f->f_host = strdup(host);
- if (*(bp = f->f_host + strlen(f->f_host) - 1) == '.')
+ if (*(bp = host + strlen(host) - 1) == '.')
*bp = '\0';
- if ((bp = strchr(f->f_host, '.')) != NULL &&
+ if ((bp = strchr(host, '.')) != NULL &&
strcasecmp(bp + 1, LocalDomain) == 0)
*bp = '\0';
+ /* XXX should check for NULL return */
+ f->f_host = strdup(host);
}
/* save program name if any */
With this, the patch looks almost the same as it was in my reply.
Modulo the stripping of the terminal dot.
Cheers,
--
Ruslan Ermilov Oracle Developer/DBA,
ru@sunbay.com Sunbay Software AG,
ru@FreeBSD.org FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010913105821.H10963>
