ssh: canonicize the host name before looking it up in the host file
Re-apply r99054 by des in 2002. This was accidentally dropped by the update to OpenSSH 6.5p1 (r261320). This change is actually taken from r387082 of ports/security/openssh-portable/files/patch-ssh.c PR: 198043 Differential Revision: https://reviews.freebsd.org/D3103 Reviewed by: des Approved by: kib (mentor) MFC after: 3 days Relnotes: yes Sponsored by: Dell Inc.
This commit is contained in:
parent
6e5fcd99df
commit
3e74849a1e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285642
@ -1001,6 +1001,23 @@ main(int ac, char **av)
|
|||||||
shorthost[strcspn(thishost, ".")] = '\0';
|
shorthost[strcspn(thishost, ".")] = '\0';
|
||||||
snprintf(portstr, sizeof(portstr), "%d", options.port);
|
snprintf(portstr, sizeof(portstr), "%d", options.port);
|
||||||
|
|
||||||
|
/* 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 = options.address_family;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (options.local_command != NULL) {
|
if (options.local_command != NULL) {
|
||||||
debug3("expanding LocalCommand: %s", options.local_command);
|
debug3("expanding LocalCommand: %s", options.local_command);
|
||||||
cp = options.local_command;
|
cp = options.local_command;
|
||||||
|
Loading…
Reference in New Issue
Block a user