From owner-cvs-all Thu Sep 13 0:58:55 2001 Delivered-To: cvs-all@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id AD67637B401; Thu, 13 Sep 2001 00:58:33 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f8D7wMV25977; Thu, 13 Sep 2001 10:58:22 +0300 (EEST) (envelope-from ru) Date: Thu, 13 Sep 2001 10:58:21 +0300 From: Ruslan Ermilov To: Dag-Erling Smorgrav 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> References: <200109130648.f8D6mfU01568@freefall.freebsd.org> <20010913105056.G10963@sunbay.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010913105056.G10963@sunbay.com>; from ru@FreeBSD.org on Thu, Sep 13, 2001 at 10:50:56AM +0300 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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