From owner-cvs-usrsbin Fri Jun 12 10:56:00 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA01611 for cvs-usrsbin-outgoing; Fri, 12 Jun 1998 10:56:00 -0700 (PDT) (envelope-from owner-cvs-usrsbin) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA00166; Fri, 12 Jun 1998 10:49:32 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id KAA13779; Fri, 12 Jun 1998 10:48:58 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma013771; Fri Jun 12 10:48:52 1998 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id KAA23287; Fri, 12 Jun 1998 10:48:51 -0700 (PDT) From: Archie Cobbs Message-Id: <199806121748.KAA23287@bubba.whistle.com> Subject: Re: cvs commit: src/usr.sbin/syslogd syslog.conf.5 syslogd.c In-Reply-To: <199806112100.XAA03394@gvr.gvr.org> from Guido van Rooij at "Jun 11, 98 11:00:46 pm" To: guido@gvr.org (Guido van Rooij) Date: Fri, 12 Jun 1998 10:48:51 -0700 (PDT) Cc: julian@FreeBSD.ORG, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-usrsbin@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-cvs-usrsbin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk 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) {