Bug 2122 - ssh: Could not resolve hostname nohost: Success
Summary: ssh: Could not resolve hostname nohost: Success
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.2p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_6_3
  Show dependency treegraph
 
Reported: 2013-06-24 23:45 AEST by Petr Lautrbach
Modified: 2021-04-23 15:10 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Lautrbach 2013-06-24 23:45:16 AEST
When the resolver is not configured properly, ssh shows a "Success" error message:

/etc/nsswitch.conf:
hosts:      files dns xyz


$ ssh nohost
ssh: Could not resolve hostname nohost: Success

The message "Success" doesn't make sense given that it's in fact a system error. It's an issue of ssh_gai_strerror() which can't handle a situation when getaddrinfo() returns EAI_SYSTEM but errno is not set/is set to 0.

A potential fix:

--- a/misc.c
+++ b/misc.c
@@ -127,7 +127,7 @@ unset_nonblock(int fd)
 const char *
 ssh_gai_strerror(int gaierr)
 {
-       if (gaierr == EAI_SYSTEM)
+       if (gaierr == EAI_SYSTEM && errno != 0)
                return strerror(errno);
        return gai_strerror(gaierr);
 }
Comment 1 Petr Lautrbach 2013-06-24 23:52:53 AEST
Using the suggested patch, the message changes to:

$ ssh nohost
ssh: Could not resolve hostname nohost: System error
Comment 2 Darren Tucker 2013-06-25 00:57:36 AEST
seems reasonable to me.
Comment 3 Damien Miller 2013-07-12 10:44:07 AEST
applied - will be in 6.3. Thanks!
Comment 4 Damien Miller 2021-04-23 15:10:42 AEST
closing resolved bugs as of 8.6p1 release