Blame SOURCES/telnet-log-address.patch

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