DNS lookup

Stefan Mangard smang at cs.jhu.edu
Tue Apr 11 10:20:33 EST 2000


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);

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

More information about the openssh-unix-dev mailing list