Subject: misc/11970: add -n option to syslogd (skip DNS queries)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <nikolay.n.silkin@vanderbilt.edu>
List: netbsd-bugs
Date: 01/15/2001 18:15:27
>Number: 11970
>Category: misc
>Synopsis: add -n option to syslogd (skip DNS queries)
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: misc-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Mon Jan 15 18:15:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Nikolay Silkin
>Release: 1.5
>Organization:
Vanderbilt University
>Environment:
NetBSD classic 1.5 NetBSD 1.5 (GENERIC) #1: Wed Nov 29 00:29:52 MET 2000 root@flambard:/usr/src/sys/arch/sparc/compile/GENERIC sparc
>Description:
I would like to suggest a command line option to syslogd.
It allows to skip domain name resolution when syslogd accepts
and logs messages from remote hosts through a datagram socket.
When the option is activated, syslogd logs remote hosts IP addresses
without trying to lookup domain names.
The option is -n (analogous to netstat -n). Attached are the diff's
that one can apply to the 1.5 release source of syslogd
to achieve this effect.
>How-To-Repeat:
n/a
>Fix:
=== below is the patch for syslogd.c (in /usr/src/usr.sbin/syslogd)
--- syslogd.c Thu Jan 11 19:55:04 2001
+++ syslogd.c Thu Jan 11 19:55:04 2001
@@ -192,6 +192,7 @@
int MarkInterval = 20 * 60; /* interval between marks in seconds */
int MarkSeq = 0; /* mark sequence number */
int SecureMode = 0; /* listen only on unix domain socks */
+int UseNameService = 1; /* make domain name queries */
int NumForwards = 0; /* number of forwarding actions in conf file */
char **LogPaths; /* array of pathnames to read messages from */
@@ -228,7 +229,7 @@
char *p, *line, **pp;
struct pollfd *readfds;
- while ((ch = getopt(argc, argv, "dsf:m:p:P:")) != -1)
+ while ((ch = getopt(argc, argv, "dnsf:m:p:P:")) != -1)
switch(ch) {
case 'd': /* debug */
Debug++;
@@ -239,6 +240,9 @@
case 'm': /* mark interval */
MarkInterval = atoi(optarg) * 60;
break;
+ case 'n': /* turn off DNS queries */
+ UseNameService = 0;
+ break;
case 'p': /* path */
logpath_add(&LogPaths, &funixsize,
&funixmaxsize, optarg);
@@ -946,15 +950,19 @@
return ("???");
}
- error = getnameinfo((struct sockaddr*)f, ((struct sockaddr*)f)->sa_len,
- host, sizeof host, NULL, 0, niflag);
- if (error) {
- dprintf("Host name for your address (%s) unknown\n", ip);
- return (ip);
+ if (UseNameService) {
+ error = getnameinfo((struct sockaddr*)f, ((struct sockaddr*)f)->sa_len,
+ host, sizeof host, NULL, 0, niflag);
+ if (error) {
+ dprintf("Host name for your address (%s) unknown\n", ip);
+ return (ip);
+ }
+ if ((p = strchr(host, '.')) && strcmp(p + 1, LocalDomain) == 0)
+ *p = '\0';
+ return (host);
+ } else {
+ return(ip);
}
- if ((p = strchr(host, '.')) && strcmp(p + 1, LocalDomain) == 0)
- *p = '\0';
- return (host);
}
void
=== below are the diffs for syslogd.8 (in /usr/src/usr.sbin/syslogd)
--- syslogd.8 Thu Jan 11 19:55:04 2001
+++ syslogd.8 Thu Jan 11 19:55:04 2001
@@ -41,7 +41,7 @@
.Nd log systems messages
.Sh SYNOPSIS
.Nm "
-.Op Fl dsS
+.Op Fl dnsS
.Bk -words
.Op Fl f Ar config_file
.Ek
@@ -73,6 +73,9 @@
.It Fl m
Select the number of minutes between ``mark'' messages;
the default is 20 minutes.
+.It Fl n
+Turn off domain name queries, when syslogd accepts
+log messages from remote hosts.
.It Fl s
Select ``secure'' mode, in which syslogd does not listen on a UDP socket but
only communicates over a
>Release-Note:
>Audit-Trail:
>Unformatted: