diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2002-11-21 07:46:49 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2002-11-21 07:46:49 +0000 |
commit | 2536c5ff25921a67417bca335806fddf2572d956 (patch) | |
tree | ae662e2c20c7e21bdba714b81cf7ad2afb871628 /usr.sbin | |
parent | 6587a4cf6b137489253c0453b1ed69490fa3bc43 (diff) |
Add -n option to print message source addresses numerically rather than
symbolically. This saves address->name lookups, which is nice on log
servers without a DNS cache.
millert@, jakob@ ok
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/syslogd/syslogd.8 | 11 | ||||
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 29 |
2 files changed, 27 insertions, 13 deletions
diff --git a/usr.sbin/syslogd/syslogd.8 b/usr.sbin/syslogd/syslogd.8 index bd02a79de81..7a98481c36c 100644 --- a/usr.sbin/syslogd/syslogd.8 +++ b/usr.sbin/syslogd/syslogd.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: syslogd.8,v 1.13 2001/05/03 21:12:25 deraadt Exp $ +.\" $OpenBSD: syslogd.8,v 1.14 2002/11/21 07:46:48 cloder Exp $ .\" .\" Copyright (c) 1983, 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ .Nd log systems messages .Sh SYNOPSIS .Nm syslogd -.Op Fl du +.Op Fl dnu .Op Fl f Ar config_file .Op Fl m Ar mark_interval .Op Fl a Ar path @@ -65,6 +65,13 @@ the default is Select the number of minutes between .Dq mark messages; the default is 20 minutes. +.It Fl n +Print source addresses numerically rather than symbolically. +This saves an address-to-name lookup for each incoming message, +which can useful when combined with the +.Fl u +option on a loghost with no DNS cache. Messages from the local +host will still be logged with the symbolic local host name. .It Fl u Select the historical .Dq insecure diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 622f91cddf5..e67142a657c 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogd.c,v 1.57 2002/09/06 19:46:52 deraadt Exp $ */ +/* $OpenBSD: syslogd.c,v 1.58 2002/11/21 07:46:48 cloder Exp $ */ /* * Copyright (c) 1983, 1988, 1993, 1994 @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)syslogd.c 8.3 (Berkeley) 4/4/94"; #else -static char rcsid[] = "$OpenBSD: syslogd.c,v 1.57 2002/09/06 19:46:52 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: syslogd.c,v 1.58 2002/11/21 07:46:48 cloder Exp $"; #endif #endif /* not lint */ @@ -193,13 +193,13 @@ 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 SecureMode = 1; /* when true, speak only unix domain socks */ +int NoDNS = 0; /* when true, will refrain from doing DNS lookups */ volatile sig_atomic_t MarkSet; volatile sig_atomic_t WantDie; volatile sig_atomic_t DoInit; -int SecureMode = 1; /* when true, speak only unix domain socks */ - void cfline(char *, struct filed *, char *); char *cvthname(struct sockaddr_in *); int decode(const char *, CODE *); @@ -237,7 +237,7 @@ main(int argc, char *argv[]) char *p, *line; FILE *fp; - while ((ch = getopt(argc, argv, "duf:m:p:a:")) != -1) + while ((ch = getopt(argc, argv, "dnuf:m:p:a:")) != -1) switch (ch) { case 'd': /* debug */ Debug++; @@ -248,6 +248,9 @@ main(int argc, char *argv[]) case 'm': /* mark interval */ MarkInterval = atoi(optarg) * 60; break; + case 'n': /* don't do DNS lookups */ + NoDNS = 1; + break; case 'p': /* path */ funixn[0] = optarg; break; @@ -469,7 +472,7 @@ usage(void) { (void)fprintf(stderr, - "usage: syslogd [-du] [-f config_file] [-m mark_interval] " + "usage: syslogd [-dnu] [-f config_file] [-m mark_interval] " "[-a path] [-p log_socket]\n"); exit(1); } @@ -884,13 +887,18 @@ cvthname(struct sockaddr_in *f) struct hostent *hp; sigset_t omask, nmask; char *p; - - dprintf("cvthname(%s)\n", inet_ntoa(f->sin_addr)); + char *ip; if (f->sin_family != AF_INET) { dprintf("Malformed from address\n"); return ("???"); } + + ip = inet_ntoa(f->sin_addr); + dprintf("cvthname(%s)\n", ip); + if (NoDNS) + return (ip); + sigemptyset(&nmask); sigaddset(&nmask, SIGHUP); sigprocmask(SIG_BLOCK, &nmask, &omask); @@ -898,9 +906,8 @@ cvthname(struct sockaddr_in *f) sizeof(struct in_addr), f->sin_family); sigprocmask(SIG_SETMASK, &omask, NULL); if (hp == 0) { - dprintf("Host name for your address (%s) unknown\n", - inet_ntoa(f->sin_addr)); - return (inet_ntoa(f->sin_addr)); + dprintf("Host name for your address (%s) unknown\n", ip); + return (ip); } if ((p = strchr(hp->h_name, '.')) && strcmp(p + 1, LocalDomain) == 0) *p = '\0'; |