|
Lines 502-513
confirm(const char *prompt)
Link Here
|
| 502 |
* is not valid. the user_hostfile will not be updated if 'readonly' is true. |
502 |
* is not valid. the user_hostfile will not be updated if 'readonly' is true. |
| 503 |
*/ |
503 |
*/ |
| 504 |
static int |
504 |
static int |
| 505 |
check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, |
505 |
check_host_key(char *hostname, struct sockaddr *hostaddr, Key *host_key, |
| 506 |
int readonly, const char *user_hostfile, const char *system_hostfile) |
506 |
int readonly, const char *user_hostfile, const char *system_hostfile) |
| 507 |
{ |
507 |
{ |
| 508 |
Key *file_key; |
508 |
Key *file_key; |
| 509 |
const char *type = key_type(host_key); |
509 |
const char *type = key_type(host_key); |
| 510 |
char *ip = NULL; |
510 |
char *ip = NULL, *host = NULL; |
| 511 |
char hostline[1000], *hostp, *fp; |
511 |
char hostline[1000], *hostp, *fp; |
| 512 |
HostStatus host_status; |
512 |
HostStatus host_status; |
| 513 |
HostStatus ip_status; |
513 |
HostStatus ip_status; |
|
Lines 554-560
check_host_key(char *host, struct sockad
Link Here
|
| 554 |
if (getnameinfo(hostaddr, hostaddr->sa_len, ntop, sizeof(ntop), |
554 |
if (getnameinfo(hostaddr, hostaddr->sa_len, ntop, sizeof(ntop), |
| 555 |
NULL, 0, NI_NUMERICHOST) != 0) |
555 |
NULL, 0, NI_NUMERICHOST) != 0) |
| 556 |
fatal("check_host_key: getnameinfo failed"); |
556 |
fatal("check_host_key: getnameinfo failed"); |
| 557 |
ip = xstrdup(ntop); |
557 |
ip = put_host_port(ntop, options.port); |
| 558 |
} else { |
558 |
} else { |
| 559 |
ip = xstrdup("<no hostip for proxy command>"); |
559 |
ip = xstrdup("<no hostip for proxy command>"); |
| 560 |
} |
560 |
} |
|
Lines 562-579
check_host_key(char *host, struct sockad
Link Here
|
| 562 |
* Turn off check_host_ip if the connection is to localhost, via proxy |
562 |
* Turn off check_host_ip if the connection is to localhost, via proxy |
| 563 |
* command or if we don't have a hostname to compare with |
563 |
* command or if we don't have a hostname to compare with |
| 564 |
*/ |
564 |
*/ |
| 565 |
if (options.check_host_ip && |
565 |
if (options.check_host_ip && (local || |
| 566 |
(local || strcmp(host, ip) == 0 || options.proxy_command != NULL)) |
566 |
strcmp(hostname, ip) == 0 || options.proxy_command != NULL)) |
| 567 |
options.check_host_ip = 0; |
567 |
options.check_host_ip = 0; |
| 568 |
|
568 |
|
| 569 |
/* |
569 |
/* |
| 570 |
* Allow the user to record the key under a different name. This is |
570 |
* Allow the user to record the key under a different name or |
| 571 |
* useful for ssh tunneling over forwarded connections or if you run |
571 |
* differentiate a non-standard port. This is useful for ssh |
| 572 |
* multiple sshd's on different ports on the same machine. |
572 |
* tunneling over forwarded connections or if you run multiple |
|
|
573 |
* sshd's on different ports on the same machine. |
| 573 |
*/ |
574 |
*/ |
| 574 |
if (options.host_key_alias != NULL) { |
575 |
if (options.host_key_alias != NULL) { |
| 575 |
host = options.host_key_alias; |
576 |
host = xstrdup(options.host_key_alias); |
| 576 |
debug("using hostkeyalias: %s", host); |
577 |
debug("using hostkeyalias: %s", host); |
|
|
578 |
} else { |
| 579 |
host = put_host_port(hostname, options.port); |
| 577 |
} |
580 |
} |
| 578 |
|
581 |
|
| 579 |
/* |
582 |
/* |
|
Lines 835-844
check_host_key(char *host, struct sockad
Link Here
|
| 835 |
} |
838 |
} |
| 836 |
|
839 |
|
| 837 |
xfree(ip); |
840 |
xfree(ip); |
|
|
841 |
xfree(host); |
| 838 |
return 0; |
842 |
return 0; |
| 839 |
|
843 |
|
| 840 |
fail: |
844 |
fail: |
| 841 |
xfree(ip); |
845 |
xfree(ip); |
|
|
846 |
xfree(host); |
| 842 |
return -1; |
847 |
return -1; |
| 843 |
} |
848 |
} |
| 844 |
|
849 |
|