summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2017-04-17 14:18:44 +0000
committerbluhm <bluhm@openbsd.org>2017-04-17 14:18:44 +0000
commitcf679774bcb9854e93e3d778e764574171a29b23 (patch)
tree5ef969a4d781e7b59b372df1d6e68f5ca486cc03 /usr.sbin/syslogd
parenttest display of long URIs (diff)
downloadwireguard-openbsd-cf679774bcb9854e93e3d778e764574171a29b23.tar.xz
wireguard-openbsd-cf679774bcb9854e93e3d778e764574171a29b23.zip
Add syslogd(8) option -r to suppress the summary line for pipe and
remote loghost as they are most commonly used for automated log processing. With -rr the "last message repeated" feature can be disabled completely. OK sthen@ deraadt@ jmc@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/syslogd.811
-rw-r--r--usr.sbin/syslogd/syslogd.c24
2 files changed, 24 insertions, 11 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8
index 5c243a37f83..1e51f26fc0c 100644
--- a/usr.sbin/syslogd/syslogd.8
+++ b/usr.sbin/syslogd/syslogd.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: syslogd.8,v 1.53 2017/01/02 15:58:02 bluhm Exp $
+.\" $OpenBSD: syslogd.8,v 1.54 2017/04/17 14:18:44 bluhm Exp $
.\"
.\" Copyright (c) 1983, 1986, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -30,7 +30,7 @@
.\" from: @(#)syslogd.8 8.1 (Berkeley) 6/6/93
.\" $NetBSD: syslogd.8,v 1.3 1996/01/02 17:41:48 perry Exp $
.\"
-.Dd $Mdocdate: January 2 2017 $
+.Dd $Mdocdate: April 17 2017 $
.Dt SYSLOGD 8
.Os
.Sh NAME
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.Nm syslogd
.Bk -words
-.Op Fl 46dFhnuVZ
+.Op Fl 46dFhnruVZ
.Op Fl a Ar path
.Op Fl C Ar CAfile
.Op Fl c Ar cert_file
@@ -129,6 +129,11 @@ the symbolic local host name.
Specify the pathname of an alternate log socket to be used instead;
the default is
.Pa /dev/log .
+.It Fl r
+Print duplicate lines immediately and suppress the "last message
+repeated" summary when piping to another program or forwarding to
+a remote loghost.
+If given twice, this is done for all log actions.
.It Fl S Ar listen_address
Create a TLS listen socket for receiving encrypted messages and
bind it to the specified address.
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index 17b80935d20..d86d4d26b95 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syslogd.c,v 1.241 2017/04/07 15:36:16 bluhm Exp $ */
+/* $OpenBSD: syslogd.c,v 1.242 2017/04/17 14:18:44 bluhm Exp $ */
/*
* Copyright (c) 1983, 1988, 1993, 1994
@@ -209,6 +209,7 @@ int Initialized = 0; /* set when we have initialized ourselves */
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
int PrivChild = 0; /* Exec the privileged parent process */
+int Repeat = 0; /* 0 msg repeated, 1 in files only, 2 never */
int SecureMode = 1; /* when true, speak only unix domain socks */
int NoDNS = 0; /* when true, refrain from doing DNS lookups */
int ZuluTime = 0; /* display date and time in UTC ISO format */
@@ -369,8 +370,8 @@ main(int argc, char *argv[])
tls_hostport = tls_host = NULL;
nbind = nlisten = 0;
- while ((ch = getopt(argc, argv, "46a:C:c:dFf:hK:k:m:nP:p:S:s:T:U:uVZ"))
- != -1)
+ while ((ch = getopt(argc, argv,
+ "46a:C:c:dFf:hK:k:m:nP:p:rS:s:T:U:uVZ")) != -1) {
switch (ch) {
case '4': /* disable IPv6 */
Family = PF_INET;
@@ -425,6 +426,9 @@ main(int argc, char *argv[])
case 'p': /* path */
path_unix[0] = optarg;
break;
+ case 'r':
+ Repeat++;
+ break;
case 'S': /* allow tls and listen on address */
tls_hostport = optarg;
if ((p = strdup(optarg)) == NULL)
@@ -455,6 +459,7 @@ main(int argc, char *argv[])
default:
usage();
}
+ }
if (argc != optind)
usage();
@@ -1490,10 +1495,10 @@ usage(void)
{
(void)fprintf(stderr,
- "usage: syslogd [-46dFhnuVZ] [-a path] [-C CAfile] [-c cert_file]\n"
- "\t[-f config_file] [-K CAfile] [-k key_file] [-m mark_interval]\n"
- "\t[-p log_socket] [-S listen_address] [-s reporting_socket]\n"
- "\t[-T listen_address] [-U bind_address]\n");
+ "usage: syslogd [-46dFhnruVZ] [-a path] [-C CAfile]\n"
+ "\t[-c cert_file] [-f config_file] [-K CAfile] [-k key_file]\n"
+ "\t[-m mark_interval] [-p log_socket] [-S listen_address]\n"
+ "\t[-s reporting_socket] [-T listen_address] [-U bind_address]\n");
exit(1);
}
@@ -1766,7 +1771,10 @@ logline(int pri, int flags, char *from, char *msg)
/*
* suppress duplicate lines to this file
*/
- if ((flags & MARK) == 0 && msglen == f->f_prevlen &&
+ if ((Repeat == 0 || (Repeat == 1 &&
+ (f->f_type != F_PIPE && f->f_type != F_FORWUDP &&
+ f->f_type != F_FORWTCP && f->f_type != F_FORWTLS))) &&
+ (flags & MARK) == 0 && msglen == f->f_prevlen &&
!strcmp(msg, f->f_prevline) &&
!strcmp(from, f->f_prevhost)) {
strlcpy(f->f_lasttime, timestamp,