From dan@dan.emsphone.com  Fri May 16 14:18:11 2003
Return-Path: <dan@dan.emsphone.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id DAA1237B401; Fri, 16 May 2003 14:18:11 -0700 (PDT)
Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id D45EF43FAF; Fri, 16 May 2003 14:18:10 -0700 (PDT)
	(envelope-from dan@dan.emsphone.com)
Received: (from dan@localhost)
	by dan.emsphone.com (8.12.9/8.12.9) id h4GLI8sQ098988;
	Fri, 16 May 2003 16:18:08 -0500 (CDT)
	(envelope-from dan)
Message-Id: <200305162118.h4GLI8sQ098988@dan.emsphone.com>
Date: Fri, 16 May 2003 16:18:08 -0500 (CDT)
From: Dan Nelson <dnelson@allantgroup.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc: gshapiro@freebsd.org
Subject: syslogd does not strip domainname from local hosts
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         52342
>Category:       bin
>Synopsis:       syslogd does not strip domainname from local hosts
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    gshapiro
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 16 14:20:10 PDT 2003
>Closed-Date:    Mon May 19 09:24:05 PDT 2003
>Last-Modified:  Mon May 19 09:24:05 PDT 2003
>Originator:     Dan Nelson
>Release:        FreeBSD 5.1-BETA i386
>Organization:
The Allant Group
>Environment:
System: FreeBSD dan.emsphone.com 5.1-BETA FreeBSD 5.1-BETA #269: Tue May 13 09:30:33 CDT 2003 zsh@dan.emsphone.com:/usr/src/sys/i386/compile/DANSMP i386


	
>Description:
	

After the commit to syslogd.c on 2003/05/04, domain removal for
machines in the same domain as the syslod server doesn't seem to work. 
This makes hostname entries in syslogd.config that have the short name
instead of FQDN fail to match.

>How-To-Repeat:
	
>Fix:

Seems to be a simple off-by-one error. Consider the case where:

  hname = "myhost.mydomain.com"
  hl = 19
  LocalDomain = "mydomain.com"
  LocalDomainLen = 12

hname[hl-LocalDomainLen] points to the 'm' in mydomain, not the dot.
(hname + hl - LocalDomainLen + 1) points to "ydomain.com".

	

Index: syslogd.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.114
diff -u -r1.114 syslogd.c
--- syslogd.c	4 May 2003 22:05:40 -0000	1.114
+++ syslogd.c	16 May 2003 21:07:53 -0000
@@ -1308,9 +1308,9 @@
 	hl = strlen(hname);
 	if (hl > 0 && hname[hl-1] == '.')
 		hname[--hl] = '\0';
-	if (hl > LocalDomainLen && hname[hl-LocalDomainLen] == '.' &&
-	    strcasecmp(hname + hl - LocalDomainLen + 1, LocalDomain) == 0)
-		hname[hl-LocalDomainLen] = '\0';
+	if (hl > LocalDomainLen && hname[hl - LocalDomainLen - 1] == '.' &&
+	    strcasecmp(hname + hl - LocalDomainLen, LocalDomain) == 0)
+		hname[hl - LocalDomainLen - 1] = '\0';
 	return (hname);
 }
 

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->gshapiro 
Responsible-Changed-By: gshapiro 
Responsible-Changed-When: Fri May 16 19:58:37 PDT 2003 
Responsible-Changed-Why:  
I made the change, I should fix it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52342 
State-Changed-From-To: open->analyzed 
State-Changed-By: gshapiro 
State-Changed-When: Fri May 16 20:06:51 PDT 2003 
State-Changed-Why:  
Dan, I believe the same sort of change is needed at lines 1635-1636. 
Do you agree? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52342 
State-Changed-From-To: analyzed->patched 
State-Changed-By: gshapiro 
State-Changed-When: Sat May 17 13:11:51 PDT 2003 
State-Changed-Why:  
Your fix has been committed to the HEAD and will be MFC'ed to RELENG_4  
shortly.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52342 
State-Changed-From-To: patched->closed 
State-Changed-By: gshapiro 
State-Changed-When: Mon May 19 09:23:46 PDT 2003 
State-Changed-Why:  
The fix has been MFC'ed to RELENG_4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=52342 
>Unformatted:
