Bug 28634

Summary: Bug in syslogd.c prevents #+hostname working
Product: Base System Reporter: Andy <andy>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Andy 2001-07-02 16:10:02 UTC
When using the "log from hostname" function in syslog.conf like:-

#+hostname
local7.=info  <tab> <tab>  /var/log/file
#+*

fails to log to file correctly, in fact, logs nothing.

Fix: 

Simple one line patch to :
File: [freebsd] / src / usr.sbin / syslogd / syslogd.c (download)
Revision 1.78, Mon May 21 22:13:55 2001 UTC (5 weeks, 6 days ago) by dwmalone 


1414d1413
<                       p++;
How-To-Repeat: Try it, it's very simple to recreate as above.
Comment 1 dwmalone freebsd_committer freebsd_triage 2001-07-02 16:16:42 UTC
Responsible Changed
From-To: freebsd-bugs->dwmalone

I'll have a look at this as I imported the hostname stuff.
Comment 2 ceri 2001-07-02 16:22:14 UTC
On Mon, Jul 02, 2001 at 08:00:23AM -0700, Andy said:
> 
> When using the "log from hostname" function in syslog.conf like:-
> 
> #+hostname
> local7.=info  <tab> <tab>  /var/log/file
> #+*
> 
> fails to log to file correctly, in fact, logs nothing.

I've been having the exact same problem :

*.*                                             /var/log/all.log
+212.250.77.217
*.*                                             /var/log/netpilot

logs all messages from 212.250.77.217 to /var/log/all.log instead of
/var/log/netpilot.

Ceri

-- 
Your local RFC Nazi
Comment 3 Andy 2001-07-02 16:41:55 UTC
It's simple to see what's going on without
using another host to syslog from/to. Just
create a syslog.conf file with the requited
spec. Then when running syslogd use -d option
and see the line cfline where it gets parsed.
You'll see it includes the leading "+" char.
My patch just skipped by one char to drop it.

I compiled and ran this and it worked straight
off.

Regards
Andy
Comment 4 dwmalone freebsd_committer freebsd_triage 2001-07-02 19:22:32 UTC
State Changed
From-To: open->analyzed

I think the problem here is that giving the full hostname doesn't work 
if the remote machine is in the same domain as the machine running syslogd. 
I'll try to fix this and improve the explaination in the man page.
Comment 5 ru freebsd_committer freebsd_triage 2001-07-03 09:42:24 UTC
On Mon, Jul 02, 2001 at 08:00:23AM -0700, Andy wrote:
> 
> When using the "log from hostname" function in syslog.conf like:-
> 
> #+hostname
> local7.=info  <tab> <tab>  /var/log/file
> #+*
> 
> fails to log to file correctly, in fact, logs nothing.
> 
Works nice here without your patch, modulo the bug David mentioned.
If the sending host is within the same domain, using FQDN for the
sending host does not work, unless the following patch is applied.

I must admit I don't like how the ``#+'' is currently implemented.
For example, it is unclear (and undocumented) from the reading
of the manpage, that the -n flag affects the hostname specification
in syslog.conf(5).


Index: syslogd.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.78
diff -u -p -r1.78 syslogd.c
--- syslogd.c	2001/05/21 22:13:55	1.78
+++ syslogd.c	2001/07/03 08:33:54
@@ -1524,8 +1524,12 @@ cfline(line, f, prog, host)
 	/* save hostname if any */
 	if (host && *host == '*')
 		host = NULL;
-	if (host)
+	if (host) {
+		if ((p = strchr(host, '.')) &&
+		    strcasecmp(p + 1, LocalDomain) == 0)
+			*p = '\0';
 		f->f_host = strdup(host);
+	}
 
 	/* save program name if any */
 	if (prog && *prog == '*')


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 6 dwmalone 2001-07-03 09:47:14 UTC
> Works nice here without your patch, modulo the bug David mentioned.
> If the sending host is within the same domain, using FQDN for the
> sending host does not work, unless the following patch is applied.

> I must admit I don't like how the ``#+'' is currently implemented.
> For example, it is unclear (and undocumented) from the reading
> of the manpage, that the -n flag affects the hostname specification
> in syslog.conf(5).

Yep - I think this could all be documented better in the man page.
I think the "-n" flag and the host selection stuff were added about
the same time and the man page was never updated to take account
of the interaction.

The patch you included would be a reasonable fix, but I think it
may be better to keep the full host name within syslogd until the
log message is written to the log. This is because syslogd trys to
reconstruct the full host name in atleasy one place after it has
truncated it, which seems silly.

	David.
Comment 7 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-09-13 06:11:14 UTC
State Changed
From-To: analyzed->feedback

Fixed in -CURRENT (unless there are other bugs which were masked by this one) 


Comment 8 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-09-13 06:11:14 UTC
Responsible Changed
From-To: dwmalone->des

I'll handle the shakedown and MFC.
Comment 9 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2001-11-27 13:50:20 UTC
State Changed
From-To: feedback->closed

This was actually MFCed siz weeks ago, but I forgot to close the PR.