Blame SOURCES/telnet-log-address.patch

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