[Ttssh2-commit] [6723] パスワード変更ダイアログの挙動調整

svnno****@sourc***** svnno****@sourc*****
2017年 5月 12日 (金) 21:44:01 JST


Revision: 6723
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6723
Author:   doda
Date:     2017-05-12 21:44:01 +0900 (Fri, 12 May 2017)
Log Message:
-----------
パスワード変更ダイアログの挙動調整

・フォーカスの初期位置を旧パスワード入力欄にした
・キャンセルした時に認証を試さず切断するようにした
・何も入力せずに Return を押した時の対策の為、空のパスワードを蹴るようにした

Modified Paths:
--------------
    trunk/ttssh2/ttxssh/ssh.c

-------------- next part --------------
Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2017-05-12 12:43:32 UTC (rev 6722)
+++ trunk/ttssh2/ttxssh/ssh.c	2017-05-12 12:44:01 UTC (rev 6723)
@@ -7218,6 +7218,8 @@
 
 static BOOL CALLBACK passwd_change_dialog(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
+	char old_passwd[PASSWD_MAXLEN];
+	char new_passwd[PASSWD_MAXLEN];
 	char retype_passwd[PASSWD_MAXLEN];
 	static struct change_password *cp;
 	LOGFONT logfont;
@@ -7262,30 +7264,44 @@
 		UTIL_get_lang_msg("DLG_PASSCHG_CONFIRMPASSWD", pvar, uimsg);
 		SetDlgItemText(dlg, IDC_CONFIRM_PASSWD_LABEL, pvar->ts->UIMsg);
 
-		return TRUE;
+		SetFocus(GetDlgItem(dlg, IDC_OLD_PASSWD));
 
+		return FALSE;
+
 	case WM_COMMAND:
 		switch (LOWORD(wParam)) {
 		case IDOK:
-			SendMessage(GetDlgItem(dlg, IDC_OLD_PASSWD), WM_GETTEXT , sizeof(cp->passwd), (LPARAM)cp->passwd);
-			SendMessage(GetDlgItem(dlg, IDC_NEW_PASSWD), WM_GETTEXT , sizeof(cp->new_passwd), (LPARAM)cp->new_passwd);
+			SendMessage(GetDlgItem(dlg, IDC_OLD_PASSWD), WM_GETTEXT , sizeof(old_passwd), (LPARAM)old_passwd);
+			SendMessage(GetDlgItem(dlg, IDC_NEW_PASSWD), WM_GETTEXT , sizeof(new_passwd), (LPARAM)new_passwd);
 			SendMessage(GetDlgItem(dlg, IDC_CONFIRM_PASSWD), WM_GETTEXT , sizeof(retype_passwd), (LPARAM)retype_passwd);
 
-			if (strcmp(cp->new_passwd, retype_passwd) == 0) {
-				EndDialog(dlg, 1); // dialog close
+			if (strcmp(new_passwd, retype_passwd) == 1) {
+				UTIL_get_lang_msg("MSG_PASSCHG_MISMATCH", pvar, "Mismatch; try again.");
+				MessageBox(NULL, pvar->ts->UIMsg, "ERROR", MB_OK | MB_ICONEXCLAMATION);
+				return FALSE;
+			}
 
-				if (DlgChgPassFont != NULL) {
-					DeleteObject(DlgChgPassFont);
-					DlgChgPassFont = NULL;
-				}
+			if (old_passwd[0] == 0 || new_passwd[0] == 0) {
+				// \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x8AJ\x82\xA2\x82Ă\xB7\x82\xAE\x82\xC9 Return \x82\xF0\x89\x9F\x82\xB5\x82Ă\xB5\x82܂\xC1\x82\xBD\x8E\x9E\x82̑΍\xF4\x82ׁ̈A
+				// \x82Ƃ肠\x82\xA6\x82\xB8\x8B\xF3\x83p\x83X\x83\x8F\x81[\x83h\x82\xF0\x82͂\xB6\x82\xA2\x82Ă\xA8\x82\xAD\x81B
+				return FALSE;
+			}
 
-				return TRUE;
-			} 
-			UTIL_get_lang_msg("MSG_PASSCHG_MISMATCH", pvar, "Mismatch; try again.");
-			MessageBox(NULL, pvar->ts->UIMsg, "ERROR", MB_OK | MB_ICONEXCLAMATION);
-			return FALSE;
+			strncpy_s(cp->passwd, sizeof(cp->passwd), old_passwd, _TRUNCATE);
+			strncpy_s(cp->new_passwd, sizeof(cp->new_passwd), new_passwd, _TRUNCATE);
 
+			EndDialog(dlg, 1); // dialog close
+
+			if (DlgChgPassFont != NULL) {
+				DeleteObject(DlgChgPassFont);
+				DlgChgPassFont = NULL;
+			}
+
+			return TRUE;
+
 		case IDCANCEL:
+			// \x90ڑ\xB1\x82\xF0\x90؂\xE9
+                        notify_closed_connection(pvar, "authentication cancelled");
 			EndDialog(dlg, 0); // dialog close
 
 			if (DlgChgPassFont != NULL) {
@@ -7302,7 +7318,7 @@
 
 BOOL handle_SSH2_userauth_passwd_changereq(PTInstVar pvar)
 {
-	int len;
+	int len, ret;
 	char *data;
 	buffer_t *msg = NULL;
 	char *s, *username;
@@ -7314,9 +7330,19 @@
 
 	notify_verbose_message(pvar, "SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ was received.", LOG_LEVEL_VERBOSE);
 
+	memset(&cp, 0, sizeof(cp));
 	cp.pvar = pvar;
-	DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHPASSWD_INPUT), pvar->cv->HWin, passwd_change_dialog, (LPARAM)&cp);
+	ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHPASSWD_INPUT), pvar->cv->HWin, passwd_change_dialog, (LPARAM)&cp);
 
+	if (ret == -1) {
+		logprintf(pvar, LOG_LEVEL_WARNING, __FUNCTION__ "%s: DialogBoxParam failed.");
+		return FALSE;
+	}
+	else if (ret == 0) {
+		logprintf(pvar, LOG_LEVEL_NOTICE, __FUNCTION__ "%s: dialog cancelled.");
+		return FALSE;
+	}
+
 	// 6byte\x81i\x83T\x83C\x83Y\x81{\x83p\x83f\x83B\x83\x93\x83O\x81{\x83^\x83C\x83v\x81j\x82\xF0\x8E\xE6\x82菜\x82\xA2\x82\xBD\x88ȍ~\x82̃y\x83C\x83\x8D\x81[\x83h
 	data = pvar->ssh_state.payload;
 	// \x83p\x83P\x83b\x83g\x83T\x83C\x83Y - (\x83p\x83f\x83B\x83\x93\x83O\x83T\x83C\x83Y+1)\x81G\x90^\x82̃p\x83P\x83b\x83g\x83T\x83C\x83Y



Ttssh2-commit メーリングリストの案内