summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2005-03-02 12:06:51 +1100
committerDamien Miller <djm@mindrot.org>2005-03-02 12:06:51 +1100
commit1227d4c93c44d09694e547b62b643afa2a321a17 (patch)
tree7863e2efa552e67527e7301857a653ef50a883ba
parent265d309ebc97447f5e710df04196e626f018cad8 (diff)
- djm@cvs.openbsd.org 2005/03/02 01:00:06
[sshconnect.c] fix addition of new hashed hostnames when CheckHostIP=yes; found and ok dtucker@
-rw-r--r--ChangeLog6
-rw-r--r--sshconnect.c35
2 files changed, 30 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 459edc97f..a5554745f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,10 @@
35 spelling (occurance -> occurrence); 35 spelling (occurance -> occurrence);
36 use prompt before examples; 36 use prompt before examples;
37 grammar; 37 grammar;
38 - djm@cvs.openbsd.org 2005/03/02 01:00:06
39 [sshconnect.c]
40 fix addition of new hashed hostnames when CheckHostIP=yes;
41 found and ok dtucker@
38 42
3920050301 4320050301
40 - (djm) OpenBSD CVS sync: 44 - (djm) OpenBSD CVS sync:
@@ -2254,4 +2258,4 @@
2254 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 2258 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
2255 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 2259 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
2256 2260
2257$Id: ChangeLog,v 1.3684 2005/03/02 01:05:06 djm Exp $ 2261$Id: ChangeLog,v 1.3685 2005/03/02 01:06:51 djm Exp $
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