[Ttssh2-commit] [4332] 接続しようとした SSH サーバのホスト鍵と違う形式の鍵が ssh_known_hosts にある場合、鍵を置き換えるダイアログではなく追加するダイアログを表示してユーザに問い合わせるようにした

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2011年 2月 24日 (木) 00:47:30 JST


Revision: 4332
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4332
Author:   maya
Date:     2011-02-24 00:47:30 +0900 (Thu, 24 Feb 2011)

Log Message:
-----------
接続しようとした SSH サーバのホスト鍵と違う形式の鍵が ssh_known_hosts にある場合、鍵を置き換えるダイアログではなく追加するダイアログを表示してユーザに問い合わせるようにした

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/ja/html/about/history.html
    trunk/installer/release/lang/English.lng
    trunk/installer/release/lang/French.lng
    trunk/installer/release/lang/German.lng
    trunk/installer/release/lang/Japanese.lng
    trunk/ttssh2/ttxssh/hosts.c
    trunk/ttssh2/ttxssh/resource.h
    trunk/ttssh2/ttxssh/ttxssh.rc


-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/doc/en/html/about/history.html	2011-02-23 15:47:30 UTC (rev 4332)
@@ -1638,6 +1638,7 @@
      <!--li>SSH2 ‚Ì diffie-hellman-group-exchange-sha256, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521 Œ®ŒðŠ·ƒvƒƒgƒRƒ‹‚ðƒTƒ|[ƒg‚µ‚½B</li-->
      <!--li>SSH2 ‚Ì ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521 ƒzƒXƒgŒ®•ûŽ®‚ðƒTƒ|[ƒg‚µ‚½B</li-->
      <!--li>SSH2 ‚Ì ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521 ŒöŠJŒ®”FØ‚ðƒTƒ|[ƒg‚µ‚½B</li-->
+     <!--li>ssh_known_hosts ‚ɈႤŒ`Ž®‚̃T[ƒoƒzƒXƒgŒ®‚ª‚ ‚éê‡AŒ®‚ð’u‚«Š·‚¦‚é‚©‚Ç‚¤‚©‚Å‚Í‚È‚­’ljÁ‚·‚é‚©‚Ç‚¤‚©ƒ†[ƒU‚É–â‚¢‡‚킹‚é‚悤‚É‚µ‚½B</li-->
     </ul>
   </li>
 

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/doc/ja/html/about/history.html	2011-02-23 15:47:30 UTC (rev 4332)
@@ -1639,6 +1639,7 @@
      <li>SSH2 ‚Ì diffie-hellman-group-exchange-sha256, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521 Œ®ŒðŠ·ƒvƒƒgƒRƒ‹‚ðƒTƒ|[ƒg‚µ‚½B</li>
      <li>SSH2 ‚Ì ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521 ƒzƒXƒgŒ®•ûŽ®‚ðƒTƒ|[ƒg‚µ‚½B</li>
      <li>SSH2 ‚Ì ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521 ŒöŠJŒ®”FØ‚ðƒTƒ|[ƒg‚µ‚½B</li>
+     <li>ssh_known_hosts ‚ɈႤŒ`Ž®‚̃T[ƒoƒzƒXƒgŒ®‚ª‚ ‚éê‡AŒ®‚ð’u‚«Š·‚¦‚é‚©‚Ç‚¤‚©‚Å‚Í‚È‚­’ljÁ‚·‚é‚©‚Ç‚¤‚©ƒ†[ƒU‚É–â‚¢‡‚킹‚é‚悤‚É‚µ‚½B</li>
     </ul>
   </li>
 

Modified: trunk/installer/release/lang/English.lng
===================================================================
--- trunk/installer/release/lang/English.lng	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/installer/release/lang/English.lng	2011-02-23 15:47:30 UTC (rev 4332)
@@ -517,13 +517,20 @@
 MSG_RHOSTS_NOTDEFAULT_ERROR=Rhosts authentication will probably fail because it was not the default authentication method.\nTo use Rhosts authentication in TTSSH, you need to set it to be the default by restarting\nTTSSH and selecting "SSH Authentication..." from the Setup menubefore connecting.
 MSG_NOAUTHMETHOD_ERROR=Server does not support any of the authentication options\nprovided by TTSSH. This connection will now close.
 
-; dlg diff host
+; dlg diff key
 DLG_DIFFERENTKEY_TITLE=SECURITY WARNING
 DLG_DIFFERENTKEY_WARNING=Your known hosts list has an entry for the server "####################################", but the machine you have contacted has presented a DIFFERENT KEY to the one in your known hosts list. A hostile machine may be pretending to be the server.
 DLG_DIFFERENTKEY_WARNING2=If you choose to add this new key to the known hosts list and continue, then you will not receive this warning again.
 DLG_DIFFERENTKEY_FINGERPRINT=The server's host key fingerprint is:
 DLG_DIFFERENTKEY_REPLACE=&Replace the exist key with this new key
 
+; dlg diff type key
+DLG_DIFFERENTTYPEKEY_TITLE=SECURITY WARNING
+DLG_DIFFERENTTYPEKEY_WARNINIG=Your known hosts list has an entry for the server "####################################", but the machine you have contacted has presented a DIFFERENT TYPE KEY to the one in your known hosts list. A hostile machine may be pretending to be the server.
+DLG_DIFFERENTTYPEKEY_WARNINIG2=If you choose to add this new key to the known hosts list and continue, then you will not receive this warning again.
+DLG_DIFFERENTTYPEKEY_FINGERPRINT=The server's host key fingerprint is:
+DLG_DIFFERENTTYPEKEY_ADD=&Add this machine and its key to the known hosts list
+
 ; dlg fwd edit
 DLG_FWD_TITLE=SSH Port Forwarding
 DLG_FWD_BANNER=Select direction for forwarded port:

Modified: trunk/installer/release/lang/French.lng
===================================================================
--- trunk/installer/release/lang/French.lng	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/installer/release/lang/French.lng	2011-02-23 15:47:30 UTC (rev 4332)
@@ -516,13 +516,20 @@
 MSG_RHOSTS_NOTDEFAULT_ERROR=L'authentification Rhosts va probablement échouer car ce n'est pas la méthode d'authentification par défaut.\nPour utiliser l'authentification Rhosts avec TTSSH, il faut la paramétrer par défaut en redémarrant\nTTSSH et en sélectionnant "Authentification SSH..." dans le menu de configuration avant de vous connecter.
 MSG_NOAUTHMETHOD_ERROR=Le serveur ne supporte aucune des options d'authentification\nfournies par TTSSH. Cette connexion va maintenant être fermée.
 
-; dlg diff host
+; dlg diff key
 DLG_DIFFERENTKEY_TITLE=ALERTE DE SECURITE
 DLG_DIFFERENTKEY_WARNING=Votre liste d'hôte connus a une entrée pour le serveur "####################################", mais la machine contactée a présenté une CLE DIFFERENTE ! Une machine hostile pourrait se faire passer pour le serveur.
 DLG_DIFFERENTKEY_WARNING2=Si vous choisissez d'ajouter la nouvelle clé à votre liste et de continuer, vous ne recevrez plus cet avertissement.
 DLG_DIFFERENTKEY_FINGERPRINT=L'empreinte de la clé du serveur est:
 DLG_DIFFERENTKEY_REPLACE=&Remplacer la clé actuelle avec cette nouvelle clé
 
+; dlg diff type key
+DLG_DIFFERENTTYPEKEY_TITLE=ALERTE DE SECURITE
+DLG_DIFFERENTTYPEKEY_WARNINIG=Your known hosts list has an entry for the server "####################################", but the machine you have contacted has presented a DIFFERENT TYPE KEY to the one in your known hosts list. A hostile machine may be pretending to be the server.
+DLG_DIFFERENTTYPEKEY_WARNINIG2=Si vous choisissez d'ajouter la nouvelle clé à votre liste et de continuer, vous ne recevrez plus cet avertissement.
+DLG_DIFFERENTTYPEKEY_FINGERPRINT=L'empreinte de la clé du serveur est:
+DLG_DIFFERENTTYPEKEY_ADD=&Ajouter cette machine et sa clé à la liste des hôtes connus
+
 ; dlg fwd edit
 DLG_FWD_TITLE=SSH Mappage de port
 DLG_FWD_BANNER=Sélectionner une direction pour le port mappé:

Modified: trunk/installer/release/lang/German.lng
===================================================================
--- trunk/installer/release/lang/German.lng	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/installer/release/lang/German.lng	2011-02-23 15:47:30 UTC (rev 4332)
@@ -515,13 +515,20 @@
 MSG_RHOSTS_NOTDEFAULT_ERROR=Rhosts authentication will probably fail because it was not the default authentication method.\nTo use Rhosts authentication in TTSSH, you need to set it to be the default by restarting\nTTSSH and selecting "SSH Authentication..." from the Setup menubefore connecting.
 MSG_NOAUTHMETHOD_ERROR=Der Server unterstützt keine der von TTSSH angebotenen\nAuthentifizierungs-Optionen. Die Verbindung wird beendet.
 
-; dlg diff host
+; dlg diff key
 DLG_DIFFERENTKEY_TITLE=SICHERHEITSWARNUNG
 DLG_DIFFERENTKEY_WARNING=Der Server ("####################################") ist in der "known hosts"-Liste bereits mit einem anderen Schlüssel eingetragen.
 DLG_DIFFERENTKEY_WARNING2=Wenn Sie auf 'Continue'  klicken, wird der Server in die Liste aufgenommen und die Fehlermeldung erscheint nicht mehr.
 DLG_DIFFERENTKEY_FINGERPRINT=Der Fingerabdruck des Schlüssels:
 DLG_DIFFERENTKEY_REPLACE=Den vorhanden Schlüssel durch den neuen ersetzen.
 
+; dlg diff type key
+DLG_DIFFERENTTYPEKEY_TITLE=SICHERHEITSWARNUNG
+DLG_DIFFERENTTYPEKEY_WARNINIG=Your known hosts list has an entry for the server "####################################", but the machine you have contacted has presented a DIFFERENT TYPE KEY to the one in your known hosts list. A hostile machine may be pretending to be the server.
+DLG_DIFFERENTTYPEKEY_WARNINIG2=Wenn Sie auf 'Continue'  klicken, wird der Server in die Liste aufgenommen und die Fehlermeldung erscheint nicht mehr.
+DLG_DIFFERENTTYPEKEY_FINGERPRINT=Der Fingerabdruck des Schlüssels:
+DLG_DIFFERENTTYPEKEY_ADD=Den Server zur "known hosts"-Liste hinzufügen.
+
 ; dlg fwd edit
 DLG_FWD_TITLE=SSH-Port-Weiterleitung
 DLG_FWD_BANNER=Die Richtung der Port-Weiterleitung wählen:

Modified: trunk/installer/release/lang/Japanese.lng
===================================================================
--- trunk/installer/release/lang/Japanese.lng	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/installer/release/lang/Japanese.lng	2011-02-23 15:47:30 UTC (rev 4332)
@@ -517,13 +517,20 @@
 MSG_RHOSTS_NOTDEFAULT_ERROR=Rhosts ”FØ‚Í•W€‚Ì”FØ•ûŽ®‚Å‚Í‚È‚¢‚½‚ß, ”FØ‚ÉŽ¸”s‚·‚é‚©‚à‚µ‚ê‚Ü‚¹‚ñ.\nRhosts ”FØ‚ðTTSSH ‚ÅŽg—p‚·‚é‚É‚Í, Rhosts ”FØ‚ð•W€‚ɐݒèŒãTTSSH ‚ðÄ‹N“®‚µ, Ú‘±‘O‚ɐݒ胁ƒjƒ…[‚©‚ç"SSH ”FØ..." ‚ð‘I‘ð‚µ‚Ä‰º‚³‚¢.
 MSG_NOAUTHMETHOD_ERROR=ƒT[ƒo‚ÍTTSSH ‚ª’ñ‹Ÿ‚·‚é”FØƒIƒvƒVƒ‡ƒ“‚ðƒTƒ|[ƒg‚µ‚Ä‚¢‚Ü‚¹‚ñ.\nÚ‘±‚͕‚¶‚ç‚ê‚Ü‚·.
 
-; dlg diff host
+; dlg diff type
 DLG_DIFFERENTKEY_TITLE=ƒZƒLƒ…ƒŠƒeƒBŒx
 DLG_DIFFERENTKEY_WARNING=knows hostsƒŠƒXƒg’†‚̃T[ƒo"####################################"‚̃Gƒ“ƒgƒŠ‚Æ, Ú‘±æ‚̃zƒXƒgŒ®‚ª *ˆê’v‚µ‚Ä‚¢‚Ü‚¹‚ñ* ˆ«ˆÓ‚ðŽ‚Á‚½ƒzƒXƒg‚ª, Ú‘±‚µ‚悤‚Æ‚µ‚Ä‚¢‚éƒT[ƒo‚Ì‚Ó‚è‚ð‚µ‚Ä‚¢‚é‰Â”\«‚à‚ ‚è‚Ü‚·‚Ì‚Å, \•ª’ˆÓ‚µ‚Ä‚­‚¾‚³‚¢.
 DLG_DIFFERENTKEY_WARNING2=known hostsƒŠƒXƒg‚É‚±‚̃zƒXƒg‚ð’ljÁ‚µ‚Ä‘±s‚·‚é‚Æ, ŽŸ‰ñ‚©‚炱‚ÌŒx‚͏o‚È‚­‚È‚è‚Ü‚·.
 DLG_DIFFERENTKEY_FINGERPRINT=ƒT[ƒo‘¤‚̃zƒXƒgŒ®Žw–ä:
-DLG_DIFFERENTKEY_REPLACE=Šù‘¶‚ÌŒ®‚ð, V‚µ‚¢Œ®‚ŏ㏑‚«‚·‚é(&R)
+DLG_DIFFERENTKEY_ADD=Šù‘¶‚ÌŒ®‚ð, V‚µ‚¢Œ®‚ŏ㏑‚«‚·‚é(&R)
 
+; dlg diff type key
+DLG_DIFFERENTTYPEKEY_TITLE=ƒZƒLƒ…ƒŠƒeƒBŒx
+DLG_DIFFERENTTYPEKEY_WARNINIG=knows hostsƒŠƒXƒg’†‚̃T[ƒo"####################################"‚̃Gƒ“ƒgƒŠ‚Æ, Ú‘±æ‚̃zƒXƒgŒ®‚ÌŽí—Þ‚ª *ˆê’v‚µ‚Ä‚¢‚Ü‚¹‚ñ* ˆ«ˆÓ‚ðŽ‚Á‚½ƒzƒXƒg‚ª, Ú‘±‚µ‚悤‚Æ‚µ‚Ä‚¢‚éƒT[ƒo‚Ì‚Ó‚è‚ð‚µ‚Ä‚¢‚é‰Â”\«‚à‚ ‚è‚Ü‚·‚Ì‚Å, \•ª’ˆÓ‚µ‚Ä‚­‚¾‚³‚¢.
+DLG_DIFFERENTTYPEKEY_WARNINIG2=known hostsƒŠƒXƒg‚É‚±‚̃zƒXƒg‚ð’ljÁ‚µ‚Ä‘±s‚·‚é‚Æ, ŽŸ‰ñ‚©‚炱‚ÌŒx‚͏o‚È‚­‚È‚è‚Ü‚·.
+DLG_DIFFERENTTYPEKEY_FINGERPRINT=ƒT[ƒo‘¤‚̃zƒXƒgŒ®Žw–ä:
+DLG_DIFFERENTTYPEKEY_ADD=‚±‚̃zƒXƒg‚ðknown hostsƒŠƒXƒg‚ɒljÁ‚·‚é(&A)
+
 ; dlg fwd edit
 DLG_FWD_TITLE=SSHƒ|[ƒg“]‘—
 DLG_FWD_BANNER=ƒ|[ƒg“]‘—‚ðs‚¤Œü‚«‚Ì‘I‘ð:

Modified: trunk/ttssh2/ttxssh/hosts.c
===================================================================
--- trunk/ttssh2/ttxssh/hosts.c	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/ttssh2/ttxssh/hosts.c	2011-02-23 15:47:30 UTC (rev 4332)
@@ -791,7 +791,10 @@
 }
 
 // ŒöŠJŒ®‚ª“™‚µ‚¢‚©‚ðŒŸØ‚·‚é
-static BOOL match_key(PTInstVar pvar, Key *key)
+//   -1 ... Œ®‚ÌŒ^‚ªˆá‚¤
+//    0 ... “™‚µ‚­‚È‚¢
+//    1 ... “™‚µ‚¢
+static int match_key(PTInstVar pvar, Key *key)
 {
 	int bits;
 	unsigned char FAR * exp;
@@ -799,6 +802,10 @@
 	const EC_GROUP *group;
 	const EC_POINT *pa, *pb;
 
+	if (pvar->hosts_state.hostkey.type != key->type) {
+		return -1;
+	}
+
 	switch (key->type) {
 	case KEY_RSA1: // SSH1 host public key
 		bits = key->bits;
@@ -1219,29 +1226,17 @@
 					host_index += eat_to_end_of_pattern(data + host_index);
 				} while (data[host_index] == ',');
 
-				// ƒzƒXƒg‚ª“™‚µ‚­‚臒v‚·‚éƒL[‚ªŒ©‚‚©‚é
-				if (match_key(pvar, &key)) {
-					do_write = 1;
-				}
 				// ƒzƒXƒg‚ª“™‚µ‚­‚È‚¢
-				else if (!matched) {
+				if (!matched) {
 					do_write = 1;
 				}
-				// ƒzƒXƒg‚ª“™‚µ‚¢ and Ú‘±‚̃o[ƒWƒ‡ƒ“‚ªˆá‚¤
+				// ƒzƒXƒg‚ª“™‚µ‚¢
 				else {
-					int rsa1_key_bits=0;
-					rsa1_key_bits = atoi(data + host_index + eat_spaces(data + host_index));
-					
-					if (rsa1_key_bits > 0) { // ƒtƒ@ƒCƒ‹‚̃L[‚Í ssh1
-						if (!SSHv1(pvar)) {
-							do_write = 1;
-						}
+					// Œ®‚ÌŒ`Ž®‚ªˆá‚¤ or ‡’v‚·‚éƒL[
+					if (match_key(pvar, &key) != 0) {
+						do_write = 1;
 					}
-					else { // ƒtƒ@ƒCƒ‹‚̃L[‚Í ssh2
-						if (!SSHv2(pvar)) {
-							do_write = 1;
-						}
-					}
+					// Œ®‚ÌŒ`Ž®‚ª“¯‚¶‚ō‡’v‚µ‚È‚¢ƒL[‚̓XƒLƒbƒv‚³‚ê‚é
 				}
 			}
 
@@ -1496,6 +1491,113 @@
 	}
 }
 
+//
+// “¯‚¶ƒzƒXƒg‚ÅŒ®Œ`Ž®‚ªˆá‚¤Žž‚̒ljÁŠm”Fƒ_ƒCƒAƒƒO‚𕪗£
+//
+static BOOL CALLBACK hosts_add2_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
+                                         LPARAM lParam)
+{
+	PTInstVar pvar;
+	LOGFONT logfont;
+	HFONT font;
+	char uimsg[MAX_UIMSG];
+
+	switch (msg) {
+	case WM_INITDIALOG:
+		pvar = (PTInstVar) lParam;
+		pvar->hosts_state.hosts_dialog = dlg;
+		SetWindowLong(dlg, DWL_USER, lParam);
+
+		// ’ljÁE’u‚«Š·‚¦‚Æ‚à init_hosts_dlg ‚ðŒÄ‚ñ‚Å‚¢‚é‚̂ŁA‚»‚Ì‘O‚ɃZƒbƒg‚·‚é•K—v‚ª‚ ‚é
+		GetWindowText(dlg, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("DLG_DIFFERENTTYPEKEY_TITLE", pvar, uimsg);
+		SetWindowText(dlg, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDC_HOSTWARNING, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("DLG_DIFFERENTTYPEKEY_WARNINIG", pvar, uimsg);
+		SetDlgItemText(dlg, IDC_HOSTWARNING, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDC_HOSTWARNING2, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("DLG_DIFFERENTTYPEKEY_WARNINIG2", pvar, uimsg);
+		SetDlgItemText(dlg, IDC_HOSTWARNING2, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDC_HOSTFINGERPRINT, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("DLG_DIFFERENTTYPEKEY_FINGERPRINT", pvar, uimsg);
+		SetDlgItemText(dlg, IDC_HOSTFINGERPRINT, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDC_ADDTOKNOWNHOSTS, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("DLG_DIFFERENTTYPEKEY_ADD", pvar, uimsg);
+		SetDlgItemText(dlg, IDC_ADDTOKNOWNHOSTS, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDC_CONTINUE, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("BTN_CONTINUE", pvar, uimsg);
+		SetDlgItemText(dlg, IDC_CONTINUE, pvar->ts->UIMsg);
+		GetDlgItemText(dlg, IDCANCEL, uimsg, sizeof(uimsg));
+		UTIL_get_lang_msg("BTN_DISCONNECT", pvar, uimsg);
+		SetDlgItemText(dlg, IDCANCEL, pvar->ts->UIMsg);
+
+		init_hosts_dlg(pvar, dlg);
+
+		font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
+		GetObject(font, sizeof(LOGFONT), &logfont);
+		if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgHostsAddFont, pvar)) {
+			SendDlgItemMessage(dlg, IDC_HOSTWARNING, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDC_HOSTWARNING2, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDC_HOSTFINGERPRINT, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDC_FINGER_PRINT, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDC_ADDTOKNOWNHOSTS, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDC_CONTINUE, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+			SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgHostsAddFont, MAKELPARAM(TRUE,0));
+		}
+		else {
+			DlgHostsAddFont = NULL;
+		}
+
+		// add host check box ‚̃fƒtƒHƒ‹ƒg‚Í off ‚É‚·‚é
+		// SendMessage(GetDlgItem(dlg, IDC_ADDTOKNOWNHOSTS), BM_SETCHECK, BST_CHECKED, 0);
+
+		return TRUE;			/* because we do not set the focus */
+
+	case WM_COMMAND:
+		pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
+
+		switch (LOWORD(wParam)) {
+		case IDC_CONTINUE:
+			if (IsDlgButtonChecked(dlg, IDC_ADDTOKNOWNHOSTS)) {
+				add_host_key(pvar);
+			}
+
+			if (SSHv1(pvar)) {
+				SSH_notify_host_OK(pvar);
+			} else { // SSH2
+				// SSH2‚Å‚Í‚ ‚Æ‚Å SSH_notify_host_OK() ‚ðŒÄ‚ԁB
+			}
+
+			pvar->hosts_state.hosts_dialog = NULL;
+
+			EndDialog(dlg, 1);
+
+			if (DlgHostsAddFont != NULL) {
+				DeleteObject(DlgHostsAddFont);
+			}
+
+			return TRUE;
+
+		case IDCANCEL:			/* kill the connection */
+			pvar->hosts_state.hosts_dialog = NULL;
+			notify_closed_connection(pvar);
+			EndDialog(dlg, 0);
+
+			if (DlgHostsAddFont != NULL) {
+				DeleteObject(DlgHostsAddFont);
+			}
+
+			return TRUE;
+
+		default:
+			return FALSE;
+		}
+
+	default:
+		return FALSE;
+	}
+}
+
 void HOSTS_do_unknown_host_dialog(HWND wnd, PTInstVar pvar)
 {
 	if (pvar->hosts_state.hosts_dialog == NULL) {
@@ -1518,6 +1620,17 @@
 	}
 }
 
+void HOSTS_do_different_type_key_dialog(HWND wnd, PTInstVar pvar)
+{
+	if (pvar->hosts_state.hosts_dialog == NULL) {
+		HWND cur_active = GetActiveWindow();
+
+		DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHDIFFERENTTYPEKEY),
+		               cur_active != NULL ? cur_active : wnd,
+		               hosts_add2_dlg_proc, (LPARAM) pvar);
+	}
+}
+
 //
 // ƒT[ƒo‚©‚ç‘—‚ç‚ê‚Ä‚«‚½ƒzƒXƒgŒöŠJŒ®‚̑Ó–«‚ðƒ`ƒFƒbƒN‚·‚é
 //
@@ -1525,12 +1638,12 @@
 //
 BOOL HOSTS_check_host_key(PTInstVar pvar, char FAR * hostname, unsigned short tcpport, Key *key)
 {
-	int found_different_key = 0;
+	int found_different_key = 0, found_different_type_key = 0;
 
 	// ‚·‚Å‚É known_hosts ƒtƒ@ƒCƒ‹‚©‚çƒzƒXƒgŒöŠJŒ®‚ð“ǂݍž‚ñ‚Å‚¢‚é‚È‚çA‚»‚ê‚Æ”äŠr‚·‚éB
 	if (pvar->hosts_state.prefetched_hostname != NULL
 	 && _stricmp(pvar->hosts_state.prefetched_hostname, hostname) == 0
-	 && match_key(pvar, key)) {
+	 && match_key(pvar, key) == 1) {
 
 		if (SSHv1(pvar)) {
 			SSH_notify_host_OK(pvar);
@@ -1548,7 +1661,8 @@
 			}
 
 			if (pvar->hosts_state.hostkey.type != KEY_UNSPEC) {
-				if (match_key(pvar, key)) {
+				int match = match_key(pvar, key);
+				if (match == 1) {
 					finish_read_host_files(pvar, 0);
 					// ‚·‚ׂẴGƒ“ƒgƒŠ‚ðŽQÆ‚µ‚āA‡’v‚·‚éƒL[‚ªŒ©‚‚©‚Á‚½‚ç–ß‚éB
 					// SSH2‚̏ꍇ‚Í‚±‚±‚ł͉½‚à‚µ‚È‚¢B(2006.3.29 yutaka)
@@ -1558,10 +1672,15 @@
 						// SSH2‚Å‚Í‚ ‚Æ‚Å SSH_notify_host_OK() ‚ðŒÄ‚ԁB
 					}
 					return TRUE;
-				} else {
+				}
+				else if (match == 0) {
 					// ƒL[‚Í known_hosts ‚ÉŒ©‚‚©‚Á‚½‚ªAƒL[‚Ì“à—e‚ªˆÙ‚È‚éB
 					found_different_key = 1;
 				}
+				else {
+					// ƒL[‚ÌŒ`Ž®‚ªˆá‚¤ê‡
+					found_different_type_key = 1;
+				}
 			}
 		} while (pvar->hosts_state.hostkey.type != KEY_UNSPEC);  // ƒL[‚ªŒ©‚‚©‚Á‚Ä‚¢‚éŠÔ‚̓‹[ƒv‚·‚é
 
@@ -1608,7 +1727,11 @@
 #else
 		HOSTS_do_different_key_dialog(pvar->NotificationWindow, pvar);
 #endif
-	} else {
+	}
+	else if (found_different_type_key) {
+		HOSTS_do_different_type_key_dialog(pvar->NotificationWindow, pvar);
+	}
+	else {
 #if 0
 		PostMessage(pvar->NotificationWindow, WM_COMMAND,
 		            ID_SSHUNKNOWNHOST, 0);

Modified: trunk/ttssh2/ttxssh/resource.h
===================================================================
--- trunk/ttssh2/ttxssh/resource.h	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/ttssh2/ttxssh/resource.h	2011-02-23 15:47:30 UTC (rev 4332)
@@ -22,6 +22,7 @@
 #define IDD_SSHFWDSETUP                 603
 #define IDD_SSHFWDEDIT                  604
 #define IDD_SSHTISAUTH                  605
+#define IDD_SSHDIFFERENTTYPEKEY         606
 #define IDC_HOSTCOMLABEL                608
 #define IDC_HOSTCOM                     609
 #define IDC_HOSTHELP                    699

Modified: trunk/ttssh2/ttxssh/ttxssh.rc
===================================================================
--- trunk/ttssh2/ttxssh/ttxssh.rc	2011-02-23 15:04:13 UTC (rev 4331)
+++ trunk/ttssh2/ttxssh/ttxssh.rc	2011-02-23 15:47:30 UTC (rev 4332)
@@ -361,7 +361,23 @@
     EDITTEXT        IDC_CONFIRM_PASSWD,67,56,99,14,ES_PASSWORD | ES_AUTOHSCROLL
 END
 
+IDD_SSHDIFFERENTTYPEKEY DIALOGEX 0, 0, 215, 242
+STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "SECURITY WARNING"
+FONT 8, "Tahoma", 0, 0, 0x0
+BEGIN
+    LTEXT           "Your known hosts list has an entry for the server ""####################################"", but the machine you have contacted has presented a DIFFERENT TYPE KEY to the one in your known hosts list. A hostile machine may be pretending to be the server.",IDC_HOSTWARNING,15,7,184,43
+    LTEXT           "If you choose to add this new key to the known hosts list and continue, then you will not receive this warning again.",IDC_HOSTWARNING2,15,48,184,24
+    LTEXT           "The server's host key fingerprint is:",IDC_HOSTFINGERPRINT,15,75,176,8
+    EDITTEXT        IDC_FINGER_PRINT,15,86,179,12,ES_AUTOHSCROLL | ES_READONLY
+    EDITTEXT        IDC_FP_RANDOMART,14,105,181,97,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
+    CONTROL         "&Add this machine and its key to the known hosts list",IDC_ADDTOKNOWNHOSTS,
+                    "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,19,207,181,13
+    DEFPUSHBUTTON   "&Continue",IDC_CONTINUE,50,222,50,14,WS_GROUP
+    PUSHBUTTON      "&Disconnect",IDCANCEL,115,222,50,14,WS_GROUP
+END
 
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // DESIGNINFO
@@ -480,6 +496,14 @@
         TOPMARGIN, 7
         BOTTOMMARGIN, 88
     END
+
+    IDD_SSHDIFFERENTTYPEKEY, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 208
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 236
+    END
 END
 #endif    // APSTUDIO_INVOKED
 



Ttssh2-commit メーリングリストの案内
アーカイブの一覧に戻る