[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch for syslogd, allowing program-name exclusion
- To: misc_(_at_)_openbsd_(_dot_)_org
- Subject: patch for syslogd, allowing program-name exclusion
- From: Julian Smith <jules_(_at_)_op59_(_dot_)_net>
- Date: Tue, 1 Jun 2004 10:16:47 +0100
Here's a patch for syslogd that adds support for excluding messages from a
particular programme, by prefixing the programme name with `-' in
/etc/syslogd.conf's !<prog> construct.
It would be better to also allow multiple programmes to be excluded, but I
haven't got round to that.
As an example, I've stopped my dhclient from filling up /var/log/daemon by
inserting a `!-dhclient' line at the start of /etc/syslog.conf. So it looks
like:
!-dhclient
*.err;kern.debug;auth.notice;authpriv.none;mail.crit /dev/console
*.notice;auth,authpriv,cron,ftp,kern,lpr,mail,user.none /var/log/messages
kern.debug;user.info;syslog.info /var/log/messages
auth.info /var/log/authlog
authpriv.debug /var/log/secure
cron.info /var/cron/log
daemon.info /var/log/daemon
ftp.info /var/log/xferlog
lpr.debug /var/log/lpd-errs
mail.info /var/log/maillog
#uucp.info /var/log/uucp
[...]
Index: syslog.conf.5
===================================================================
RCS file: /cvs/src/usr.sbin/syslogd/syslog.conf.5,v
retrieving revision 1.16
diff -u -r1.16 syslog.conf.5
--- syslog.conf.5 16 Mar 2004 08:50:07 -0000 1.16
+++ syslog.conf.5 1 Jun 2004 09:03:46 -0000
@@ -105,7 +105,12 @@
The tag is a line beginning with
.Em !prog
and each block will be associated with calls to syslog from that specific
-program.
+program. If
+.Em prog
+starts with
+.Em -
+, the block will be associated with all calls to syslog except from that
+specific program.
.Pp
See
.Xr syslog 3
Index: syslogd.c
===================================================================
RCS file: /cvs/src/usr.sbin/syslogd/syslogd.c,v
retrieving revision 1.74
diff -u -r1.74 syslogd.c
--- syslogd.c 19 Jan 2004 16:06:05 -0000 1.74
+++ syslogd.c 1 Jun 2004 09:03:49 -0000
@@ -701,10 +701,14 @@
continue;
/* skip messages with the incorrect program name */
- if (f->f_program)
- if (strcmp(prog, f->f_program) != 0)
+ if (f->f_program) {
+ if (f->f_program[0]=='-') {
+ if (strcmp(prog, f->f_program+1) == 0)
+ continue;
+ }
+ else if (strcmp(prog, f->f_program) != 0)
continue;
-
+ }
if (f->f_type == F_CONSOLE && (flags & IGN_CONS))
continue;
- Julian
--
http://www.op59.net
Visit your host, monkey.org