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.
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.
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.
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.
*** This bug has been marked as a duplicate of 253392 ***