summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2015-08-31 20:44:48 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2015-08-31 20:44:48 +0000
commitd6205d6e6fef15bab811c6b3c8baed69bd6c0d62 (patch)
treed64f9f5efde2974cf5b1c7de5e438356480af3c9 /usr.sbin
parentd2f0dfc8fd2617a465bfc88a69358dee983575e0 (diff)
The !prog and +host features allow to select log messages from a
specific programm or host. It does not make sense to truncate the string from the config at some character from a list. Just take whatever the user specified as progname or hostname. If it contains funky charactes it will not match and the action is not taken. This fixes matching with IP addresses if syslogd is started with -n. OK semarie@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/syslogd/syslogd.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 4e59a708f8d..07976b4b664 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.179 2015/08/27 17:53:35 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.180 2015/08/31 20:44:47 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -1937,7 +1937,7 @@ die(int signo)
void
init(void)
{
- char progblock[NAME_MAX+1], hostblock[NAME_MAX+1], *cline, *p;
+ char progblock[NAME_MAX+1], hostblock[NAME_MAX+1], *cline, *p, *q;
struct filed_list mb;
struct filed *f, *m;
FILE *cf;
@@ -2025,40 +2025,22 @@ init(void)
continue;
if (*p == '\0' || *p == '#')
continue;
- if (*p == '!') {
+ if (*p == '!' || *p == '+') {
+ q = (*p == '!') ? progblock : hostblock;
p++;
while (isspace((unsigned char)*p))
p++;
- if (!*p || (*p == '*' && (!p[1] ||
+ if (*p == '\0' || (*p == '*' && (p[1] == '\0' ||
isspace((unsigned char)p[1])))) {
- strlcpy(progblock, "*", sizeof(progblock));
+ strlcpy(q, "*", NAME_MAX+1);
continue;
}
for (i = 0; i < NAME_MAX; i++) {
- if (!isalnum((unsigned char)p[i]) &&
- p[i] != '-' && p[i] != '!')
+ if (*p == '\0' || isspace((unsigned char)*p))
break;
- progblock[i] = p[i];
+ *q++ = *p++;
}
- progblock[i] = 0;
- continue;
- }
- if (*p == '+') {
- p++;
- while (isspace((unsigned char)*p))
- p++;
- if (!*p || (*p == '*' && (!p[1] ||
- isspace((unsigned char)p[1])))) {
- strlcpy(hostblock, "*", sizeof(hostblock));
- continue;
- }
- for (i = 0; i < NAME_MAX; i++) {
- if (!isalnum((unsigned char)p[i]) &&
- p[i] != '-' && p[i] != '+')
- break;
- hostblock[i] = p[i];
- }
- hostblock[i] = 0;
+ *q = '\0';
continue;
}