Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 232020 - ipv6 changes break telnetd with no DNS
Summary: ipv6 changes break telnetd with no DNS
Status: CLOSED DUPLICATE of bug 253392
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: telnet
Version: 5.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Adam Tkac
QA Contact: Ben Levenson
Depends On:
TreeView+ depends on / blocked
Reported: 2007-03-13 16:18 UTC by Bryn M. Reeves
Modified: 2013-04-30 23:35 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-09-03 08:49:04 UTC
Target Upstream Version:

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

Description Bryn M. Reeves 2007-03-13 16:18:17 UTC
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:

   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:

   650         /* get name of connected client */
   651         int error = -1;
   652         char namebuf[255];
   654         error = getnameinfo(who, wholen, namebuf, sizeof(namebuf), NULL,
0, 0);
   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):

How reproducible:

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

# 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 16:37:19 UTC
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

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

	perror("getaddrinfo: localhost");

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 16:47:19 UTC
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",


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 20:34:10 UTC
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 08:49:04 UTC

*** 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.