Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jan 2000 17:26:41 +0300 (MSK)
From:      "Vladimir B. Grebeschikov" <vova@express.ru>
To:        current@freebsd.org
Subject:   syslogd
Message-ID:  <Pine.BSF.4.21.0001151723020.53170-100000@lanturn.kmost.express.ru>

next in thread | raw e-mail | index | archive | help

 I've make small patch to syslogd, to enable terminate search of logfiles
when matched specifig progname, like:

# log anything interesting to console
*.err;kern.debug;auth.notice;mail.crit          /dev/console
*.err                                           root
*.notice;news.err                               root
*.alert                                         root
*.emerg                                         *


# log firewall messages ONLY in this file (noy in messages below)
!!ipfw
*.*	/var/log/ipfw

!*

*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
mail.info                                       /var/log/maillog
lpr.info                                        /var/log/lpd-errs
cron.*                                          /var/cron/log

may be this patch will be interesting to other freebsd people ?


--- usr.sbin/syslogd/syslogd.c.orig	Sat Jan 15 14:56:37 2000
+++ usr.sbin/syslogd/syslogd.c	Sat Jan 15 16:57:25 2000
@@ -153,6 +153,7 @@
 #define PRI_EQ	0x2
 #define PRI_GT	0x4
 	char	*f_program;		/* program this applies to */
+	short	f_prog_excl;		/* don't match files after chane prog */
 	union {
 		char	f_uname[MAXUNAMES][UT_NAMESIZE+1];
 		struct {
@@ -657,6 +658,7 @@
 	char *timestamp;
  	char prog[NAME_MAX+1];
 	char buf[MAXLINE+1];
+	int pexcl = 0;
 
 	dprintf("logmsg: pri %o, flags %x, from %s, msg %s\n",
 	    pri, flags, from, msg);
@@ -721,6 +723,7 @@
 		return;
 	}
 	for (f = Files; f; f = f->f_next) {
+		int pok = 0;
 		/* skip messages that are incorrect priority */
 		if (!(((f->f_pcmp[fac] & PRI_EQ) && (f->f_pmask[fac] == prilev))
 		     ||((f->f_pcmp[fac] & PRI_LT) && (f->f_pmask[fac] < prilev))
@@ -729,9 +732,20 @@
 		    || f->f_pmask[fac] == INTERNAL_NOPRI)
 			continue;
 		/* skip messages with the incorrect program name */
-		if(f->f_program)
+		if(f->f_program) { 
 			if(strcmp(prog, f->f_program) != 0)
 				continue;
+			else 
+				pok = 1;
+				
+			if(f->f_prog_excl)
+				pexcl = 1;
+				
+		}
+
+		if (pexcl && !pok)
+			break; /* terminate search when f->f_program 
+				  no longer match prog */
 
 		if (f->f_type == F_CONSOLE && (flags & IGN_CONS))
 			continue;
@@ -1305,7 +1319,7 @@
 				continue;
 			}
 			for(i = 0; i < NAME_MAX; i++) {
-				if(!isalnum(p[i]))
+				if(!isalnum(p[i]) && p[i] != '!')
 					break;
 				prog[i] = p[i];
 			}
@@ -1396,7 +1410,9 @@
 	if(prog) {
 		f->f_program = calloc(1, strlen(prog)+1);
 		if(f->f_program) {
-			strcpy(f->f_program, prog);
+			f->f_prog_excl = (*prog == '!');
+			strcpy(f->f_program, prog + (f->f_prog_excl?1:0));
+			
 		}
 	}
 

--
TSB Russian Express, Moscow
Vladimir B. Grebenschikov, vova@express.ru



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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001151723020.53170-100000>