Created attachment 1820 [details] use getaddrinfo for sshd port lookup Ssh, in ssh_connect(), calls getaddrinfo() to get the the server endpoint address. Getaddrinfo returns a port number but this is ignored. Ssh instead makes an unnecessary call to getservbyname() to get the port number. In most cases this makes no difference, but this makes it impossible to use DNS SRV records to find ssh services. The attached patch eliminates the call to getservbyname and instead uses the port returned by getaddrinfo.
We need to be careful here, I think the port number that we obtain by getservbyname() is used to decide whether to decorate the hostname with a non default port in known_hosts.
We are freezing for the OpenSSH 5.6 release. Retargetting these bugs to the next release.
Targetting OpenSSH 5.7
Retarget unresolved bugs/features to 6.0 release
Retarget unresolved bugs/features to 6.0 release (try again - bugzilla's "change several" isn't)
I believe that if there is no SRV record, getaddrinfo will return the same port as getservbyname. I can check on this. If that's the case, the risk seems low. The question is, if there is a SRV record, and it returns something different from what getservbyname does, what port should be used for known_hosts? If we can decide on the correct behavior, I can make sure the patch does the right thing.
Retarget from 6.0 to 6.1
Retarget 6.0 => 6.1
Retarget uncompleted bugs from 6.1 => 6.2
Retarget bugs from 6.1 => 6.2
retarget to openssh-6.3
Thinking about this a little more, this patch would break hosts where "ssh" isn't in /etc/services. There are probably a few of these out there, since people like to run OpenSSH on all sorts of old things. How about we do the getservbyname lookup but only set port (to 22) if it fails? This would preserve the current working behaviour but let SRV records work too.
Retarget to openssh-6.4
Retarget 6.3 -> 6.4
Retarget incomplete bugs / feature requests to 6.6 release
Retarget to 6.7 release, since 6.6 was mostly bugfixing.
Remove from 6.6 tracking bug
untarget from 6.7; this needs a concrete design in light of hostname canonicalisation changes
I think a few lines more won't hurt nobody if it brings in any additional value. ,http://ultimatewebtraffic.com