diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2013-02-10 10:47:09 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2013-02-10 10:47:09 +0000 |
commit | e6251d1a22ded05abd0a3695159cabc9f8f54ede (patch) | |
tree | 7fad1169d8b80c015b85faf855d833d04df3ca19 /usr.sbin/syslogd | |
parent | 8164ac9255ffd9676c9e09f424cb9e975d704a43 (diff) |
-h includes RFC 3164 style hostnames when forwarding;
feedback and ok sthen@, mpf@
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.8 | 8 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 14 |
2 files changed, 15 insertions, 7 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index 90dc3896132..d7b7b74af07 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: syslogd.8,v 1.26 2009/10/22 15:02:13 sobrado Exp $ +.\" $OpenBSD: syslogd.8,v 1.27 2013/02/10 10:47:08 markus 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: October 22 2009 $ +.Dd $Mdocdate: February 10 2013 $ .Dt SYSLOGD 8 .Os .Sh NAME @@ -39,7 +39,7 @@ .Sh SYNOPSIS .Nm syslogd .Bk -words -.Op Fl dnu +.Op Fl dhnu .Op Fl a Ar path .Op Fl f Ar config_file .Op Fl m Ar mark_interval @@ -69,6 +69,8 @@ and do not disassociate from the controlling terminal. Specify the pathname of an alternate configuration file; the default is .Pa /etc/syslog.conf . +.It Fl h +Include the hostname when forwarding messages to a remote host. .It Fl m Ar mark_interval Select the number of minutes between .Dq mark diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index d092abf6b3f..d9ad7c72f8e 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.104 2011/07/12 11:28:31 sthen Exp $ */ +/* $OpenBSD: syslogd.c,v 1.105 2013/02/10 10:47:08 markus Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -195,6 +195,7 @@ int MarkInterval = 20 * 60; /* interval between marks in seconds */ int MarkSeq = 0; /* mark sequence number */ int SecureMode = 1; /* when true, speak only unix domain socks */ int NoDNS = 0; /* when true, will refrain from doing DNS lookups */ +int IncludeHostname = 0; /* include RFC 3164 style hostnames when forwarding */ char *ctlsock_path = NULL; /* Path to control socket */ @@ -289,7 +290,7 @@ main(int argc, char *argv[]) struct addrinfo hints, *res, *res0; FILE *fp; - while ((ch = getopt(argc, argv, "dnuf:m:p:a:s:")) != -1) + while ((ch = getopt(argc, argv, "dhnuf:m:p:a:s:")) != -1) switch (ch) { case 'd': /* debug */ Debug++; @@ -297,6 +298,9 @@ main(int argc, char *argv[]) case 'f': /* configuration file */ ConfFile = optarg; break; + case 'h': /* RFC 3164 hostnames */ + IncludeHostname = 1; + break; case 'm': /* mark interval */ MarkInterval = atoi(optarg) * 60; break; @@ -611,7 +615,7 @@ usage(void) { (void)fprintf(stderr, - "usage: syslogd [-dnu] [-a path] [-f config_file] [-m mark_interval]\n" + "usage: syslogd [-dhnu] [-a path] [-f config_file] [-m mark_interval]\n" " [-p log_socket] [-s reporting_socket]\n"); exit(1); } @@ -888,8 +892,10 @@ fprintlog(struct filed *f, int flags, char *msg) case F_FORW: dprintf(" %s\n", f->f_un.f_forw.f_hname); - if ((l = snprintf(line, sizeof(line), "<%d>%.15s %s", + if ((l = snprintf(line, sizeof(line), "<%d>%.15s %s%s%s", f->f_prevpri, (char *)iov[0].iov_base, + IncludeHostname ? LocalHostName : "", + IncludeHostname ? " " : "", (char *)iov[4].iov_base)) >= sizeof(line) || l == -1) l = strlen(line); if (sendto(pfd[PFD_INET].fd, line, l, 0, |