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

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