On Sat, Aug 29, 2015 at 04:43:39PM +0200, Sebastien Marie wrote: > On Fri, Aug 28, 2015 at 07:53:23PM +0200, Alexander Bluhm wrote: > > On Fri, Aug 28, 2015 at 06:11:02PM +0200, Alexander Bluhm wrote: > > > The +host feature allows to select log messages from a specific > > > host. Normally syslogd does a reverse lookup on the sender's > > > address. If that fails or if syslogd has been started with the -n > > > option, the +host is matched with the IP. Unfortunatelty IP addresses > > > consist of characters that are not allowed in syslog.conf. So take > > > the list of valid characters from FreeBSD.
> > + if (!isalnum((unsigned char)*p) && > > + *p != '-' && *p != '+' && *p != '.' && > > + *p != ',' && *p != ':' && *p != '%' && > > + *p != '_') > > Does ',' is valid or could occurs in a hostname/ip ? I reconsidered it. It does not make sense to truncate the hostname in the config at some character from a list. Just take whatever the user specified as progname or hostname. ok? bluhm Index: usr.sbin/syslogd/syslogd.c =================================================================== RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/syslogd/syslogd.c,v retrieving revision 1.179 diff -u -p -r1.179 syslogd.c --- usr.sbin/syslogd/syslogd.c 27 Aug 2015 17:53:35 -0000 1.179 +++ usr.sbin/syslogd/syslogd.c 30 Aug 2015 17:06:13 -0000 @@ -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; }