Bug 25833

Summary: LOG_FAC() is bogus
Product: Base System Reporter: Tony Finch <dot>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Tony Finch 2001-03-15 19:20:01 UTC
There was recently a problem with syslogd looping messages that were
printed to the console, because of the following code:
	if (LOG_FAC(pri) == LOG_CONSOLE)
		/* blah */;
the problem being that the value of the LOG_FAC() macro cannot be
compared with a facility value, which is bogus.

There are still a couple of harmless instances of this brokenness
(in syslogd.c and dmesg.c) where the facility in question is
LOG_KERN, which is fortunately zero.

Fix: This patch sanitizes LOG_FAC(), and adds a LOG_FACSHIFT macro to
replace the lost semantics. I have also replaced uses of LOG_FACMASK
that are now more correctly done with LOG_FAC() (where before that
would have been broken).

An alternative fix would be to replace the code in syslogd.c and
dmesg.c that bogusly compares the value of LOG_FAC() with LOG_KERN.

There's also some code in src/contrib/ipfilter which uses
LOG_PRIMASK and LOG_FACMASK instead of LOG_PRI() and LOG_FAC()
but I haven't touched it since it is contrib code.
Comment 1 ru freebsd_committer freebsd_triage 2001-03-15 19:48:01 UTC
On Thu, Mar 15, 2001 at 11:57:27AM +0000, Tony Finch wrote:
> 
> There was recently a problem with syslogd looping messages that were
> printed to the console, because of the following code:
> 	if (LOG_FAC(pri) == LOG_CONSOLE)
> 		/* blah */;
> 
But you can write ``LOG_FAC(pri) == LOG_FAC(LOG_CONSOLE)'' without
breaking backwards compatibility.


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
Comment 2 Poul-Henning Kamp freebsd_committer freebsd_triage 2001-03-28 19:16:06 UTC
State Changed
From-To: open->feedback

I am weary at changing the sematics of LOC_FAC(), I'm afraid 
it will break too much existing code. 

Ruslan's suggestion seems to make sense to me, could you 
provide us with a patch based on it ?
Comment 3 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-17 16:12:05 UTC
State Changed
From-To: feedback->closed

Automatic feedback timeout.  If additional feedback that warrants 
the re-opening of this PR is available but not included in the 
audit trail, please include the feedback in a reply to this message 
(preserving the Subject line) and ask that the PR be re-opened.