From sanewo@ba2.so-net.ne.jp  Fri Jul 13 01:42:03 2001
Return-Path: <sanewo@ba2.so-net.ne.jp>
Received: from mgate08.so-net.ne.jp (mgate08.so-net.ne.jp [210.139.254.155])
	by hub.freebsd.org (Postfix) with ESMTP id 7EB5D37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jul 2001 01:42:02 -0700 (PDT)
	(envelope-from sanewo@ba2.so-net.ne.jp)
Received: from mail.ba2.so-net.ne.jp (mail.ba2.so-net.ne.jp [210.139.254.21])
	by mgate08.so-net.ne.jp (8.8.8+3.0Wbeta9/3.6W01060506) with ESMTP id RAA26251
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jul 2001 17:42:00 +0900 (JST)
Received: from ba2.so-net.ne.jp (pd300b1.tkyoea00.ap.so-net.ne.jp [61.211.0.177])
	by mail.ba2.so-net.ne.jp  with ESMTP id f6D8g0H01401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 13 Jul 2001 17:42:00 +0900 (JST)
Received: (from sanewo@localhost)
	by ba2.so-net.ne.jp (8.11.4/8.11.4) id f6D8fxk30069;
	Fri, 13 Jul 2001 17:41:59 +0900 (JST)
	(envelope-from sanewo)
Message-Id: <200107130841.f6D8fxk30069@ba2.so-net.ne.jp>
Date: Fri, 13 Jul 2001 17:41:59 +0900 (JST)
From: Takanori Saneto <sanewo@ba2.so-net.ne.jp>
To: FreeBSD-gnats-submit@freebsd.org
Subject: syslogd -u doesn't treat * as "all levels"
X-Send-Pr-Version: 3.113

>Number:         28935
>Category:       bin
>Synopsis:       syslogd -u doesn't treat * as "all levels"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dwmalone
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 13 01:50:01 PDT 2001
>Closed-Date:    Sun Dec 01 13:44:30 PST 2002
>Last-Modified:  Sun Dec 01 13:44:30 PST 2002
>Originator:     Takanori Saneto
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
an individual
>Environment:
System: FreeBSD muse.sanewo 4.3-STABLE FreeBSD 4.3-STABLE #3: Fri Jul 6 01:38:21 JST 2001 sanewo@muse.sanewo:/export/usr.obj/usr/src/sys/MUSE i386

4.3-stable CVSup'ed as of today.
Same problem seems to exist in -current as well.

>Description:

When invoked with -u, syslogd logs nothing to all.log with following
syslog.conf entry:

*.*	/var/log/all.log

 In syslogd.c, '*' is converted to priority level LOG_PRIMASK+1.
 Without -u, default comparison is '>=' and LOG_PRIMASK+1 is larger
than any actual priority level, comparison always succeeds (as
intended).
 With -u, comparison is '==' and no actual priority level is equal to
LOG_PRIMASK+1, comparison always fails.

>How-To-Repeat:

Invoke syslogd with -u and see all.log doesn't grow.

>Fix:

A quick hack patch is as follows:

--- syslogd.c.orig	Fri Jul 13 17:30:46 2001
+++ syslogd.c	Fri Jul 13 17:31:55 2001
@@ -809,6 +809,7 @@
 		if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev))
 		     ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev))
 		     ||((f->f_pcmp[fac] & PRI_GT) && (f->f_pmask[fac] > prilev))
+		     ||(f->f_pmask[fac] == LOG_PRIMASK+1)
 		     )
 		    || f->f_pmask[fac] == INTERNAL_NOPRI)
 			continue;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dwmalone 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Fri Jul 13 02:54:49 PDT 2001 
Responsible-Changed-Why:  
I'll have a look at this one. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28935 

