From: djm Date: Tue, 17 Jul 2018 13:51:47 +0000 (+0000) Subject: allow shell globs to match program and hostname selector tags via X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=dce36526c4baa9e522b9e616cd41a07542404ead;p=openbsd allow shell globs to match program and hostname selector tags via fnmatch(3); ok sthen@ bluhm@ --- diff --git a/usr.sbin/syslogd/syslog.conf.5 b/usr.sbin/syslogd/syslog.conf.5 index 488d6e3023f..b444a6556a9 100644 --- a/usr.sbin/syslogd/syslog.conf.5 +++ b/usr.sbin/syslogd/syslog.conf.5 @@ -26,10 +26,10 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)syslog.conf.5 8.1 (Berkeley) 6/9/93 -.\" $OpenBSD: syslog.conf.5,v 1.36 2018/02/02 10:53:44 jmc Exp $ +.\" $OpenBSD: syslog.conf.5,v 1.37 2018/07/17 13:51:47 djm Exp $ .\" $NetBSD: syslog.conf.5,v 1.4 1996/01/02 17:41:46 perry Exp $ .\" -.Dd $Mdocdate: February 2 2018 $ +.Dd $Mdocdate: July 17 2018 $ .Dt SYSLOG.CONF 5 .Os .Sh NAME @@ -102,7 +102,7 @@ Each block of lines is separated from the previous block by a tag. The tag is a line beginning with .Em !prog and each block will be associated with calls to syslog from that specific -program. +program (matched using shell globbing rules). When a message matches multiple blocks, the action of each matching block is taken. If no tag is specified at the beginning of the file, diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 3323a5523d2..da02de04b21 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.254 2017/11/24 23:11:42 bluhm Exp $ */ +/* $OpenBSD: syslogd.c,v 1.255 2018/07/17 13:51:47 djm Exp $ */ /* * Copyright (c) 2014-2017 Alexander Bluhm @@ -98,6 +98,7 @@ #include #include #include +#include #include #include #include @@ -1823,9 +1824,9 @@ logline(int pri, int flags, char *from, char *msg) continue; /* skip messages with the incorrect program or hostname */ - if (f->f_program && strcmp(prog, f->f_program) != 0) + if (f->f_program && fnmatch(f->f_program, prog, 0) != 0) continue; - if (f->f_hostname && strcmp(from, f->f_hostname) != 0) + if (f->f_hostname && fnmatch(f->f_hostname, from, 0) != 0) continue; if (f->f_type == F_CONSOLE && (flags & IGN_CONS))