summaryrefslogtreecommitdiff
path: root/sshconnect.c
diff options
context:
space:
mode:
Diffstat (limited to 'sshconnect.c')
-rw-r--r--sshconnect.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/sshconnect.c b/sshconnect.c
index bafe7ba92..49190560d 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect.c,v 1.160 2005/03/01 10:40:27 djm Exp $"); 16RCSID("$OpenBSD: sshconnect.c,v 1.161 2005/03/02 01:00:06 djm Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19 19
@@ -554,7 +554,7 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
554 char hostline[1000], *hostp, *fp; 554 char hostline[1000], *hostp, *fp;
555 HostStatus host_status; 555 HostStatus host_status;
556 HostStatus ip_status; 556 HostStatus ip_status;
557 int local = 0, host_ip_differ = 0; 557 int r, local = 0, host_ip_differ = 0;
558 int salen; 558 int salen;
559 char ntop[NI_MAXHOST]; 559 char ntop[NI_MAXHOST];
560 char msg[1024]; 560 char msg[1024];
@@ -734,18 +734,33 @@ check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
734 if (!confirm(msg)) 734 if (!confirm(msg))
735 goto fail; 735 goto fail;
736 } 736 }
737 if (options.check_host_ip && ip_status == HOST_NEW) {
738 snprintf(hostline, sizeof(hostline), "%s,%s", host, ip);
739 hostp = hostline;
740 } else
741 hostp = host;
742
743 /* 737 /*
744 * If not in strict mode, add the key automatically to the 738 * If not in strict mode, add the key automatically to the
745 * local known_hosts file. 739 * local known_hosts file.
746 */ 740 */
747 if (!add_host_to_hostfile(user_hostfile, hostp, host_key, 741 if (options.check_host_ip && ip_status == HOST_NEW) {
748 options.hash_known_hosts)) 742 snprintf(hostline, sizeof(hostline), "%s,%s",
743 host, ip);
744 hostp = hostline;
745 if (options.hash_known_hosts) {
746 /* Add hash of host and IP separately */
747 r = add_host_to_hostfile(user_hostfile, host,
748 host_key, options.hash_known_hosts) &&
749 add_host_to_hostfile(user_hostfile, ip,
750 host_key, options.hash_known_hosts);
751 } else {
752 /* Add unhashed "host,ip" */
753 r = add_host_to_hostfile(user_hostfile,
754 hostline, host_key,
755 options.hash_known_hosts);
756 }
757 } else {
758 r = add_host_to_hostfile(user_hostfile, host, host_key,
759 options.hash_known_hosts);
760 hostp = host;
761 }
762
763 if (!r)
749 logit("Failed to add the host to the list of known " 764 logit("Failed to add the host to the list of known "
750 "hosts (%.500s).", user_hostfile); 765 "hosts (%.500s).", user_hostfile);
751 else 766 else