From dmw@unete.cl  Sun Oct 30 07:22:20 2005
Return-Path: <dmw@unete.cl>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 23F0C16A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 30 Oct 2005 07:22:20 +0000 (GMT)
	(envelope-from dmw@unete.cl)
Received: from qmail2.ifxnetworks.com (qmail2.ifxnetworks.com [200.110.128.9])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9252743D48
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 30 Oct 2005 07:22:19 +0000 (GMT)
	(envelope-from dmw@unete.cl)
Received: (qmail 19352 invoked from network); 30 Oct 2005 07:22:19 -0000
Received: from unknown (HELO hopto.org) ([200.73.29.115])
          (envelope-sender <dmw@unete.cl>)
          by qmail2.ifxnetworks.com (qmail-ldap-1.03) with AES256-SHA encrypted SMTP
          for <FreeBSD-gnats-submit@freebsd.org>; 30 Oct 2005 07:22:08 -0000
Received: from hopto.org (fv7cq6xcvc83a33p@localhost.daemon.cl [127.0.0.1])
	by hopto.org (8.13.4/8.13.1) with ESMTP id j9U7MgEH066602
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 30 Oct 2005 04:22:42 -0300 (CLST)
	(envelope-from dmw@unete.cl)
Received: (from dmw@localhost)
	by hopto.org (8.13.4/8.13.1/Submit) id j9U7Mgjc066601;
	Sun, 30 Oct 2005 04:22:42 -0300 (CLST)
	(envelope-from dmw@unete.cl)
Message-Id: <200510300722.j9U7Mgjc066601@hopto.org>
Date: Sun, 30 Oct 2005 04:22:42 -0300 (CLST)
From: Daniel Molina Wegener <dmw@unete.cl>
Reply-To: Daniel Molina Wegener <dmw@unete.cl>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] syslogd does not pass cleanly parameters to cfline()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         88215
>Category:       bin
>Synopsis:       [patch] syslogd(8) does not pass cleanly parameters to cfline()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Oct 30 07:30:15 GMT 2005
>Closed-Date:    
>Last-Modified:  Wed Nov  9 14:40:16 GMT 2005
>Originator:     Daniel Molina Wegener
>Release:        FreeBSD 5.4-STABLE i386
>Organization:
Daniel Molina Wegener
>Environment:
System: FreeBSD dmw.hopto.org 5.4-STABLE FreeBSD 5.4-STABLE #10: Wed Oct 26 22:37:00 CLST 2005 root@dmw.hopto.org:/usr/obj/usr/src/sys/PHOBOS i386


>Description:

   In the syslogd function init(), parameters passed to cfline()
are not clean when the user attempt to use a remote host entry
as the source of syslog messages.

   Instead of a clean host name, it passes the hostname and the
last program specification in the syslog.conf file.

>How-To-Repeat:

   Put any program specification and start syslogd with -vv and -d
flags, you can see the parameters passed to cfline() function in
a list.

>Fix:

   Apply the next patch from the source tree:

--- usr.sbin/syslogd/syslogd.c.dist	Sun Oct 30 02:05:56 2005
+++ usr.sbin/syslogd/syslogd.c	Sun Oct 30 04:04:10 2005
@@ -1,3 +1,4 @@
+/* -*- mode: c; c-basic-offset: 4; c-default-style: "bsd" -*- */ 
 /*
  * Copyright (c) 1983, 1988, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -734,7 +735,7 @@
 			*q++ = '-';
 		}
 		if (isascii(c) && iscntrl(c)) {
-			if (c == '\n') {
+			if (c == '\n' || c == '\r') {
 				*q++ = ' ';
 			} else if (c == '\t') {
 				*q++ = '\t';
@@ -747,7 +748,6 @@
 		}
 	}
 	*q = '\0';
-
 	logmsg(pri, line, hname, 0);
 }
 
@@ -1588,6 +1588,7 @@
 				continue;
 		}
 		if (*p == '+' || *p == '-') {
+			(void)strlcpy(prog, "*", sizeof(prog));
 			host[0] = *p++;
 			while (isspace(*p))
 				p++;
@@ -1607,6 +1608,7 @@
 			continue;
 		}
 		if (*p == '!') {
+			(void)strlcpy(host, "*", sizeof(host));
 			p++;
 			while (isspace(*p)) p++;
 			if ((!*p) || (*p == '*')) {
>Release-Note:
>Audit-Trail:

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Daniel Molina Wegener <dmw@unete.cl>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/88215: [PATCH] syslogd does not pass cleanly parameters to cfline()
Date: Tue, 8 Nov 2005 15:43:30 +0300

 On Sun, Oct 30, 2005 at 04:22:42AM -0300, Daniel Molina Wegener wrote:
 D>    In the syslogd function init(), parameters passed to cfline()
 D> are not clean when the user attempt to use a remote host entry
 D> as the source of syslog messages.
 D> 
 D>    Instead of a clean host name, it passes the hostname and the
 D> last program specification in the syslog.conf file.
 D> 
 D> >How-To-Repeat:
 D> 
 D>    Put any program specification and start syslogd with -vv and -d
 D> flags, you can see the parameters passed to cfline() function in
 D> a list.
 
 This is expected behavior, it is documented in manual:
 
 
      A program or hostname specification may be reset by giving the program or
      hostname as `*'.
 
 This means, that program and hostname specifications are sticky and should
 be reset explicitly, if set once. Many people find this confusing (me too).
 
 I would like to change syslogd so that it resets both program and hostname
 to '*' after any regular configuration line. But before commiting this we
 need positive review from some people, and no negative review. May be current@
 mailing list will be the correct choice. You should raise this question
 on mailing lists, if you want to discuss this issue. In this case I will set
 PR to analyzed state. If you agree with current documented behavior, then you
 can ask for PR to be closed.
 
 -- 
 Totus tuus, Glebius.
 GLEBIUS-RIPN GLEB-RIPE

From: Daniel Molina Wegener <dmw@unete.cl>
To: Gleb Smirnoff <glebius@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/88215: [PATCH] syslogd does not pass cleanly parameters to cfline()
Date: Wed, 9 Nov 2005 11:32:11 -0300

    On Tue, Nov 08, 2005 at 03:43:30PM +0300,
    Gleb Smirnoff wrote:
 
 > [SNIP]
 >
 > This is expected behavior, it is documented in manual:
 > 
 > 
 >      A program or hostname specification may be reset by
 >      giving the program or hostname as `*'.
 >
 
   Ok, the manual page indicates this method to reset the
 program/host specification. The patch I've sent makes this
 task automatically when a new specficiation is given from the
 syslog.conf file.
 
 > This means, that program and hostname specifications are
 > sticky and should be reset explicitly, if set once. Many
 > people find this confusing (me too).
 
   I understand...
 
 > I would like to change syslogd so that it resets both program
 > and hostname to '*' after any regular configuration line.
 > But before commiting this we need positive review from some
 > people, and no negative review. May be current@ mailing list
 > will be the correct choice. You should raise this question on
 > mailing lists, if you want to discuss this issue. In this case
 > I will set PR to analyzed state. If you agree with current
 > documented behavior, then you can ask for PR to be closed.
 
   Ok, Is the hackers mailing list the right place to start?.
 
 > -- 
 > Totus tuus, Glebius.
 > GLEBIUS-RIPN GLEB-RIPE
 
 Regards
 -- 
  . 0 . | Daniel Molina Wegener
  . . 0 | dmw at unete dot cl
  0 0 0 | FreeBSD Power User
>Unformatted:
