Mailing List Archive

DNS lookup
Hi,

I have a question concerning the linux code of openssh-1.2.3:

When I started working with openssh I recognised that openssh stores a
hostkey twice if one uses the full hostname and later on only the machine
name (for a local machine).

for example if one calls: ssh jhunix
and later session starts with: ssh jhunix.jhu.edu

openssh stores two times the same key in the ssh_known_keys file.

Is this intended? If so, why?

After looking through the code I found this function call in ssh.c:

/* Find canonic host name. */

if (strchr(host, '.') == 0) {
struct addrinfo hints;
struct addrinfo *ai = NULL;
int errgai;
memset(&hints, 0, sizeof(hints));
hints.ai_family = IPv4or6;
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
errgai = getaddrinfo(host, NULL, &hints, &ai);
if (errgai == 0) {
if (ai->ai_canonname != NULL)
host = xstrdup(ai->ai_canonname);
freeaddrinfo(ai);
}
}

Unfortunately the function getaddrinfo, which is in fake-getaddrinfo.c
doesn't return the full hostname as it (at least I think so) should.