From owner-freebsd-current Sat Jan 15 6:27:16 2000 Delivered-To: freebsd-current@freebsd.org Received: from ds.express.ru (ds.express.ru [212.24.32.7]) by hub.freebsd.org (Postfix) with ESMTP id 7416C14DE4 for ; Sat, 15 Jan 2000 06:26:39 -0800 (PST) (envelope-from vova@express.ru) Received: from lanturn.kmost.express.ru ([212.24.37.109]) by ds.express.ru with esmtp (Exim 2.12 #8) id 129U9r-0004HR-00 for current@freebsd.org; Sat, 15 Jan 2000 17:26:27 +0300 Date: Sat, 15 Jan 2000 17:26:41 +0300 (MSK) From: "Vladimir B. Grebeschikov" X-Sender: vova@lanturn.kmost.express.ru To: current@freebsd.org Subject: syslogd Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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