Blame SOURCES/telnet-log-address.patch

fbcb50
diff --git a/telnetd/telnetd.8 b/telnetd/telnetd.8
fbcb50
index 02b48c7..c72ab76 100644
fbcb50
--- a/telnetd/telnetd.8
fbcb50
+++ b/telnetd/telnetd.8
fbcb50
@@ -42,7 +42,7 @@
fbcb50
 protocol server
fbcb50
 .Sh SYNOPSIS
fbcb50
 .Nm /usr/sbin/in.telnetd
fbcb50
-.Op Fl hnNs
fbcb50
+.Op Fl ihnNs
fbcb50
 .Op Fl a Ar authmode
fbcb50
 .Op Fl D Ar debugmode
fbcb50
 .Op Fl L Ar loginprg
fbcb50
@@ -158,6 +158,10 @@ option may be used to enable encryption debugging code.
fbcb50
 .It Fl h
fbcb50
 Disables the printing of host-specific information before
fbcb50
 login has been completed.
fbcb50
+.It Fl i
fbcb50
+Disable reverse DNS lookups and use the numeric IP address in logs
fbcb50
+and REMOTEHOST environment variable. (-i switch corresponds to 
fbcb50
+utilities like last)
fbcb50
 .It Fl L Ar loginprg
fbcb50
 This option may be used to specify a different login program.
fbcb50
 By default, 
fbcb50
diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c
fbcb50
index a4988a9..2ac8bc1 100644
fbcb50
--- a/telnetd/telnetd.c
fbcb50
+++ b/telnetd/telnetd.c
fbcb50
@@ -84,6 +84,7 @@ int	hostinfo = 1;			/* do we print login banner? */
fbcb50
 int debug = 0;
fbcb50
 int debugsix = 0;
fbcb50
 int keepalive = 1;
fbcb50
+int numeric_hosts = 0;
fbcb50
 char *loginprg = _PATH_LOGIN;
fbcb50
 char *progname;
fbcb50
 int lookupself = 1;
fbcb50
@@ -113,7 +114,7 @@ main(int argc, char *argv[], char *env[])
fbcb50
 
fbcb50
 	progname = *argv;
fbcb50
 
fbcb50
-	while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:N")) != EOF) {
fbcb50
+	while ((ch = getopt(argc, argv, "d:a:e:ilhnr:I:D:B:sS:a:X:L:N")) != EOF) {
fbcb50
 		switch(ch) {
fbcb50
 
fbcb50
 #ifdef	AUTHENTICATE
fbcb50
@@ -196,6 +197,14 @@ main(int argc, char *argv[], char *env[])
fbcb50
 			break;
fbcb50
 #endif	/* AUTHENTICATE */
fbcb50
 
fbcb50
+                /*
fbcb50
+                 * Use ip address instead of hostname when
fbcb50
+                 * calling login process.
fbcb50
+                 */
fbcb50
+                case 'i':
fbcb50
+                        numeric_hosts = 1;
fbcb50
+                        break;
fbcb50
+
fbcb50
 		case 'h':
fbcb50
 			hostinfo = 0;
fbcb50
 			break;
fbcb50
@@ -663,10 +672,12 @@ doit(struct sockaddr *who, socklen_t wholen)
fbcb50
 	int error = -1;
fbcb50
 	char namebuf[255];
fbcb50
 
fbcb50
-	error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL, 0, 0);
fbcb50
+        /* if we don't want hostname '-i', skip this call to getnameinfo */
fbcb50
+        if (numeric_hosts == 0)
fbcb50
+                error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL, 0, 0);
fbcb50
 	
fbcb50
 	/* if we can't get a hostname now, settle for an address */	
fbcb50
-	if(error == EAI_AGAIN)
fbcb50
+	if(error == EAI_AGAIN || numeric_hosts != 0)
fbcb50
 		error = getnameinfo(who, wholen, namebuf, sizeof(namebuf),
fbcb50
 				NULL, 0, NI_NUMERICHOST);
fbcb50