Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jun 1998 10:48:51 -0700 (PDT)
From:      Archie Cobbs <archie@whistle.com>
To:        guido@gvr.org (Guido van Rooij)
Cc:        julian@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-usrsbin@FreeBSD.ORG
Subject:   Re: cvs commit: src/usr.sbin/syslogd syslog.conf.5 syslogd.c
Message-ID:  <199806121748.KAA23287@bubba.whistle.com>
In-Reply-To: <199806112100.XAA03394@gvr.gvr.org> from Guido van Rooij at "Jun 11, 98 11:00:46 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Guido van Rooij writes:
> Julian Elischer wrote:
> > julian      1998/06/09 21:34:58 PDT
> > 
> >   Modified files:
> >     usr.sbin/syslogd     syslog.conf.5 syslogd.c 
> >   Log:
> >   Allow syslogd to separate out kernel log messages with a known
> >   category.
> >   e.g. separate out ipfw entries to a separate file.
> 
> >From what I see this means that if the kernel spits out a message
> starting with a word frollowed by a colon, the prefix kernel: 
> is no longer printed.
> 
> I wonder if this is wanted behaviour. Shouldn't this be made optional?
> 
> -Guido

Guido,
Good comment... here's a better patch.

Thanks,
-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

Index: syslog.conf.5
===================================================================
RCS file: /cvs/freebsd/src/usr.sbin/syslogd/syslog.conf.5,v
retrieving revision 1.9
diff -c -r1.9 syslog.conf.5
*** syslog.conf.5	1997/10/20 12:55:47	1.9
--- syslog.conf.5	1998/06/12 17:48:28
***************
*** 114,120 ****
  (the former is for compatibility with the previous syslogd, if one is sharing
  syslog.conf files, for example)
  and each block will be associated with calls to syslog from that specific
! program.
  .Pp
  See
  .Xr syslog 3
--- 114,121 ----
  (the former is for compatibility with the previous syslogd, if one is sharing
  syslog.conf files, for example)
  and each block will be associated with calls to syslog from that specific
! program. A tag for ``foo'' will also match any message logged by the kernel
! with the prefix ``foo: ''.
  .Pp
  See
  .Xr syslog 3
***************
*** 294,299 ****
--- 295,304 ----
  # Save ftpd transactions along with mail and news
  !ftpd
  *.*							/var/log/spoolerr
+ 
+ # Log kernel firewall reports to a separate file
+ !ipfw
+ *.*							/var/log/ipfw
  .Ed
  .Sh FILES
  .Bl -tag -width /etc/syslog.conf -compact
Index: syslogd.c
===================================================================
RCS file: /cvs/freebsd/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.32
diff -c -r1.32 syslogd.c
*** syslogd.c	1998/05/19 12:02:41	1.32
--- syslogd.c	1998/06/12 17:48:28
***************
*** 130,135 ****
--- 130,136 ----
  #define SYNC_FILE	0x002	/* do fsync on file after printing */
  #define ADDDATE		0x004	/* add a date to the message */
  #define MARK		0x008	/* this message is a mark */
+ #define ISKERNEL	0x010	/* kernel generated message */
  
  /*
   * This structure represents the files that will have log
***************
*** 541,553 ****
  	char *msg;
  {
  	int c, pri, flags;
! 	char *lp, *p, *q, line[MAXLINE + 1];
  
- 	(void)strcpy(line, bootfile);
- 	(void)strcat(line, ": ");
- 	lp = line + strlen(line);
  	for (p = msg; *p != '\0'; ) {
! 		flags = SYNC_FILE | ADDDATE;	/* fsync file after write */
  		pri = DEFSPRI;
  		if (*p == '<') {
  			pri = 0;
--- 542,551 ----
  	char *msg;
  {
  	int c, pri, flags;
! 	char *p, *q;
  
  	for (p = msg; *p != '\0'; ) {
! 		flags = ISKERNEL | SYNC_FILE | ADDDATE;	/* fsync after write */
  		pri = DEFSPRI;
  		if (*p == '<') {
  			pri = 0;
***************
*** 561,572 ****
  		}
  		if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
  			pri = DEFSPRI;
! 		q = lp;
! 		while (*p != '\0' && (c = *p++) != '\n' &&
! 		    q < &line[MAXLINE])
! 			*q++ = c;
! 		*q = '\0';
! 		logmsg(pri, line, LocalHostName, flags);
  	}
  }
  
--- 559,569 ----
  		}
  		if (pri &~ (LOG_FACMASK|LOG_PRIMASK))
  			pri = DEFSPRI;
! 		for (q = p; *q != '\0' && *q != '\n'; q++);
! 		if (*q != '\0')
! 			*q++ = '\0';
! 		logmsg(pri, p, LocalHostName, flags);
! 		p = q;
  	}
  }
  
***************
*** 583,592 ****
  	int flags;
  {
  	struct filed *f;
! 	int fac, msglen, omask, prilev;
  	char *timestamp;
   	char prog[NAME_MAX+1];
!  	int i;
  
  	dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n",
  	    pri, flags, from, msg);
--- 580,589 ----
  	int flags;
  {
  	struct filed *f;
! 	int i, fac, msglen, omask, prilev;
  	char *timestamp;
   	char prog[NAME_MAX+1];
! 	char buf[MAXLINE+1];
  
  	dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n",
  	    pri, flags, from, msg);
***************
*** 630,635 ****
--- 627,639 ----
  		prog[i] = msg[i];
  	}
  	prog[i] = 0;
+ 
+ 	/* add kernel prefix for kernel messages */
+ 	if (flags & ISKERNEL) {
+ 		snprintf(buf, sizeof(buf), "%s: %s", bootfile, msg);
+ 		msg = buf;
+ 		msglen = strlen(buf);
+ 	}
  
  	/* log the message to the particular outputs */
  	if (!Initialized) {

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806121748.KAA23287>