Blame SOURCES/netkit-telnet-0.17-reallynodns.patch

fbcb50
--- netkit-telnet-0.17.orig/telnetd/telnetd.c.reallynodns	2009-03-12 14:32:29.000000000 -0700
fbcb50
+++ netkit-telnet-0.17.orig/telnetd/telnetd.c	2009-03-12 14:51:59.000000000 -0700
fbcb50
@@ -85,6 +85,7 @@
fbcb50
 int keepalive = 1;
fbcb50
 char *loginprg = _PATH_LOGIN;
fbcb50
 char *progname;
fbcb50
+int lookupself = 1;
fbcb50
 
fbcb50
 extern void usage(void);
fbcb50
 
fbcb50
@@ -111,7 +112,7 @@
fbcb50
 
fbcb50
 	progname = *argv;
fbcb50
 
fbcb50
-	while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:")) != EOF) {
fbcb50
+	while ((ch = getopt(argc, argv, "d:a:e:lhnr:I:D:B:sS:a:X:L:N")) != EOF) {
fbcb50
 		switch(ch) {
fbcb50
 
fbcb50
 #ifdef	AUTHENTICATE
fbcb50
@@ -210,6 +211,10 @@
fbcb50
 			keepalive = 0;
fbcb50
 			break;
fbcb50
 
fbcb50
+                case 'N':
fbcb50
+                        lookupself = 0;
fbcb50
+                        break;
fbcb50
+
fbcb50
 #ifdef	SecurID
fbcb50
 		case 's':
fbcb50
 			/* SecurID required */
fbcb50
@@ -393,6 +398,7 @@
fbcb50
 #endif
fbcb50
 	fprintf(stderr, " [-L login_program]");
fbcb50
 	fprintf(stderr, " [-n]");
fbcb50
+	fprintf(stderr, " [-N]");
fbcb50
 #ifdef	SecurID
fbcb50
 	fprintf(stderr, " [-s]");
fbcb50
 #endif
fbcb50
@@ -691,15 +697,20 @@
fbcb50
 
fbcb50
 		memset(&hints, '\0', sizeof(hints));
fbcb50
 		hints.ai_socktype = SOCK_STREAM;
fbcb50
-		hints.ai_flags = AI_ADDRCONFIG;
fbcb50
+		hints.ai_flags = AI_CANONNAME;
fbcb50
 
fbcb50
 		gethostname(host_name, sizeof(host_name));
fbcb50
-		if ((e = getaddrinfo(host_name, NULL, &hints, &res)) != 0) {
fbcb50
-			if(e != EAI_AGAIN) {
fbcb50
-				fprintf(stderr, "getaddrinfo: localhost %s\n", 
fbcb50
-				        gai_strerror(e));
fbcb50
-				exit(1);
fbcb50
-			}
fbcb50
+                /*
fbcb50
+                 * Optionally canonicalize the local host name, in case
fbcb50
+                 * gethostname() returns foo, we want foo.example.com
fbcb50
+                 */
fbcb50
+		if (lookupself &&
fbcb50
+                    (e = getaddrinfo(host_name, NULL, &hints, &res)) == 0) {
fbcb50
+                        if (res->ai_canonname) {
fbcb50
+                                strncpy(host_name, res->ai_canonname,
fbcb50
+                                                        sizeof(host_name)-1);
fbcb50
+                                host_name[sizeof(host_name)-1] = 0;
fbcb50
+                        }
fbcb50
 		}
fbcb50
 		if(res)
fbcb50
 			freeaddrinfo(res);
fbcb50
--- netkit-telnet-0.17.orig/telnetd/telnetd.8.reallynodns	2009-03-12 14:54:54.000000000 -0700
fbcb50
+++ netkit-telnet-0.17.orig/telnetd/telnetd.8	2009-03-12 14:56:58.000000000 -0700
fbcb50
@@ -42,7 +42,7 @@
fbcb50
 protocol server
fbcb50
 .Sh SYNOPSIS
fbcb50
 .Nm /usr/sbin/in.telnetd
fbcb50
-.Op Fl hns
fbcb50
+.Op Fl hnNs
fbcb50
 .Op Fl a Ar authmode
fbcb50
 .Op Fl D Ar debugmode
fbcb50
 .Op Fl L Ar loginprg
fbcb50
@@ -175,6 +175,10 @@
fbcb50
 if the client is still there, so that idle connections
fbcb50
 from machines that have crashed or can no longer
fbcb50
 be reached may be cleaned up.
fbcb50
+.It Fl N
fbcb50
+Do not use DNS to canonicalize the local hostname;
fbcb50
+.Fn gethostname 2
fbcb50
+returns a fully qualified name.
fbcb50
 .It Fl s
fbcb50
 This option is only enabled if
fbcb50
 .Nm telnetd