|
Lines 518-529
Link Here
|
| 518 |
* is not valid. the user_hostfile will not be updated if 'readonly' is true. |
518 |
* is not valid. the user_hostfile will not be updated if 'readonly' is true. |
| 519 |
*/ |
519 |
*/ |
| 520 |
static int |
520 |
static int |
| 521 |
check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, |
521 |
check_host_key(char *hostname, struct sockaddr *hostaddr, Key *host_key, |
| 522 |
int readonly, const char *user_hostfile, const char *system_hostfile) |
522 |
int readonly, const char *user_hostfile, const char *system_hostfile) |
| 523 |
{ |
523 |
{ |
| 524 |
Key *file_key; |
524 |
Key *file_key; |
| 525 |
const char *type = key_type(host_key); |
525 |
const char *type = key_type(host_key); |
| 526 |
char *ip = NULL; |
526 |
char *ip = NULL, *host = NULL; |
| 527 |
char hostline[1000], *hostp, *fp; |
527 |
char hostline[1000], *hostp, *fp; |
| 528 |
HostStatus host_status; |
528 |
HostStatus host_status; |
| 529 |
HostStatus ip_status; |
529 |
HostStatus ip_status; |
|
Lines 574-580
Link Here
|
| 574 |
if (getnameinfo(hostaddr, salen, ntop, sizeof(ntop), |
574 |
if (getnameinfo(hostaddr, salen, ntop, sizeof(ntop), |
| 575 |
NULL, 0, NI_NUMERICHOST) != 0) |
575 |
NULL, 0, NI_NUMERICHOST) != 0) |
| 576 |
fatal("check_host_key: getnameinfo failed"); |
576 |
fatal("check_host_key: getnameinfo failed"); |
| 577 |
ip = xstrdup(ntop); |
577 |
ip = put_host_port(ntop, options.port); |
| 578 |
} else { |
578 |
} else { |
| 579 |
ip = xstrdup("<no hostip for proxy command>"); |
579 |
ip = xstrdup("<no hostip for proxy command>"); |
| 580 |
} |
580 |
} |
|
Lines 582-599
Link Here
|
| 582 |
* Turn off check_host_ip if the connection is to localhost, via proxy |
582 |
* Turn off check_host_ip if the connection is to localhost, via proxy |
| 583 |
* command or if we don't have a hostname to compare with |
583 |
* command or if we don't have a hostname to compare with |
| 584 |
*/ |
584 |
*/ |
| 585 |
if (options.check_host_ip && |
585 |
if (options.check_host_ip && (local || |
| 586 |
(local || strcmp(host, ip) == 0 || options.proxy_command != NULL)) |
586 |
strcmp(hostname, ip) == 0 || options.proxy_command != NULL)) |
| 587 |
options.check_host_ip = 0; |
587 |
options.check_host_ip = 0; |
| 588 |
|
588 |
|
| 589 |
/* |
589 |
/* |
| 590 |
* Allow the user to record the key under a different name. This is |
590 |
* Allow the user to record the key under a different name or |
| 591 |
* useful for ssh tunneling over forwarded connections or if you run |
591 |
* differentiate a non-standard port. This is useful for ssh |
| 592 |
* multiple sshd's on different ports on the same machine. |
592 |
* tunneling over forwarded connections or if you run multiple |
|
|
593 |
* sshd's on different ports on the same machine. |
| 593 |
*/ |
594 |
*/ |
| 594 |
if (options.host_key_alias != NULL) { |
595 |
if (options.host_key_alias != NULL) { |
| 595 |
host = options.host_key_alias; |
596 |
host = xstrdup(options.host_key_alias); |
| 596 |
debug("using hostkeyalias: %s", host); |
597 |
debug("using hostkeyalias: %s", host); |
|
|
598 |
} else { |
| 599 |
host = put_host_port(hostname, options.port); |
| 597 |
} |
600 |
} |
| 598 |
|
601 |
|
| 599 |
/* |
602 |
/* |
|
Lines 855-864
Link Here
|
| 855 |
} |
858 |
} |
| 856 |
|
859 |
|
| 857 |
xfree(ip); |
860 |
xfree(ip); |
|
|
861 |
xfree(host); |
| 858 |
return 0; |
862 |
return 0; |
| 859 |
|
863 |
|
| 860 |
fail: |
864 |
fail: |
| 861 |
xfree(ip); |
865 |
xfree(ip); |
|
|
866 |
xfree(host); |
| 862 |
return -1; |
867 |
return -1; |
| 863 |
} |
868 |
} |
| 864 |
|
869 |
|