From: David Malone <dwmalone@maths.tcd.ie>
To: freebsd-gnats-submit@FreeBSD.org, sanewo@ba2.so-net.ne.jp
Cc: freebsd-audit@FreeBSD.org
Subject: Re: bin/28935: syslogd -u doesn't treat * as "all levels"
Date: Sun, 11 Aug 2002 17:31:58 +0100

 This is a possible patch for:
 
 	http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/28935
 
 which points out that "*" means completly the wrong thing if you
 run syslogd -u. It would seem to make more sense to consider "*"
 as having an explicit set of comparison flags "<=>".
 
 This also patch adds a "!" comparison flag which should be compatable
 with the same flag in the Linux version of syslogd. I'm not sure I
 find the linux semtics that intuative, but there is little point in
 being incompatable.
 
 	David.
 
 
 Index: syslog.conf.5
 ===================================================================
 RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/syslogd/syslog.conf.5,v
 retrieving revision 1.26
 diff -u -r1.26 syslog.conf.5
 --- syslog.conf.5	16 May 2002 02:28:39 -0000	1.26
 +++ syslog.conf.5	11 Aug 2002 16:20:16 -0000
 @@ -85,7 +85,7 @@
  a period
  .Pq Dq \&. ,
  an optional set of comparison flags
 -.Pq Bq <=> ,
 +.Pq Bo ! Bc Bq <=> ,
  and a
  .Em level ,
  with no intervening white-space.
 @@ -123,6 +123,15 @@
  level equal or greater than
  .Em level
  will be logged.
 +Comparison flags beginning with
 +.Do ! Dc
 +will have their logical sense inverted.
 +Thus
 +.Dq !=info
 +means all levels except info and
 +.Dq !notice
 +has the same meaning as
 +.Dq <notice .
  .Pp
  The
  .Em level
 Index: syslogd.c
 ===================================================================
 RCS file: /cvs/FreeBSD-CVS/src/usr.sbin/syslogd/syslogd.c,v
 retrieving revision 1.104
 diff -u -r1.104 syslogd.c
 --- syslogd.c	25 Jul 2002 15:45:41 -0000	1.104
 +++ syslogd.c	11 Aug 2002 16:05:16 -0000
 @@ -1591,6 +1591,7 @@
  	for (p = line; *p && *p != '\t' && *p != ' ';) {
  		int pri_done;
  		int pri_cmp;
 +		int pri_invert;
  
  		/* find the end of this facility name list */
  		for (q = p; *q && *q != '\t' && *q != ' ' && *q++ != '.'; )
 @@ -1599,6 +1600,11 @@
  		/* get the priority comparison */
  		pri_cmp = 0;
  		pri_done = 0;
 +		pri_invert = 0;
 +		if (*q == '!') {
 +			pri_invert = 1;
 +			q++;
 +		}
  		while (!pri_done) {
  			switch (*q) {
  			case '<':
 @@ -1618,11 +1624,6 @@
  				break;
  			}
  		}
 -		if (!pri_cmp)
 -			pri_cmp = (UniquePriority)
 -				  ? (PRI_EQ)
 -				  : (PRI_EQ | PRI_GT)
 -				  ;
  
  		/* collect priority name */
  		for (bp = buf; *q && !strchr("\t,; ", *q); )
 @@ -1636,6 +1637,7 @@
  		/* decode priority name */
  		if (*buf == '*') {
  			pri = LOG_PRIMASK + 1;
 +			pri_cmp = PRI_LT | PRI_EQ | PRI_GT;
  		} else {
  			pri = decode(buf, prioritynames);
  			if (pri < 0) {
 @@ -1645,6 +1647,13 @@
  				return;
  			}
  		}
 +		if (!pri_cmp)
 +			pri_cmp = (UniquePriority)
 +				  ? (PRI_EQ)
 +				  : (PRI_EQ | PRI_GT)
 +				  ;
 +		if (pri_invert)
 +			pri_cmp ^= PRI_LT | PRI_EQ | PRI_GT;
  
  		/* scan facilities */
  		while (*p && !strchr("\t.; ", *p)) {
State-Changed-From-To: open->closed 
State-Changed-By: dwmalone 
State-Changed-When: Sun Dec 1 13:44:05 PST 2002 
State-Changed-Why:  
Now fixed in -current and -stable. 

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