Bug 232020 - ipv6 changes break telnetd with no DNS
ipv6 changes break telnetd with no DNS
Status: CLOSED DUPLICATE of bug 253392
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: telnet (Show other bugs)
5.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Adam Tkac
Ben Levenson
: Reopened
Depends On:
Blocks: 246258
  Show dependency treegraph
 
Reported: 2007-03-13 12:18 EDT by Bryn M. Reeves
Modified: 2013-04-30 19:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-09-03 04:49:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
patch correcting two name lookup problems (1.33 KB, patch)
2007-03-13 12:37 EDT, Bryn M. Reeves
no flags Details | Diff
clean up error messages in telnetd.c:doit() (617 bytes, patch)
2007-03-13 12:47 EDT, Bryn M. Reeves
no flags Details | Diff

  None (edit)
Description Bryn M. Reeves 2007-03-13 12:18:17 EDT
Description of problem:
The changes in name lookup introduced in netkit-telnet-0.17-ipv6.diff in the
RHEL-5 telnet packages cause telnet to fail when DNS services are unavailable.

For example, RHEL4's telnetd.c:doit() looks like this:

 ///RHEL4
   /usr/src/redhat/BUILD/netkit-telnet-0.17/telnetd/telnetd.c
   625         /* get name of connected client */
   626         hp = gethostbyaddr((char *)&who->sin_addr, sizeof (struct in_addr),
   627                 who->sin_family);
   628         if (hp)
   629                 host = hp->h_name;
   630         else
   631                 host = inet_ntoa(who->sin_addr); 

I.e. we attempt a gethostbyaddr lookup and, it it fails we fall back to using
inet_ntoa and use a string addrress.

This is changed by the above patch in RHEL-5 to:

/usr/src/redhat/BUILD/netkit-telnet-0.17/telnetd/telnetd.c
   650         /* get name of connected client */
   651         int error = -1;
   652         char namebuf[255];
   653
   654         error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL,
0, 0);
   655
   656         if (error) {                              
   657                 perror("getnameinfo: localhost");
   658                 perror(gai_strerror(error));
   659                 exit(1);
   660         }

In this version of the code, it is possible for getnameinfo() to return
EAI_AGAIN if name services are temporarily unavailable. In the old version of
the code we would get a NULL from gethostbyaddr and carry on. Now, the telnetd
process exits abruptly instead.

This is the first such problem we hit, but there are others related to the
changes in name service handling. For e.g. there is a lookup carried out on the
local hostname further on in the same function which has similar problems.

Version-Release number of selected component (if applicable):
telnet-0.17-38.el5

How reproducible:
100%

Steps to Reproduce:
1. Comment out or remove nameserver lines from  /etc/resolv.conf
2. Configure nsswitch.conf to something like:
hosts: files dns
3. Ensure there is no entry for the client in /etc/hosts
4. telnet to the system

  
Actual results:
The telnetd exits with status 1. This is easier to see if you run it in the
foreground:

# telnet -debug 23

The same thing happens when run under xinetd though.

Expected results:
telnetd does not exit & the remote user is presented with a login prompt.
Comment 1 Bryn M. Reeves 2007-03-13 12:37:19 EDT
Created attachment 149946 [details]
patch correcting two name lookup problems

This addresses the problem for me, in that I can successfully telnet into the
machine with this applied. Also tested with working DNS and didn't hit any
issues.

There are some bits of code that don't totally make sense, for e.g.:

	perror("getaddrinfo: localhost");
	perror(gai_strerror(e));
	exit(1);

Using perror here doesn't seem right - for one thing, errno will have some
random value at this point that needn't have anything to do with the
getaddrinfo we just did. 

For e.g., if we just fix the first problem, we're left with confusing error
messages like:

getaddrinfo: localhost: Connection refused
Temporary failure in name resolution: Illegal seek

When the lookup for localhost fails. I'll submit a change for that in a
separate patch.
Comment 2 Bryn M. Reeves 2007-03-13 12:47:19 EDT
Created attachment 149948 [details]
clean up error messages in telnetd.c:doit()

Change use of perror to use fprintf and gai_strerror directly.

Errors now looks something like:

getaddrinfo: localhost: Temporary failure in name resolution

The code in this part of telnetd.c still looks a bit odd to me:

		gethostname(host_name, sizeof(host_name));
		if ((e = getaddrinfo(host_name, NULL, &hints, &res)) != 0) {
			if(e != EAI_AGAIN) {
				fprintf(stderr, "getaddrinfo: localhost: %s\n",

					gai_strerror(e));
				exit(1);
			}
		}
		if(res)
			freeaddrinfo(res);

Since it only seems to check that we can lookup an address, but doesn't make
any use of the information we retrieved.
Comment 5 RHEL Product and Program Management 2007-06-05 16:34:10 EDT
This request was evaluated by Red Hat Product Management for
inclusion in a Red Hat Enterprise Linux release.  Since this
bugzilla is in a component that is not approved for the current
release, it has been closed with resolution deferred.  You may
reopen this bugzilla for consideration in the next release.
Comment 6 Adam Tkac 2007-09-03 04:49:04 EDT

*** This bug has been marked as a duplicate of 253392 ***

Note You need to log in before you can comment on or make changes to this bug.