Blame SOURCES/telnet-log-address.patch

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