summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/syslogd/syslog.conf.515
-rw-r--r--usr.sbin/syslogd/syslogd.c17
2 files changed, 27 insertions, 5 deletions
diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5
index 756fe9f3ec5..d66a2cd01fc 100644
--- a/usr.sbin/syslogd/syslog.conf.5
+++ b/usr.sbin/syslogd/syslog.conf.5
@@ -26,7 +26,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93
-.\" $OpenBSD: syslog.conf.5,v 1.16 2004/03/16 08:50:07 jmc Exp $
+.\" $OpenBSD: syslog.conf.5,v 1.17 2004/06/03 12:21:08 dhartmei Exp $
.\" $NetBSD: syslog.conf.5,v 1.4 1996/01/02 17:41:46 perry Exp $
.\"
.Dd June 9, 1993
@@ -106,6 +106,11 @@ The tag is a line beginning with
.Em !prog
and each block will be associated with calls to syslog from that specific
program.
+When a messages matches multiple blocks, the action of each matching
+block is taken.
+.Em !!prog
+causes the subsequent block to abort evaluation when a message matches,
+ensuring that only a single action is taken.
.Pp
See
.Xr syslog 3
@@ -227,6 +232,14 @@ configuration file.
.Sh EXAMPLES
A configuration file might appear as follows:
.Bd -literal
+# Log info (and higher) messages from spamd only to
+# a dedicated file, discarding debug messages.
+# Matching messages abort evaluation of further rules.
+!!spamd
+daemon.info /var/log/spamd
+daemon.debug /dev/null
+!*
+
# Log all kernel messages, authentication messages of
# level notice or higher and anything of level err or
# higher to the console.
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 85bad7fc242..ebee9fb1ae0 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.78 2004/06/03 08:21:40 otto Exp $ */
+/* $OpenBSD: syslogd.c,v 1.79 2004/06/03 12:21:08 dhartmei Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -39,7 +39,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94";
#else
-static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.78 2004/06/03 08:21:40 otto Exp $";
+static const char rcsid[] = "$OpenBSD: syslogd.c,v 1.79 2004/06/03 12:21:08 dhartmei Exp $";
#endif
#endif /* not lint */
@@ -157,6 +157,7 @@ struct filed {
int f_prevlen; /* length of f_prevline */
int f_prevcount; /* repetition cnt of prevline */
int f_repeatcount; /* number of "repeated" msgs */
+ int f_quick; /* abort when matched */
};
/*
@@ -677,7 +678,7 @@ logmsg(int pri, char *msg, char *from, int flags)
/* extract program name */
for(i = 0; i < NAME_MAX; i++) {
- if (!isalnum(msg[i]))
+ if (!isalnum(msg[i]) && msg[i] != '-')
break;
prog[i] = msg[i];
}
@@ -754,6 +755,9 @@ logmsg(int pri, char *msg, char *from, int flags)
fprintlog(f, flags, msg);
}
}
+
+ if (f->f_quick)
+ break;
}
(void)sigprocmask(SIG_SETMASK, &omask, NULL);
}
@@ -1147,7 +1151,7 @@ init(void)
continue;
}
for (i = 0; i < NAME_MAX; i++) {
- if (!isalnum(p[i]))
+ if (!isalnum(p[i]) && p[i] != '-' && p[i] != '!')
break;
prog[i] = p[i];
}
@@ -1235,6 +1239,11 @@ cfline(char *line, struct filed *f, char *prog)
f->f_pmask[i] = INTERNAL_NOPRI;
/* save program name if any */
+ if (*prog == '!') {
+ f->f_quick = 1;
+ prog++;
+ } else
+ f->f_quick = 0;
if (!strcmp(prog, "*"))
prog = NULL;
else {