Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /branches/ssh_chacha20poly1305/ttssh2/ttxssh/auth.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7634 - (hide annotations) (download) (as text)
Sun Apr 28 15:42:38 2019 UTC (4 years, 11 months ago) by zmatsuo
Original Path: trunk/ttssh2/ttxssh/auth.c
File MIME type: text/x-csrc
File size: 63869 byte(s)
ttsshのauth dialogのdropdownボタンを下向き三角のicon画像に変更
1 maya 3227 /*
2 doda 6841 * Copyright (c) 1998-2001, Robert O'Callahan
3 zmatsuo 7605 * (C) 2004-2019 TeraTerm Project
4 doda 6841 * All rights reserved.
5     *
6     * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9     *
10     * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17     *
18     * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28     */
29 maya 3227
30     #include "ttxssh.h"
31     #include "util.h"
32     #include "ssh.h"
33 maya 4304 #include "key.h"
34 zmatsuo 7360 #include "ttlib.h"
35 zmatsuo 7560 #include "dlglib.h"
36 maya 3227
37     #include <io.h>
38     #include <fcntl.h>
39     #include <stdlib.h>
40     #include <errno.h>
41 zmatsuo 7632 #include <Lmcons.h> // for UNLEN
42 zmatsuo 7605 #include <crtdbg.h>
43 maya 3227
44     #include "resource.h"
45     #include "keyfiles.h"
46     #include "libputty.h"
47 zmatsuo 7507 #include "tipwin.h"
48 zmatsuo 7605 #include "auth.h"
49 maya 3227
50 zmatsuo 7605 #if defined(_DEBUG)
51     #define malloc(l) _malloc_dbg((l), _NORMAL_BLOCK, __FILE__, __LINE__)
52     #define free(p) _free_dbg((p), _NORMAL_BLOCK)
53     #endif
54    
55 maya 3227 #define AUTH_START_USER_AUTH_ON_ERROR_END 1
56    
57     #define MAX_AUTH_CONTROL IDC_SSHUSEPAGEANT
58    
59 zmatsuo 7560 #undef DialogBoxParam
60     #define DialogBoxParam(p1,p2,p3,p4,p5) \
61     TTDialogBoxParam(p1,p2,p3,p4,p5)
62     #undef EndDialog
63     #define EndDialog(p1,p2) \
64     TTEndDialog(p1, p2)
65 maya 3227
66 zmatsuo 7560 //static HFONT DlgAuthFont;
67     //static HFONT DlgTisFont;
68     //static HFONT DlgAuthSetupFont;
69    
70 doda 6801 void destroy_malloced_string(char **str)
71 maya 3227 {
72     if (*str != NULL) {
73 yutakapon 6229 SecureZeroMemory(*str, strlen(*str));
74 maya 3227 free(*str);
75     *str = NULL;
76     }
77     }
78    
79     static int auth_types_to_control_IDs[] = {
80     -1, IDC_SSHUSERHOSTS, IDC_SSHUSERSA, IDC_SSHUSEPASSWORD,
81     IDC_SSHUSERHOSTS, IDC_SSHUSETIS, -1,
82     -1, -1, -1, -1, -1, -1, -1, -1, -1, IDC_SSHUSEPAGEANT, -1
83     };
84    
85 zmatsuo 7605 typedef struct {
86     WNDPROC ProcOrg;
87     PTInstVar pvar;
88     TipWin *tipwin;
89 zmatsuo 7632 BOOL *UseControlChar;
90 zmatsuo 7605 } TPasswordControlData;
91    
92 zmatsuo 7632 static void password_wnd_proc_close_tooltip(TPasswordControlData *data)
93     {
94     if (data->tipwin != NULL) {
95     TipWinDestroy(data->tipwin);
96     data->tipwin = NULL;
97     }
98     }
99    
100 zmatsuo 7605 static LRESULT CALLBACK password_wnd_proc(HWND control, UINT msg,
101     WPARAM wParam, LPARAM lParam)
102 maya 3227 {
103 zmatsuo 7605 LRESULT result;
104     TPasswordControlData *data = (TPasswordControlData *)GetWindowLongPtr(control, GWLP_USERDATA);
105 maya 3227 switch (msg) {
106     case WM_CHAR:
107 zmatsuo 7632 if ((data->UseControlChar == NULL || *data->UseControlChar == TRUE) &&
108     (GetKeyState(VK_CONTROL) & 0x8000) != 0)
109     { // �����������g�p���� && CTRL�L�[��������������
110 zmatsuo 7507 TCHAR chars[] = { (TCHAR) wParam, 0 };
111 maya 3227
112     SendMessage(control, EM_REPLACESEL, (WPARAM) TRUE,
113 zmatsuo 7507 (LPARAM) (TCHAR *) chars);
114    
115 zmatsuo 7605 if (data->tipwin == NULL) {
116     TCHAR uimsg[MAX_UIMSG];
117 maya 7508 RECT rect;
118 zmatsuo 7605 PTInstVar pvar = data->pvar;
119     UTIL_get_lang_msg("DLG_AUTH_TIP_CONTROL_CODE", pvar, "control character is entered");
120     _tcscpy_s(uimsg, _countof(uimsg), pvar->ts->UIMsg);
121 zmatsuo 7507 if (wParam == 'V' - 'A' + 1) {
122 zmatsuo 7605 // CTRL + V
123     _tcscat_s(uimsg, _countof(uimsg), _T("\n"));
124     UTIL_get_lang_msg("DLG_AUTH_TIP_PASTE_KEY", pvar, "Use Shift + Insert to paste from clipboard");
125     _tcscat_s(uimsg, _countof(uimsg), pvar->ts->UIMsg);
126 zmatsuo 7507 }
127     GetWindowRect(control, &rect);
128 zmatsuo 7605 data->tipwin = TipWinCreate(control, rect.left, rect.bottom, uimsg);
129 zmatsuo 7507 }
130    
131 maya 3227 return 0;
132 zmatsuo 7507 } else {
133 zmatsuo 7632 password_wnd_proc_close_tooltip(data);
134 maya 3227 }
135 zmatsuo 7507 break;
136 zmatsuo 7611 case WM_KILLFOCUS:
137 zmatsuo 7632 password_wnd_proc_close_tooltip(data);
138 zmatsuo 7611 break;
139 zmatsuo 7605 }
140    
141     result = CallWindowProc((WNDPROC)data->ProcOrg,
142     control, msg, wParam, lParam);
143    
144     if (msg == WM_NCDESTROY) {
145     SetWindowLongPtr(control, GWLP_WNDPROC, (LONG_PTR)data->ProcOrg);
146 zmatsuo 7632 password_wnd_proc_close_tooltip(data);
147 zmatsuo 7605 free(data);
148 maya 3227 }
149    
150 zmatsuo 7605 return result;
151 maya 3227 }
152    
153 zmatsuo 7632 void init_password_control(PTInstVar pvar, HWND dlg, int item, BOOL *UseControlChar)
154 maya 3227 {
155 zmatsuo 7605 HWND passwordControl = GetDlgItem(dlg, item);
156     TPasswordControlData *data = (TPasswordControlData *)malloc(sizeof(TPasswordControlData));
157     data->ProcOrg = (WNDPROC)GetWindowLongPtr(passwordControl, GWLP_WNDPROC);
158     data->pvar = pvar;
159     data->tipwin = NULL;
160 zmatsuo 7632 data->UseControlChar = UseControlChar;
161 zmatsuo 7605 SetWindowLongPtr(passwordControl, GWLP_WNDPROC, (LONG_PTR)password_wnd_proc);
162     SetWindowLongPtr(passwordControl, GWLP_USERDATA, (LONG_PTR)data);
163 maya 3227 SetFocus(passwordControl);
164     }
165    
166     static void set_auth_options_status(HWND dlg, int controlID)
167     {
168     BOOL RSA_enabled = controlID == IDC_SSHUSERSA;
169     BOOL rhosts_enabled = controlID == IDC_SSHUSERHOSTS;
170     BOOL TIS_enabled = controlID == IDC_SSHUSETIS;
171     BOOL PAGEANT_enabled = controlID == IDC_SSHUSEPAGEANT;
172     int i;
173    
174     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL, controlID);
175    
176     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORDCAPTION), (!TIS_enabled && !PAGEANT_enabled));
177     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD), (!TIS_enabled && !PAGEANT_enabled));
178 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION), (!TIS_enabled && !PAGEANT_enabled));
179 maya 3227
180     for (i = IDC_CHOOSERSAFILE; i <= IDC_RSAFILENAME; i++) {
181     EnableWindow(GetDlgItem(dlg, i), RSA_enabled);
182     }
183    
184     for (i = IDC_LOCALUSERNAMELABEL; i <= IDC_HOSTRSAFILENAME; i++) {
185     EnableWindow(GetDlgItem(dlg, i), rhosts_enabled);
186     }
187     }
188    
189     static void init_auth_machine_banner(PTInstVar pvar, HWND dlg)
190     {
191     char buf[1024], buf2[1024];
192    
193     GetDlgItemText(dlg, IDC_SSHAUTHBANNER, buf2, sizeof(buf2));
194     _snprintf_s(buf, sizeof(buf), _TRUNCATE, buf2, SSH_get_host_name(pvar));
195     SetDlgItemText(dlg, IDC_SSHAUTHBANNER, buf);
196     }
197    
198     static void update_server_supported_types(PTInstVar pvar, HWND dlg)
199     {
200     int supported_methods = pvar->auth_state.supported_types;
201     int cur_control = -1;
202     int control;
203     HWND focus = GetFocus();
204    
205     if (supported_methods == 0) {
206     return;
207     }
208    
209     for (control = IDC_SSHUSEPASSWORD; control <= MAX_AUTH_CONTROL;
210     control++) {
211     BOOL enabled = FALSE;
212     int method;
213     HWND item = GetDlgItem(dlg, control);
214    
215     if (item != NULL) {
216     for (method = 0; method <= SSH_AUTH_MAX; method++) {
217     if (auth_types_to_control_IDs[method] == control
218     && (supported_methods & (1 << method)) != 0) {
219     enabled = TRUE;
220     }
221     }
222    
223     EnableWindow(item, enabled);
224    
225     if (IsDlgButtonChecked(dlg, control)) {
226     cur_control = control;
227     }
228     }
229     }
230    
231     if (cur_control >= 0) {
232     if (!IsWindowEnabled(GetDlgItem(dlg, cur_control))) {
233     do {
234     cur_control++;
235     if (cur_control > MAX_AUTH_CONTROL) {
236     cur_control = IDC_SSHUSEPASSWORD;
237     }
238     } while (!IsWindowEnabled(GetDlgItem(dlg, cur_control)));
239    
240     set_auth_options_status(dlg, cur_control);
241    
242     if (focus != NULL && !IsWindowEnabled(focus)) {
243     SetFocus(GetDlgItem(dlg, cur_control));
244     }
245     }
246     }
247     }
248    
249 zmatsuo 7632 static void init_auth_dlg(PTInstVar pvar, HWND dlg, BOOL *UseControlChar)
250 maya 3227 {
251 zmatsuo 7632 const static DlgTextInfo text_info[] = {
252     { 0, "DLG_AUTH_TITLE" },
253     { IDC_SSHAUTHBANNER, "DLG_AUTH_BANNER" },
254     { IDC_SSHAUTHBANNER2, "DLG_AUTH_BANNER2" },
255     { IDC_SSHUSERNAMELABEL, "DLG_AUTH_USERNAME" },
256     { IDC_SSHPASSWORDCAPTION, "DLG_AUTH_PASSWORD" },
257     { IDC_REMEMBER_PASSWORD, "DLG_AUTH_REMEMBER_PASSWORD" },
258     { IDC_FORWARD_AGENT, "DLG_AUTH_FWDAGENT" },
259     { IDC_SSHUSEPASSWORD, "DLG_AUTH_METHOD_PASSWORD" },
260     { IDC_SSHUSERSA, "DLG_AUTH_METHOD_RSA" },
261     { IDC_SSHUSERHOSTS, "DLG_AUTH_METHOD_RHOST" },
262     { IDC_SSHUSEPAGEANT, "DLG_AUTH_METHOD_PAGEANT" },
263     { IDC_RSAFILENAMELABEL, "DLG_AUTH_PRIVATEKEY" },
264     { IDC_LOCALUSERNAMELABEL, "DLG_AUTH_LOCALUSER" },
265     { IDC_HOSTRSAFILENAMELABEL, "DLG_AUTH_HOST_PRIVATEKEY" },
266     { IDOK, "BTN_OK" },
267     { IDCANCEL, "BTN_DISCONNECT" },
268     };
269 maya 3227 int default_method = pvar->session_settings.DefaultAuthMethod;
270    
271 zmatsuo 7632 SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile);
272 maya 3227
273     init_auth_machine_banner(pvar, dlg);
274 zmatsuo 7632 init_password_control(pvar, dlg, IDC_SSHPASSWORD, UseControlChar);
275 maya 3227
276 maya 3342 // �F�����s�������x������������
277 maya 3227 if (pvar->auth_state.failed_method != SSH_AUTH_NONE) {
278     /* must be retrying a failed attempt */
279     UTIL_get_lang_msg("DLG_AUTH_BANNER2_FAILED", pvar, "Authentication failed. Please retry.");
280     SetDlgItemText(dlg, IDC_SSHAUTHBANNER2, pvar->ts->UIMsg);
281     UTIL_get_lang_msg("DLG_AUTH_TITLE_FAILED", pvar, "Retrying SSH Authentication");
282     SetWindowText(dlg, pvar->ts->UIMsg);
283     default_method = pvar->auth_state.failed_method;
284     }
285    
286 maya 3342 // �p�X���[�h���o���������`�F�b�N�{�b�N�X�����f�t�H���g���L�������� (2006.8.3 yutaka)
287     if (pvar->ts_SSH->remember_password) {
288     SendMessage(GetDlgItem(dlg, IDC_REMEMBER_PASSWORD), BM_SETCHECK, BST_CHECKED, 0);
289     } else {
290     SendMessage(GetDlgItem(dlg, IDC_REMEMBER_PASSWORD), BM_SETCHECK, BST_UNCHECKED, 0);
291     }
292 maya 3227
293 maya 3342 // ForwardAgent �����������f���� (2008.12.4 maya)
294     CheckDlgButton(dlg, IDC_FORWARD_AGENT, pvar->settings.ForwardAgent);
295    
296     // SSH �o�[�W������������ TIS �����x������������
297     if (pvar->settings.ssh_protocol_version == 1) {
298     UTIL_get_lang_msg("DLG_AUTH_METHOD_CHALLENGE1", pvar,
299 doda 7101 "Use challenge/response(&TIS) to log in");
300 maya 3342 SetDlgItemText(dlg, IDC_SSHUSETIS, pvar->ts->UIMsg);
301     } else {
302     UTIL_get_lang_msg("DLG_AUTH_METHOD_CHALLENGE2", pvar,
303 doda 7101 "Use keyboard-&interactive to log in");
304 maya 3342 SetDlgItemText(dlg, IDC_SSHUSETIS, pvar->ts->UIMsg);
305 maya 3227 }
306    
307     if (pvar->auth_state.user != NULL) {
308     SetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->auth_state.user);
309     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
310 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
311 maya 3227 EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAMELABEL), FALSE);
312 maya 3342 }
313 maya 4759 else if (strlen(pvar->ssh2_username) > 0) {
314 maya 3342 SetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->ssh2_username);
315     if (pvar->ssh2_autologin == 1) {
316     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
317 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
318 maya 3342 EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAMELABEL), FALSE);
319     }
320     }
321 zmatsuo 7632 else {
322     switch(pvar->session_settings.DefaultUserType) {
323     case 0:
324     // ����������
325     break;
326     case 1:
327     // use DefaultUserName
328     if (pvar->session_settings.DefaultUserName[0] == 0) {
329     // �u�����������v����������
330     pvar->session_settings.DefaultUserType = 0;
331     } else {
332     SetDlgItemText(dlg, IDC_SSHUSERNAME,
333     pvar->session_settings.DefaultUserName);
334     }
335     break;
336     case 2: {
337     TCHAR user_name[UNLEN+1];
338     DWORD len = _countof(user_name);
339     BOOL r = GetUserName(user_name, &len);
340     if (r != 0) {
341     SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name);
342     }
343     break;
344     }
345     default:
346     // ��������������������
347     pvar->session_settings.DefaultUserType = 0;
348     }
349 maya 3227 }
350    
351 maya 3342 if (strlen(pvar->ssh2_password) > 0) {
352     SetDlgItemText(dlg, IDC_SSHPASSWORD, pvar->ssh2_password);
353     if (pvar->ssh2_autologin == 1) {
354     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD), FALSE);
355     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORDCAPTION), FALSE);
356 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION), FALSE);
357 maya 3342 }
358     }
359    
360 maya 3227 SetDlgItemText(dlg, IDC_RSAFILENAME,
361     pvar->session_settings.DefaultRSAPrivateKeyFile);
362     SetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
363     pvar->session_settings.DefaultRhostsHostPrivateKeyFile);
364     SetDlgItemText(dlg, IDC_LOCALUSERNAME,
365     pvar->session_settings.DefaultRhostsLocalUserName);
366    
367 maya 3342 if (pvar->ssh2_authmethod == SSH_AUTH_PASSWORD) {
368     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL, IDC_SSHUSEPASSWORD);
369 maya 3227
370 maya 3342 } else if (pvar->ssh2_authmethod == SSH_AUTH_RSA) {
371     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL, IDC_SSHUSERSA);
372 maya 3227
373 maya 3342 SetDlgItemText(dlg, IDC_RSAFILENAME, pvar->ssh2_keyfile);
374 maya 3227 if (pvar->ssh2_autologin == 1) {
375 maya 3342 EnableWindow(GetDlgItem(dlg, IDC_CHOOSERSAFILE), FALSE);
376     EnableWindow(GetDlgItem(dlg, IDC_RSAFILENAME), FALSE);
377 maya 3227 }
378    
379 maya 3342 // /auth=challenge ������ (2007.10.5 maya)
380     } else if (pvar->ssh2_authmethod == SSH_AUTH_TIS) {
381     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL, IDC_SSHUSETIS);
382     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD), FALSE);
383 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION), FALSE);
384 maya 3342 SetDlgItemText(dlg, IDC_SSHPASSWORD, "");
385 maya 3227
386 maya 3342 // /auth=pageant ������
387     } else if (pvar->ssh2_authmethod == SSH_AUTH_PAGEANT) {
388     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL, IDC_SSHUSEPAGEANT);
389     EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD), FALSE);
390 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION), FALSE);
391 maya 3342 SetDlgItemText(dlg, IDC_SSHPASSWORD, "");
392 maya 3227
393 maya 3342 } else {
394     // �f�t�H���g���F�����\�b�h���_�C�A���O�����f
395     set_auth_options_status(dlg, auth_types_to_control_IDs[default_method]);
396 maya 3227
397 maya 3342 update_server_supported_types(pvar, dlg);
398 maya 3227
399 maya 3342 // �z�X�g�m�F�_�C�A���O��������������=�E�B���h�E���A�N�e�B�u������������
400     // �� SetFocus �����s�����A�R�}���h���C�����n�������F��������������������
401     // �����������A�������O�C���L������ SetFocus ������ (2009.1.31 maya)
402     if (default_method == SSH_AUTH_TIS) {
403     /* we disabled the password control, so fix the focus */
404     SetFocus(GetDlgItem(dlg, IDC_SSHUSETIS));
405 maya 3227 }
406 maya 3342 else if (default_method == SSH_AUTH_PAGEANT) {
407     SetFocus(GetDlgItem(dlg, IDC_SSHUSEPAGEANT));
408     }
409 maya 3227
410     }
411    
412 maya 3342 if (GetWindowTextLength(GetDlgItem(dlg, IDC_SSHUSERNAME)) == 0) {
413     SetFocus(GetDlgItem(dlg, IDC_SSHUSERNAME));
414 maya 3227 }
415 maya 3342 else if (pvar->ask4passwd == 1) {
416     SetFocus(GetDlgItem(dlg, IDC_SSHPASSWORD));
417     }
418 maya 3227
419 maya 3342 // '/I' �w�������������������������� (2005.9.5 yutaka)
420     if (pvar->ts->Minimize) {
421     //20050822���� start T.Takahashi
422     ShowWindow(dlg,SW_MINIMIZE);
423     //20050822���� end T.Takahashi
424 maya 3227 }
425     }
426    
427 doda 6801 static char *alloc_control_text(HWND ctl)
428 maya 3227 {
429     int len = GetWindowTextLength(ctl);
430 doda 6801 char *result = malloc(len + 1);
431 maya 3227
432     if (result != NULL) {
433     GetWindowText(ctl, result, len + 1);
434     result[len] = 0;
435     }
436    
437     return result;
438     }
439    
440 doda 6801 static int get_key_file_name(HWND parent, char *buf, int bufsize, PTInstVar pvar)
441 maya 3227 {
442     OPENFILENAME params;
443     char fullname_buf[2048] = "identity";
444     char filter[MAX_UIMSG];
445    
446     ZeroMemory(&params, sizeof(params));
447 zmatsuo 7360 params.lStructSize = get_OPENFILENAME_SIZE();
448 maya 3227 params.hwndOwner = parent;
449     // �t�B���^������ (2004.12.19 yutaka)
450     // 3�t�@�C���t�B���^������ (2005.4.26 yutaka)
451     UTIL_get_lang_msg("FILEDLG_OPEN_PRIVATEKEY_FILTER", pvar,
452 doda 7373 "identity files\\0identity;id_rsa;id_dsa;id_ecdsa;id_ed25519;*.ppk;*.pem\\0identity(RSA1)\\0identity\\0id_rsa(SSH2)\\0id_rsa\\0id_dsa(SSH2)\\0id_dsa\\0id_ecdsa(SSH2)\\0id_ecdsa\\0id_ed25519(SSH2)\\0id_ed25519\\0PuTTY(*.ppk)\\0*.ppk\\0PEM files(*.pem)\\0*.pem\\0all(*.*)\\0*.*\\0\\0");
453 maya 3227 memcpy(filter, pvar->ts->UIMsg, sizeof(filter));
454     params.lpstrFilter = filter;
455     params.lpstrCustomFilter = NULL;
456     params.nFilterIndex = 0;
457     buf[0] = 0;
458     params.lpstrFile = fullname_buf;
459     params.nMaxFile = sizeof(fullname_buf);
460     params.lpstrFileTitle = NULL;
461     params.lpstrInitialDir = NULL;
462     UTIL_get_lang_msg("FILEDLG_OPEN_PRIVATEKEY_TITLE", pvar,
463 maya 5553 "Choose a file with the RSA/DSA/ECDSA/ED25519 private key");
464 maya 3227 params.lpstrTitle = pvar->ts->UIMsg;
465     params.Flags =
466     OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
467     params.lpstrDefExt = NULL;
468    
469     if (GetOpenFileName(&params) != 0) {
470     copy_teraterm_dir_relative_path(buf, bufsize, fullname_buf);
471     return 1;
472     } else {
473     return 0;
474     }
475     }
476    
477     static void choose_RSA_key_file(HWND dlg, PTInstVar pvar)
478     {
479     char buf[1024];
480    
481     if (get_key_file_name(dlg, buf, sizeof(buf), pvar)) {
482     SetDlgItemText(dlg, IDC_RSAFILENAME, buf);
483     }
484     }
485    
486     static void choose_host_RSA_key_file(HWND dlg, PTInstVar pvar)
487     {
488     char buf[1024];
489    
490     if (get_key_file_name(dlg, buf, sizeof(buf), pvar)) {
491     SetDlgItemText(dlg, IDC_HOSTRSAFILENAME, buf);
492     }
493     }
494    
495     static BOOL end_auth_dlg(PTInstVar pvar, HWND dlg)
496     {
497     int method = SSH_AUTH_PASSWORD;
498 doda 6801 char *password =
499 maya 3227 alloc_control_text(GetDlgItem(dlg, IDC_SSHPASSWORD));
500 maya 4307 Key *key_pair = NULL;
501 maya 3227
502     if (IsDlgButtonChecked(dlg, IDC_SSHUSERSA)) {
503     method = SSH_AUTH_RSA;
504     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSERHOSTS)) {
505     if (GetWindowTextLength(GetDlgItem(dlg, IDC_HOSTRSAFILENAME)) > 0) {
506     method = SSH_AUTH_RHOSTS_RSA;
507     } else {
508     method = SSH_AUTH_RHOSTS;
509     }
510     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSETIS)) {
511     method = SSH_AUTH_TIS;
512     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSEPAGEANT)) {
513     method = SSH_AUTH_PAGEANT;
514     }
515    
516     if (method == SSH_AUTH_RSA || method == SSH_AUTH_RHOSTS_RSA) {
517 maya 5767 char keyfile[2048];
518 maya 3227 int file_ctl_ID =
519     method == SSH_AUTH_RSA ? IDC_RSAFILENAME : IDC_HOSTRSAFILENAME;
520    
521 maya 5767 keyfile[0] = 0;
522     GetDlgItemText(dlg, file_ctl_ID, keyfile, sizeof(keyfile));
523     if (keyfile[0] == 0) {
524 maya 3227 UTIL_get_lang_msg("MSG_KEYSPECIFY_ERROR", pvar,
525 maya 5553 "You must specify a file containing the RSA/DSA/ECDSA/ED25519 private key.");
526 maya 3227 notify_nonfatal_error(pvar, pvar->ts->UIMsg);
527     SetFocus(GetDlgItem(dlg, file_ctl_ID));
528     destroy_malloced_string(&password);
529     return FALSE;
530     }
531    
532     if (SSHv1(pvar)) {
533     BOOL invalid_passphrase = FALSE;
534    
535 maya 5767 key_pair = KEYFILES_read_private_key(pvar, keyfile, password,
536 maya 3227 &invalid_passphrase,
537     FALSE);
538    
539     if (key_pair == NULL) {
540     if (invalid_passphrase) {
541     HWND passwordCtl = GetDlgItem(dlg, IDC_SSHPASSWORD);
542    
543     SetFocus(passwordCtl);
544     SendMessage(passwordCtl, EM_SETSEL, 0, -1);
545     } else {
546     SetFocus(GetDlgItem(dlg, file_ctl_ID));
547     }
548     destroy_malloced_string(&password);
549     return FALSE;
550     }
551    
552     } else { // SSH2(yutaka)
553     BOOL invalid_passphrase = FALSE;
554     char errmsg[256];
555 maya 5056 FILE *fp = NULL;
556     ssh2_keyfile_type keyfile_type;
557 maya 3227
558     memset(errmsg, 0, sizeof(errmsg));
559    
560 maya 5767 keyfile_type = get_ssh2_keytype(keyfile, &fp, errmsg, sizeof(errmsg));
561 maya 5056 switch (keyfile_type) {
562     case SSH2_KEYFILE_TYPE_OPENSSH:
563     {
564     key_pair = read_SSH2_private_key(pvar, fp, password,
565     &invalid_passphrase,
566     FALSE,
567     errmsg,
568     sizeof(errmsg)
569     );
570     break;
571     }
572     case SSH2_KEYFILE_TYPE_PUTTY:
573     {
574     key_pair = read_SSH2_PuTTY_private_key(pvar, fp, password,
575     &invalid_passphrase,
576     FALSE,
577     errmsg,
578     sizeof(errmsg)
579     );
580     break;
581     }
582     case SSH2_KEYFILE_TYPE_SECSH:
583     {
584     key_pair = read_SSH2_SECSH_private_key(pvar, fp, password,
585     &invalid_passphrase,
586     FALSE,
587     errmsg,
588     sizeof(errmsg)
589     );
590     break;
591     }
592     default:
593     {
594     char buf[1024];
595 maya 5552
596     // �t�@�C�����J�����������t�@�C���`�����s��������������������
597     if (fp != NULL) {
598     key_pair = read_SSH2_private_key(pvar, fp, password,
599     &invalid_passphrase,
600     FALSE,
601     errmsg,
602     sizeof(errmsg)
603     );
604     break;
605     }
606    
607 maya 5056 UTIL_get_lang_msg("MSG_READKEY_ERROR", pvar,
608     "read error SSH2 private key file\r\n%s");
609     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg, errmsg);
610     notify_nonfatal_error(pvar, buf);
611 maya 5552 // ���������������������� SSH2 �������t�@�C�����J����������
612 maya 5056 // ���t�@�C�����I���{�^�����t�H�[�J�X������
613     SetFocus(GetDlgItem(dlg, IDC_CHOOSERSAFILE));
614     destroy_malloced_string(&password);
615     return FALSE;
616     }
617     }
618 maya 3227
619     if (key_pair == NULL) { // read error
620     char buf[1024];
621     UTIL_get_lang_msg("MSG_READKEY_ERROR", pvar,
622     "read error SSH2 private key file\r\n%s");
623     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg, errmsg);
624     notify_nonfatal_error(pvar, buf);
625     // �p�X�t���[�Y���������v����������������IDC_SSHPASSWORD���t�H�[�J�X������ (2006.10.29 yasuhide)
626     if (invalid_passphrase) {
627     HWND passwordCtl = GetDlgItem(dlg, IDC_SSHPASSWORD);
628    
629     SetFocus(passwordCtl);
630     SendMessage(passwordCtl, EM_SETSEL, 0, -1);
631     } else {
632     SetFocus(GetDlgItem(dlg, file_ctl_ID));
633     }
634     destroy_malloced_string(&password);
635     return FALSE;
636     }
637    
638     }
639    
640     }
641     else if (method == SSH_AUTH_PAGEANT) {
642     pvar->pageant_key = NULL;
643     pvar->pageant_curkey = NULL;
644     pvar->pageant_keylistlen = 0;
645     pvar->pageant_keycount = 0;
646     pvar->pageant_keycurrent = 0;
647     pvar->pageant_keyfinal=FALSE;
648    
649     // Pageant �����M
650     if (SSHv1(pvar)) {
651     pvar->pageant_keylistlen = putty_get_ssh1_keylist(&pvar->pageant_key);
652     }
653     else {
654     pvar->pageant_keylistlen = putty_get_ssh2_keylist(&pvar->pageant_key);
655     }
656     if (pvar->pageant_keylistlen == 0) {
657     UTIL_get_lang_msg("MSG_PAGEANT_NOTFOUND", pvar,
658     "Can't find Pageant.");
659     notify_nonfatal_error(pvar, pvar->ts->UIMsg);
660    
661     return FALSE;
662     }
663     pvar->pageant_curkey = pvar->pageant_key;
664    
665     // ������
666     pvar->pageant_keycount = get_uint32_MSBfirst(pvar->pageant_curkey);
667     if (pvar->pageant_keycount == 0) {
668     UTIL_get_lang_msg("MSG_PAGEANT_NOKEY", pvar,
669     "Pageant has no valid key.");
670     notify_nonfatal_error(pvar, pvar->ts->UIMsg);
671    
672     return FALSE;
673     }
674     pvar->pageant_curkey += 4;
675     }
676    
677     /* from here on, we cannot fail, so just munge cur_cred in place */
678     pvar->auth_state.cur_cred.method = method;
679     pvar->auth_state.cur_cred.key_pair = key_pair;
680     /* we can't change the user name once it's set. It may already have
681     been sent to the server, and it can only be sent once. */
682     if (pvar->auth_state.user == NULL) {
683     pvar->auth_state.user =
684     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
685     }
686    
687     // �p�X���[�h���������������������������� (2006.8.3 yutaka)
688     if (SendMessage(GetDlgItem(dlg, IDC_REMEMBER_PASSWORD), BM_GETCHECK, 0,0) == BST_CHECKED) {
689     pvar->settings.remember_password = 1; // �o��������
690     pvar->ts_SSH->remember_password = 1;
691     } else {
692     pvar->settings.remember_password = 0; // ���������������Y����
693     pvar->ts_SSH->remember_password = 0;
694     }
695    
696     // ���J���F���������A�Z�b�V�������������p�X���[�h���g�����������������������������������B
697     // (2005.4.8 yutaka)
698     if (method == SSH_AUTH_PASSWORD || method == SSH_AUTH_RSA) {
699     pvar->auth_state.cur_cred.password = password;
700     } else {
701     destroy_malloced_string(&password);
702     }
703     if (method == SSH_AUTH_RHOSTS || method == SSH_AUTH_RHOSTS_RSA) {
704     if (pvar->session_settings.DefaultAuthMethod != SSH_AUTH_RHOSTS) {
705     UTIL_get_lang_msg("MSG_RHOSTS_NOTDEFAULT_ERROR", pvar,
706     "Rhosts authentication will probably fail because it was not "
707     "the default authentication method.\n"
708     "To use Rhosts authentication "
709     "in TTSSH, you need to set it to be the default by restarting\n"
710 yutakapon 6019 "TTSSH and selecting \"SSH Authentication...\" from the Setup menu "
711 maya 3227 "before connecting.");
712     notify_nonfatal_error(pvar, pvar->ts->UIMsg);
713     }
714    
715     pvar->auth_state.cur_cred.rhosts_client_user =
716     alloc_control_text(GetDlgItem(dlg, IDC_LOCALUSERNAME));
717     }
718     pvar->auth_state.auth_dialog = NULL;
719    
720     GetDlgItemText(dlg, IDC_RSAFILENAME,
721     pvar->session_settings.DefaultRSAPrivateKeyFile,
722     sizeof(pvar->session_settings.
723     DefaultRSAPrivateKeyFile));
724     GetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
725     pvar->session_settings.DefaultRhostsHostPrivateKeyFile,
726     sizeof(pvar->session_settings.
727     DefaultRhostsHostPrivateKeyFile));
728     GetDlgItemText(dlg, IDC_LOCALUSERNAME,
729     pvar->session_settings.DefaultRhostsLocalUserName,
730     sizeof(pvar->session_settings.
731     DefaultRhostsLocalUserName));
732    
733     if (SSHv1(pvar)) {
734     SSH_notify_user_name(pvar);
735     SSH_notify_cred(pvar);
736     } else {
737     // for SSH2(yutaka)
738     do_SSH2_userauth(pvar);
739     }
740    
741     EndDialog(dlg, 1);
742 zmatsuo 7560 #if 0
743 maya 3227 if (DlgAuthFont != NULL) {
744     DeleteObject(DlgAuthFont);
745     }
746 zmatsuo 7560 #endif
747 maya 3227
748     return TRUE;
749     }
750    
751 zmatsuo 7507 /**
752     * �N���b�v�{�[�h����ANSI����������������
753     * �����������K�v��������strlen()��������
754     * @param hWnd
755     * @param emtpy TRUE�������N���b�v�{�[�h����������
756     * @retval �����������|�C���^ �g�p��free()��������
757     * ����������(�������G���[��)��NULL
758     */
759     char *GetClipboardTextA(HWND hWnd, BOOL empty)
760     {
761     HGLOBAL hGlobal;
762     const char *lpStr;
763     size_t length;
764     char *pool;
765    
766     OpenClipboard(hWnd);
767     hGlobal = (HGLOBAL)GetClipboardData(CF_TEXT);
768     if (hGlobal == NULL) {
769     CloseClipboard();
770     return NULL;
771     }
772     lpStr = (const char *)GlobalLock(hGlobal);
773     length = GlobalSize(hGlobal);
774     if (length == 0) {
775     pool = NULL;
776     } else {
777     pool = (char *)malloc(length + 1); // +1 for terminator
778     memcpy(pool, lpStr, length);
779     pool[length] = '\0';
780     }
781     GlobalUnlock(hGlobal);
782     if (empty) {
783     EmptyClipboard();
784     }
785     CloseClipboard();
786    
787     return pool;
788     }
789    
790    
791 maya 3227 BOOL autologin_sent_none;
792     static BOOL CALLBACK auth_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
793     LPARAM lParam)
794     {
795 maya 3342 const int IDC_TIMER1 = 300; // �������O�C�����L��������
796     const int IDC_TIMER2 = 301; // �T�|�[�g�������������\�b�h�������`�F�b�N(CheckAuthListFirst)
797     const int IDC_TIMER3 = 302; // challenge �� ask4passwd ��CheckAuthListFirst �� FALSE ������
798 maya 3227 const int autologin_timeout = 10; // �~���b
799     PTInstVar pvar;
800 zmatsuo 7560 // LOGFONT logfont;
801     // HFONT font;
802 zmatsuo 7632 static BOOL UseControlChar;
803     static BOOL ShowPassPhrase;
804 zmatsuo 7634 static HICON hIconDropdown;
805 maya 3227
806     switch (msg) {
807     case WM_INITDIALOG:
808     pvar = (PTInstVar) lParam;
809     pvar->auth_state.auth_dialog = dlg;
810     SetWindowLong(dlg, DWL_USER, lParam);
811    
812 zmatsuo 7632 UseControlChar = TRUE;
813     ShowPassPhrase = FALSE;
814     init_auth_dlg(pvar, dlg, &UseControlChar);
815 zmatsuo 7560 #if 0
816 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
817     GetObject(font, sizeof(LOGFONT), &logfont);
818     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgAuthFont, pvar)) {
819     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
820     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER2, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
821     SendDlgItemMessage(dlg, IDC_SSHUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
822     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
823     SendDlgItemMessage(dlg, IDC_SSHPASSWORDCAPTION, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
824     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
825     SendDlgItemMessage(dlg, IDC_REMEMBER_PASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
826     SendDlgItemMessage(dlg, IDC_FORWARD_AGENT, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
827     SendDlgItemMessage(dlg, IDC_SSHUSEPASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
828     SendDlgItemMessage(dlg, IDC_SSHUSERSA, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
829     SendDlgItemMessage(dlg, IDC_CHOOSERSAFILE, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
830     SendDlgItemMessage(dlg, IDC_RSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
831     SendDlgItemMessage(dlg, IDC_SSHUSERHOSTS, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
832     SendDlgItemMessage(dlg, IDC_LOCALUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
833     SendDlgItemMessage(dlg, IDC_LOCALUSERNAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
834     SendDlgItemMessage(dlg, IDC_CHOOSEHOSTRSAFILE, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
835     SendDlgItemMessage(dlg, IDC_HOSTRSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
836     SendDlgItemMessage(dlg, IDC_SSHUSETIS, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
837     SendDlgItemMessage(dlg, IDC_SSHUSEPAGEANT, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
838     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
839     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
840     }
841     else {
842     DlgAuthFont = NULL;
843     }
844 zmatsuo 7560 #endif
845 zmatsuo 7634 hIconDropdown = LoadImage(hInst, MAKEINTRESOURCE(IDI_DROPDOWN),
846     IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
847     SendMessage(GetDlgItem(dlg, IDC_USERNAME_OPTION), BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIconDropdown);
848     SendMessage(GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION), BM_SETIMAGE, IMAGE_ICON, (LPARAM)hIconDropdown);
849 zmatsuo 7632
850 maya 3227 // SSH2 autologin���L�����������A�^�C�}���d�|�����B (2004.12.1 yutaka)
851     if (pvar->ssh2_autologin == 1) {
852     autologin_sent_none = FALSE;
853     SetTimer(dlg, IDC_TIMER1, autologin_timeout, 0);
854     }
855     else {
856     // �T�|�[�g�������������\�b�h���`�F�b�N�����B(2007.9.24 maya)
857     // �������L�����A�����������s�����������A���[�U�����m����������
858     if (pvar->session_settings.CheckAuthListFirst &&
859     !pvar->tryed_ssh2_authlist &&
860     GetWindowTextLength(GetDlgItem(dlg, IDC_SSHUSERNAME)) > 0) {
861     SetTimer(dlg, IDC_TIMER2, autologin_timeout, 0);
862     }
863 maya 3342 // /auth=challenge �� /ask4passwd ���w���������������[�U�����m����������
864     // �������AOK �{�^���������� TIS auth �_�C�A���O���o��
865     else if (pvar->ssh2_authmethod == SSH_AUTH_TIS &&
866     pvar->ask4passwd &&
867     GetWindowTextLength(GetDlgItem(dlg, IDC_SSHUSERNAME)) > 0) {
868 maya 3227 SetTimer(dlg, IDC_TIMER3, autologin_timeout, 0);
869     }
870     }
871 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
872 maya 3227 return FALSE; /* because we set the focus */
873    
874     case WM_TIMER:
875     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
876     // �F�������������������A�F���f�[�^�����M�����B�����������A�������B(2004.12.16 yutaka)
877     if (wParam == IDC_TIMER1) {
878     // �������O�C��������
879     if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
880     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
881     if (SSHv2(pvar) &&
882     pvar->session_settings.CheckAuthListFirst &&
883     !pvar->tryed_ssh2_authlist) {
884     if (!autologin_sent_none) {
885 maya 3342 autologin_sent_none = TRUE;
886    
887 maya 3336 // �_�C�A���O�����[�U������������
888     if (pvar->auth_state.user == NULL) {
889     pvar->auth_state.user =
890     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
891     }
892    
893 maya 3342 // CheckAuthListFirst �� TRUE �������� AuthList ���A����������������
894     // IDOK �����������i�����������A�F�����\�b�h none ������ (2008.10.12 maya)
895 maya 3227 do_SSH2_userauth(pvar);
896     }
897     //else {
898     // none �������������A����������������
899     //}
900     }
901     else {
902 maya 3342 // SSH1 ������
903     // ������ CheckAuthListFirst �� FALSE ������
904     // ������ CheckAuthListFirst TRUE ���Aauthlist ���A������������
905 maya 3346 KillTimer(dlg, IDC_TIMER1);
906 maya 3342
907     // �_�C�A���O�����[�U������������
908     if (pvar->auth_state.user == NULL) {
909     pvar->auth_state.user =
910     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
911     }
912    
913 maya 3227 SendMessage(dlg, WM_COMMAND, IDOK, 0);
914     }
915     }
916     }
917     else if (wParam == IDC_TIMER2) {
918     // authlist ����������
919 maya 3346 if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
920     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
921     if (SSHv2(pvar)) {
922 maya 3227 KillTimer(dlg, IDC_TIMER2);
923    
924     // �_�C�A���O�����[�U������������
925     if (pvar->auth_state.user == NULL) {
926     pvar->auth_state.user =
927     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
928     }
929    
930     // ���[�U�������X��������
931     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
932 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
933 maya 3227
934 maya 3342 // �F�����\�b�h none ������
935 maya 3227 do_SSH2_userauth(pvar);
936    
937 maya 3342 // TIS �p�� OK �����������F�������s������������������
938 maya 3227 // Unexpected SSH2 message �������B
939     }
940 maya 3346 else if (SSHv1(pvar)) {
941     KillTimer(dlg, IDC_TIMER2);
942    
943     // TIS �p�� OK ������
944     if (pvar->ssh2_authmethod == SSH_AUTH_TIS) {
945     SendMessage(dlg, WM_COMMAND, IDOK, 0);
946     }
947     // SSH1 �����F�����\�b�h none ����������
948 maya 3227 }
949 maya 3346 // �v���g�R���o�[�W�����m���O������������
950 maya 3227 }
951     }
952     else if (wParam == IDC_TIMER3) {
953 maya 3346 if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
954     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
955     if (SSHv2(pvar) || SSHv1(pvar)) {
956     KillTimer(dlg, IDC_TIMER3);
957    
958     // TIS �p�� OK ������
959     SendMessage(dlg, WM_COMMAND, IDOK, 0);
960 maya 3227 }
961 maya 3346 // �v���g�R���o�[�W�����m���O������������
962 maya 3227 }
963     }
964     return FALSE;
965    
966     case WM_COMMAND:
967     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
968    
969     switch (LOWORD(wParam)) {
970     case IDOK:
971 yutakapon 5562 // �F�������T�[�o�������f�������������A�L�����Z�������������B(2014.3.31 yutaka)
972     if (!pvar->cv->Ready) {
973     goto canceled;
974     }
975    
976 maya 3227 // �F�������������������A�F���f�[�^�����M�����B�����������A�������B(2001.1.25 yutaka)
977     if (pvar->userauth_retry_count == 0 &&
978     ((pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) ||
979     !(pvar->ssh_state.status_flags & STATUS_HOST_OK))) {
980     return FALSE;
981     }
982     else if (SSHv2(pvar) &&
983     pvar->session_settings.CheckAuthListFirst &&
984     !pvar->tryed_ssh2_authlist) {
985     // CheckAuthListFirst ���L�����F������������������������
986     // OK �������������������� (2008.10.4 maya)
987     return FALSE;
988     }
989    
990     return end_auth_dlg(pvar, dlg);
991    
992     case IDCANCEL: /* kill the connection */
993 yutakapon 5562 canceled:
994 maya 3227 pvar->auth_state.auth_dialog = NULL;
995 maya 5678 notify_closed_connection(pvar, "authentication cancelled");
996 maya 3227 EndDialog(dlg, 0);
997 zmatsuo 7560 #if 0
998 maya 3227 if (DlgAuthFont != NULL) {
999     DeleteObject(DlgAuthFont);
1000     }
1001 zmatsuo 7560 #endif
1002 maya 3227 return TRUE;
1003    
1004     case IDC_SSHUSERNAME:
1005     // ���[�U�����t�H�[�J�X������������ (2007.9.29 maya)
1006     if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
1007     (pvar->ssh_state.status_flags & STATUS_HOST_OK) &&
1008     HIWORD(wParam) == EN_KILLFOCUS) {
1009     // �������L���������������s��������������
1010     if (SSHv2(pvar) &&
1011     pvar->session_settings.CheckAuthListFirst &&
1012     !pvar->tryed_ssh2_authlist) {
1013     // �_�C�A���O�����[�U�������f
1014     if (pvar->auth_state.user == NULL) {
1015     pvar->auth_state.user =
1016     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
1017     }
1018    
1019     // ���[�U���������������������`�F�b�N����
1020     if (strlen(pvar->auth_state.user) == 0) {
1021     return FALSE;
1022     }
1023    
1024     // ���[�U�������X��������
1025     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
1026 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
1027 maya 3227
1028 maya 3342 // �F�����\�b�h none ������
1029 maya 3227 do_SSH2_userauth(pvar);
1030     return TRUE;
1031     }
1032     }
1033    
1034     return FALSE;
1035    
1036     case IDC_SSHUSEPASSWORD:
1037     case IDC_SSHUSERSA:
1038     case IDC_SSHUSERHOSTS:
1039     case IDC_SSHUSETIS:
1040     case IDC_SSHUSEPAGEANT:
1041     set_auth_options_status(dlg, LOWORD(wParam));
1042     return TRUE;
1043    
1044     case IDC_CHOOSERSAFILE:
1045     choose_RSA_key_file(dlg, pvar);
1046     return TRUE;
1047    
1048     case IDC_CHOOSEHOSTRSAFILE:
1049     choose_host_RSA_key_file(dlg, pvar);
1050     return TRUE;
1051    
1052     case IDC_FORWARD_AGENT:
1053     // �����Z�b�V�������������f������ (2008.12.4 maya)
1054     pvar->session_settings.ForwardAgent = IsDlgButtonChecked(dlg, IDC_FORWARD_AGENT);
1055     return TRUE;
1056    
1057 zmatsuo 7632 case IDC_SSHPASSWORD_OPTION: {
1058     TCHAR uimsg[MAX_UIMSG];
1059     HMENU hMenu= CreatePopupMenu();
1060     GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_CLIPBOARD",
1061     uimsg, _countof(uimsg),
1062     "Paste from &clipboard",
1063     pvar->ts->UILanguageFile);
1064     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
1065     GetI18nStrT("ttssh", "DLG_AUTH_CLEAR_CLIPBOARD",
1066     uimsg, _countof(uimsg),
1067     "Paste from &clipboard and cl&ear clipboard",
1068     pvar->ts->UILanguageFile);
1069     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 2, uimsg);
1070     GetI18nStrT("ttssh", "DLG_AUTH_USE_CONTORL_CHARACTERS",
1071     uimsg, _countof(uimsg),
1072     "Use control charac&ters",
1073     pvar->ts->UILanguageFile);
1074     AppendMenu(hMenu, MF_ENABLED | MF_STRING | (UseControlChar ? MFS_CHECKED : 0), 3, uimsg);
1075     GetI18nStrT("ttssh", "DLG_AUTH_SHOW_PASSPHRASE",
1076     uimsg, _countof(uimsg),
1077     "&Show passphrase",
1078     pvar->ts->UILanguageFile);
1079     AppendMenu(hMenu, MF_ENABLED | MF_STRING | (ShowPassPhrase ? MFS_CHECKED : 0), 4, uimsg);
1080     RECT rect;
1081     HWND hWndButton = GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION);
1082     GetWindowRect(hWndButton, &rect);
1083     int result = TrackPopupMenu(hMenu, TPM_RETURNCMD, rect.left, rect.bottom, 0 , hWndButton, NULL);
1084     DestroyMenu(hMenu);
1085     switch(result) {
1086     case 1:
1087     case 2: {
1088     // �N���b�v�{�[�h�����y�[�X�g
1089     BOOL clear_clipboard = result == 2;
1090     char *clipboard = GetClipboardTextA(dlg, clear_clipboard);
1091     if (clipboard != NULL) {
1092     SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard);
1093     free(clipboard);
1094     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1095     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
1096     return FALSE;
1097     }
1098     return TRUE;
1099 zmatsuo 7507 }
1100 zmatsuo 7632 case 3:
1101     // �����R�[�h�g�p/���g�p
1102     UseControlChar = !UseControlChar;
1103     break;
1104     case 4:
1105     // �p�X�t���[�Y�\��/���\��
1106     ShowPassPhrase = !ShowPassPhrase;
1107     {
1108     // ������ on/off ������������
1109     HWND hWnd = GetDlgItem(dlg, IDC_SSHPASSWORD);
1110     static wchar_t password_char;
1111     if (password_char == 0) {
1112     wchar_t c = (wchar_t)SendMessage(hWnd, EM_GETPASSWORDCHAR, 0, 0);
1113     password_char = c;
1114     }
1115     if (ShowPassPhrase) {
1116     SendMessage(hWnd, EM_SETPASSWORDCHAR, 0, 0);
1117     } else {
1118     #if !defined(UNICODE)
1119     if (password_char < 0x100) {
1120     SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1121     } else {
1122     // TODO W�n������ ����������������
1123     //SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1124     SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
1125     }
1126     #else
1127     SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1128     #endif
1129     }
1130     //InvalidateRect(hWnd, NULL, TRUE);
1131     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1132     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
1133     return TRUE;
1134     }
1135     break;
1136     }
1137     break;
1138     }
1139    
1140     case IDC_USERNAME_OPTION: {
1141     TCHAR uimsg[MAX_UIMSG];
1142     HMENU hMenu= CreatePopupMenu();
1143     GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_WINDOWS_USERNAME",
1144     uimsg, _countof(uimsg),
1145     "Paste &Windows username",
1146     pvar->ts->UILanguageFile);
1147     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
1148     RECT rect;
1149     HWND hWndButton = GetDlgItem(dlg, IDC_USERNAME_OPTION);
1150     GetWindowRect(hWndButton, &rect);
1151     int result = TrackPopupMenu(hMenu, TPM_RETURNCMD, rect.left, rect.bottom, 0 , hWndButton, NULL);
1152     DestroyMenu(hMenu);
1153     switch (result) {
1154     case 1: {
1155     TCHAR user_name[UNLEN+1];
1156     DWORD len = _countof(user_name);
1157     BOOL r = GetUserName(user_name, &len);
1158     if (r != 0) {
1159     SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name);
1160     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, EM_SETSEL, 0, -1);
1161     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHUSERNAME), TRUE);
1162     }
1163     break;
1164     }
1165     }
1166 zmatsuo 7507 return TRUE;
1167     }
1168    
1169 maya 3227 default:
1170     return FALSE;
1171     }
1172    
1173 zmatsuo 7634 case WM_DESTROY:
1174     if (hIconDropdown != NULL) {
1175     DeleteObject(hIconDropdown);
1176     }
1177     return FALSE;
1178    
1179 maya 3227 default:
1180     return FALSE;
1181     }
1182     }
1183    
1184 doda 6801 char *AUTH_get_user_name(PTInstVar pvar)
1185 maya 3227 {
1186     return pvar->auth_state.user;
1187     }
1188    
1189     int AUTH_set_supported_auth_types(PTInstVar pvar, int types)
1190     {
1191 doda 6809 logprintf(LOG_LEVEL_VERBOSE, "Server reports supported authentication method mask = %d", types);
1192 maya 3227
1193     if (SSHv1(pvar)) {
1194     types &= (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA)
1195     | (1 << SSH_AUTH_RHOSTS_RSA) | (1 << SSH_AUTH_RHOSTS)
1196     | (1 << SSH_AUTH_TIS) | (1 << SSH_AUTH_PAGEANT);
1197     } else {
1198     // for SSH2(yutaka)
1199     // types &= (1 << SSH_AUTH_PASSWORD);
1200     // ���J���F�����L�������� (2004.12.18 yutaka)
1201     // TIS�������BSSH2����keyboard-interactive�����������B(2005.3.12 yutaka)
1202     types &= (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA)
1203     | (1 << SSH_AUTH_TIS) | (1 << SSH_AUTH_PAGEANT);
1204     }
1205     pvar->auth_state.supported_types = types;
1206    
1207     if (types == 0) {
1208     UTIL_get_lang_msg("MSG_NOAUTHMETHOD_ERROR", pvar,
1209     "Server does not support any of the authentication options\n"
1210     "provided by TTSSH. This connection will now close.");
1211 maya 5678 notify_fatal_error(pvar, pvar->ts->UIMsg, TRUE);
1212 maya 3227 return 0;
1213     } else {
1214     if (pvar->auth_state.auth_dialog != NULL) {
1215 doda 6809 update_server_supported_types(pvar, pvar->auth_state.auth_dialog);
1216 maya 3227 }
1217    
1218     return 1;
1219     }
1220     }
1221    
1222     static void start_user_auth(PTInstVar pvar)
1223     {
1224     // �F���_�C�A���O���\�������� (2004.12.1 yutaka)
1225     PostMessage(pvar->NotificationWindow, WM_COMMAND, (WPARAM) ID_SSHAUTH,
1226     (LPARAM) NULL);
1227     pvar->auth_state.cur_cred.method = SSH_AUTH_NONE;
1228     }
1229    
1230     static void try_default_auth(PTInstVar pvar)
1231     {
1232     if (pvar->session_settings.TryDefaultAuth) {
1233     switch (pvar->session_settings.DefaultAuthMethod) {
1234     case SSH_AUTH_RSA:{
1235     BOOL invalid_passphrase;
1236     char password[] = "";
1237    
1238     pvar->auth_state.cur_cred.key_pair
1239     =
1240     KEYFILES_read_private_key(pvar,
1241     pvar->session_settings.
1242     DefaultRSAPrivateKeyFile,
1243     password,
1244     &invalid_passphrase, TRUE);
1245     if (pvar->auth_state.cur_cred.key_pair == NULL) {
1246     return;
1247     } else {
1248     pvar->auth_state.cur_cred.method = SSH_AUTH_RSA;
1249     }
1250     break;
1251     }
1252    
1253     case SSH_AUTH_RHOSTS:
1254     if (pvar->session_settings.
1255     DefaultRhostsHostPrivateKeyFile[0] != 0) {
1256     BOOL invalid_passphrase;
1257     char password[] = "";
1258    
1259     pvar->auth_state.cur_cred.key_pair
1260     =
1261     KEYFILES_read_private_key(pvar,
1262     pvar->session_settings.
1263     DefaultRhostsHostPrivateKeyFile,
1264     password,
1265     &invalid_passphrase, TRUE);
1266     if (pvar->auth_state.cur_cred.key_pair == NULL) {
1267     return;
1268     } else {
1269     pvar->auth_state.cur_cred.method = SSH_AUTH_RHOSTS_RSA;
1270     }
1271     } else {
1272     pvar->auth_state.cur_cred.method = SSH_AUTH_RHOSTS;
1273     }
1274    
1275     pvar->auth_state.cur_cred.rhosts_client_user =
1276     _strdup(pvar->session_settings.DefaultRhostsLocalUserName);
1277     break;
1278    
1279     case SSH_AUTH_PAGEANT:
1280     pvar->auth_state.cur_cred.method = SSH_AUTH_PAGEANT;
1281     break;
1282    
1283     case SSH_AUTH_PASSWORD:
1284     pvar->auth_state.cur_cred.password = _strdup("");
1285     pvar->auth_state.cur_cred.method = SSH_AUTH_PASSWORD;
1286     break;
1287    
1288     case SSH_AUTH_TIS:
1289     default:
1290     return;
1291     }
1292    
1293     pvar->auth_state.user =
1294     _strdup(pvar->session_settings.DefaultUserName);
1295     }
1296     }
1297    
1298     void AUTH_notify_end_error(PTInstVar pvar)
1299     {
1300     if ((pvar->auth_state.flags & AUTH_START_USER_AUTH_ON_ERROR_END) != 0) {
1301     start_user_auth(pvar);
1302     pvar->auth_state.flags &= ~AUTH_START_USER_AUTH_ON_ERROR_END;
1303     }
1304     }
1305    
1306     void AUTH_advance_to_next_cred(PTInstVar pvar)
1307     {
1308     pvar->auth_state.failed_method = pvar->auth_state.cur_cred.method;
1309    
1310     if (pvar->auth_state.cur_cred.method == SSH_AUTH_NONE) {
1311     try_default_auth(pvar);
1312    
1313     if (pvar->auth_state.cur_cred.method == SSH_AUTH_NONE) {
1314     if (pvar->err_msg != NULL) {
1315     pvar->auth_state.flags |=
1316     AUTH_START_USER_AUTH_ON_ERROR_END;
1317     } else {
1318     // �������F���_�C�A���O���o�������� (2004.12.1 yutaka)
1319     // �R�}���h���C���w������������
1320     start_user_auth(pvar);
1321     }
1322     }
1323     } else {
1324     // �������F���_�C�A���O���o�������� (2004.12.1 yutaka)
1325     // �R�}���h���C���w������(/auth=xxxx)������
1326     start_user_auth(pvar);
1327     }
1328     }
1329    
1330     static void init_TIS_dlg(PTInstVar pvar, HWND dlg)
1331     {
1332     char uimsg[MAX_UIMSG];
1333    
1334     GetWindowText(dlg, uimsg, sizeof(uimsg));
1335     UTIL_get_lang_msg("DLG_TIS_TITLE", pvar, uimsg);
1336     SetWindowText(dlg, pvar->ts->UIMsg);
1337     GetDlgItemText(dlg, IDC_SSHAUTHBANNER, uimsg, sizeof(uimsg));
1338     UTIL_get_lang_msg("DLG_TIS_BANNER", pvar, uimsg);
1339     SetDlgItemText(dlg, IDC_SSHAUTHBANNER, pvar->ts->UIMsg);
1340     GetDlgItemText(dlg, IDOK, uimsg, sizeof(uimsg));
1341     UTIL_get_lang_msg("BTN_OK", pvar, uimsg);
1342     SetDlgItemText(dlg, IDOK, pvar->ts->UIMsg);
1343     GetDlgItemText(dlg, IDCANCEL, uimsg, sizeof(uimsg));
1344     UTIL_get_lang_msg("BTN_DISCONNECT", pvar, uimsg);
1345     SetDlgItemText(dlg, IDCANCEL, pvar->ts->UIMsg);
1346    
1347     init_auth_machine_banner(pvar, dlg);
1348 zmatsuo 7632 init_password_control(pvar, dlg, IDC_SSHPASSWORD, NULL);
1349 maya 3227
1350     if (pvar->auth_state.TIS_prompt != NULL) {
1351     if (strlen(pvar->auth_state.TIS_prompt) > 10000) {
1352     pvar->auth_state.TIS_prompt[10000] = 0;
1353     }
1354     SetDlgItemText(dlg, IDC_SSHAUTHBANNER2,
1355     pvar->auth_state.TIS_prompt);
1356     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1357     }
1358 doda 7477
1359     if (pvar->auth_state.echo) {
1360     SendMessage(GetDlgItem(dlg, IDC_SSHPASSWORD), EM_SETPASSWORDCHAR, 0, 0);
1361     }
1362 maya 3227 }
1363    
1364     static BOOL end_TIS_dlg(PTInstVar pvar, HWND dlg)
1365     {
1366 doda 6801 char *password =
1367 maya 3227 alloc_control_text(GetDlgItem(dlg, IDC_SSHPASSWORD));
1368    
1369     pvar->auth_state.cur_cred.method = SSH_AUTH_TIS;
1370     pvar->auth_state.cur_cred.password = password;
1371     pvar->auth_state.auth_dialog = NULL;
1372    
1373     // add
1374     if (SSHv2(pvar)) {
1375     pvar->keyboard_interactive_password_input = 1;
1376     handle_SSH2_userauth_inforeq(pvar);
1377     }
1378    
1379     SSH_notify_cred(pvar);
1380    
1381     EndDialog(dlg, 1);
1382     return TRUE;
1383     }
1384    
1385     static BOOL CALLBACK TIS_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
1386     LPARAM lParam)
1387     {
1388     PTInstVar pvar;
1389 zmatsuo 7560 // LOGFONT logfont;
1390     // HFONT font;
1391 maya 3227
1392     switch (msg) {
1393     case WM_INITDIALOG:
1394     pvar = (PTInstVar) lParam;
1395     pvar->auth_state.auth_dialog = dlg;
1396     SetWindowLong(dlg, DWL_USER, lParam);
1397    
1398     init_TIS_dlg(pvar, dlg);
1399 zmatsuo 7560 #if 0
1400 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
1401     GetObject(font, sizeof(LOGFONT), &logfont);
1402     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgTisFont, pvar)) {
1403     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1404     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER2, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1405     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1406     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1407     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1408     }
1409     else {
1410     DlgTisFont = NULL;
1411     }
1412 zmatsuo 7560 #endif
1413 maya 3227 // /auth=challenge ������ (2007.10.5 maya)
1414     if (pvar->ssh2_autologin == 1) {
1415     SetDlgItemText(dlg, IDC_SSHPASSWORD, pvar->ssh2_password);
1416     SendMessage(dlg, WM_COMMAND, IDOK, 0);
1417     }
1418    
1419 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
1420 maya 3227 return FALSE; /* because we set the focus */
1421    
1422     case WM_COMMAND:
1423     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
1424    
1425     switch (LOWORD(wParam)) {
1426     case IDOK:
1427 zmatsuo 7560 #if 0
1428 maya 3227 if (DlgTisFont != NULL) {
1429     DeleteObject(DlgTisFont);
1430     }
1431 zmatsuo 7560 #endif
1432 maya 3227 return end_TIS_dlg(pvar, dlg);
1433    
1434     case IDCANCEL: /* kill the connection */
1435     pvar->auth_state.auth_dialog = NULL;
1436 maya 5678 notify_closed_connection(pvar, "authentication cancelled");
1437 maya 3227 EndDialog(dlg, 0);
1438 zmatsuo 7560 #if 0
1439 maya 3227 if (DlgTisFont != NULL) {
1440     DeleteObject(DlgTisFont);
1441     }
1442 zmatsuo 7560 #endif
1443 maya 3227 return TRUE;
1444    
1445     default:
1446     return FALSE;
1447     }
1448    
1449     default:
1450     return FALSE;
1451     }
1452     }
1453    
1454     void AUTH_do_cred_dialog(PTInstVar pvar)
1455     {
1456     if (pvar->auth_state.auth_dialog == NULL) {
1457     HWND cur_active = GetActiveWindow();
1458     DLGPROC dlg_proc;
1459     LPCTSTR dialog_template;
1460    
1461     switch (pvar->auth_state.mode) {
1462     case TIS_AUTH_MODE:
1463     dialog_template = MAKEINTRESOURCE(IDD_SSHTISAUTH);
1464     dlg_proc = TIS_dlg_proc;
1465     break;
1466     case GENERIC_AUTH_MODE:
1467     default:
1468     dialog_template = MAKEINTRESOURCE(IDD_SSHAUTH);
1469     dlg_proc = auth_dlg_proc;
1470     }
1471    
1472     if (!DialogBoxParam(hInst, dialog_template,
1473     cur_active !=
1474     NULL ? cur_active : pvar->NotificationWindow,
1475     dlg_proc, (LPARAM) pvar) == -1) {
1476     UTIL_get_lang_msg("MSG_CREATEWINDOW_AUTH_ERROR", pvar,
1477     "Unable to display authentication dialog box.\n"
1478     "Connection terminated.");
1479 maya 5678 notify_fatal_error(pvar, pvar->ts->UIMsg, TRUE);
1480 maya 3227 }
1481     }
1482     }
1483    
1484     static void init_default_auth_dlg(PTInstVar pvar, HWND dlg)
1485     {
1486 zmatsuo 7632 int id;
1487     TCHAR user_name[UNLEN+1];
1488     DWORD len;
1489     TCHAR uimsg[MAX_UIMSG];
1490     TCHAR uimsg2[MAX_UIMSG];
1491     const static DlgTextInfo text_info[] = {
1492     { 0, "DLG_AUTHSETUP_TITLE" },
1493     { IDC_SSHAUTHBANNER, "DLG_AUTHSETUP_BANNER" },
1494     { IDC_SSH_NO_USERNAME, "DLG_AUTHSETUP_NO_USERNAME" },
1495     { IDC_SSH_DEFAULTUSERNAME, "DLG_AUTHSETUP_USERNAME" },
1496     { IDC_SSH_WINDOWS_USERNAME, "DLG_AUTHSETUP_SYSTEM_USERNAME" },
1497     { IDC_SSH_WINDOWS_USERNAME_TEXT, "DLG_AUTHSETUP_SYSTEM_USERNAME_TEXT" },
1498     { IDC_SSHUSEPASSWORD, "DLG_AUTHSETUP_METHOD_PASSWORD" },
1499     { IDC_SSHUSERSA, "DLG_AUTHSETUP_METHOD_RSA" },
1500     { IDC_SSHUSERHOSTS, "DLG_AUTHSETUP_METHOD_RHOST" },
1501     { IDC_SSHUSETIS, "DLG_AUTHSETUP_METHOD_CHALLENGE" },
1502     { IDC_SSHUSEPAGEANT, "DLG_AUTHSETUP_METHOD_PAGEANT" },
1503     { IDC_RSAFILENAMELABEL, "DLG_AUTH_PRIVATEKEY" },
1504     { IDC_LOCALUSERNAMELABEL, "DLG_AUTH_LOCALUSER" },
1505     { IDC_HOSTRSAFILENAMELABEL, "DLG_AUTH_HOST_PRIVATEKEY" },
1506     { IDC_CHECKAUTH, "DLG_AUTHSETUP_CHECKAUTH" },
1507     { IDOK, "BTN_OK" },
1508     { IDCANCEL, "BTN_CANCEL" },
1509     };
1510 maya 3227
1511 zmatsuo 7632 SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile);
1512 maya 3227
1513     switch (pvar->settings.DefaultAuthMethod) {
1514     case SSH_AUTH_RSA:
1515     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1516     IDC_SSHUSERSA);
1517     break;
1518     case SSH_AUTH_RHOSTS:
1519     case SSH_AUTH_RHOSTS_RSA:
1520     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1521     IDC_SSHUSERHOSTS);
1522     break;
1523     case SSH_AUTH_TIS:
1524     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1525     IDC_SSHUSETIS);
1526     break;
1527     case SSH_AUTH_PAGEANT:
1528     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1529     IDC_SSHUSEPAGEANT);
1530     break;
1531     case SSH_AUTH_PASSWORD:
1532     default:
1533     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1534     IDC_SSHUSEPASSWORD);
1535     }
1536    
1537     SetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->settings.DefaultUserName);
1538     SetDlgItemText(dlg, IDC_RSAFILENAME,
1539     pvar->settings.DefaultRSAPrivateKeyFile);
1540     SetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
1541     pvar->settings.DefaultRhostsHostPrivateKeyFile);
1542     SetDlgItemText(dlg, IDC_LOCALUSERNAME,
1543     pvar->settings.DefaultRhostsLocalUserName);
1544    
1545     if (pvar->settings.CheckAuthListFirst) {
1546     CheckDlgButton(dlg, IDC_CHECKAUTH, TRUE);
1547     }
1548 zmatsuo 7632
1549     if (pvar->session_settings.DefaultUserName[0] == 0) {
1550     // ���������u�����������v����������
1551     pvar->session_settings.DefaultUserType = 0;
1552     }
1553     id = pvar->settings.DefaultUserType == 1 ? IDC_SSH_DEFAULTUSERNAME :
1554     pvar->settings.DefaultUserType == 2 ? IDC_SSH_WINDOWS_USERNAME :
1555     IDC_SSH_NO_USERNAME;
1556     CheckRadioButton(dlg, IDC_SSH_NO_USERNAME, IDC_SSH_WINDOWS_USERNAME, id);
1557    
1558     len = _countof(user_name);
1559     GetUserName(user_name, &len);
1560    
1561     GetDlgItemText(dlg, IDC_SSH_WINDOWS_USERNAME_TEXT, uimsg, _countof(uimsg));
1562     _stprintf_s(uimsg2, _countof(uimsg2), uimsg, user_name);
1563     SetDlgItemText(dlg, IDC_SSH_WINDOWS_USERNAME_TEXT, uimsg2);
1564 maya 3227 }
1565    
1566     static BOOL end_default_auth_dlg(PTInstVar pvar, HWND dlg)
1567     {
1568     if (IsDlgButtonChecked(dlg, IDC_SSHUSERSA)) {
1569     pvar->settings.DefaultAuthMethod = SSH_AUTH_RSA;
1570     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSERHOSTS)) {
1571     if (GetWindowTextLength(GetDlgItem(dlg, IDC_HOSTRSAFILENAME)) > 0) {
1572     pvar->settings.DefaultAuthMethod = SSH_AUTH_RHOSTS_RSA;
1573     } else {
1574     pvar->settings.DefaultAuthMethod = SSH_AUTH_RHOSTS;
1575     }
1576     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSETIS)) {
1577     pvar->settings.DefaultAuthMethod = SSH_AUTH_TIS;
1578     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSEPAGEANT)) {
1579     pvar->settings.DefaultAuthMethod = SSH_AUTH_PAGEANT;
1580     } else {
1581     pvar->settings.DefaultAuthMethod = SSH_AUTH_PASSWORD;
1582     }
1583    
1584     GetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->settings.DefaultUserName,
1585     sizeof(pvar->settings.DefaultUserName));
1586     GetDlgItemText(dlg, IDC_RSAFILENAME,
1587     pvar->settings.DefaultRSAPrivateKeyFile,
1588     sizeof(pvar->settings.DefaultRSAPrivateKeyFile));
1589     GetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
1590     pvar->settings.DefaultRhostsHostPrivateKeyFile,
1591     sizeof(pvar->settings.DefaultRhostsHostPrivateKeyFile));
1592     GetDlgItemText(dlg, IDC_LOCALUSERNAME,
1593     pvar->settings.DefaultRhostsLocalUserName,
1594     sizeof(pvar->settings.DefaultRhostsLocalUserName));
1595 zmatsuo 7632 pvar->settings.DefaultUserType =
1596     IsDlgButtonChecked(dlg, IDC_SSH_DEFAULTUSERNAME) ? 1 :
1597     IsDlgButtonChecked(dlg, IDC_SSH_WINDOWS_USERNAME) ? 2 : 0;
1598 maya 3227
1599     if (IsDlgButtonChecked(dlg, IDC_CHECKAUTH)) {
1600     pvar->settings.CheckAuthListFirst = TRUE;
1601     }
1602     else {
1603     pvar->settings.CheckAuthListFirst = FALSE;
1604     }
1605    
1606     EndDialog(dlg, 1);
1607     return TRUE;
1608     }
1609    
1610     static BOOL CALLBACK default_auth_dlg_proc(HWND dlg, UINT msg,
1611     WPARAM wParam, LPARAM lParam)
1612     {
1613     PTInstVar pvar;
1614 zmatsuo 7560 // LOGFONT logfont;
1615     // HFONT font;
1616 maya 3227
1617     switch (msg) {
1618     case WM_INITDIALOG:
1619     pvar = (PTInstVar) lParam;
1620     SetWindowLong(dlg, DWL_USER, lParam);
1621    
1622     init_default_auth_dlg(pvar, dlg);
1623 zmatsuo 7560 #if 0
1624 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
1625     GetObject(font, sizeof(LOGFONT), &logfont);
1626     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgAuthSetupFont, pvar)) {
1627     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1628     SendDlgItemMessage(dlg, IDC_SSHUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1629     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1630     SendDlgItemMessage(dlg, IDC_SSHUSEPASSWORD, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1631     SendDlgItemMessage(dlg, IDC_SSHUSERSA, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1632     SendDlgItemMessage(dlg, IDC_CHOOSERSAFILE, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1633     SendDlgItemMessage(dlg, IDC_RSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1634     SendDlgItemMessage(dlg, IDC_SSHUSERHOSTS, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1635     SendDlgItemMessage(dlg, IDC_LOCALUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1636     SendDlgItemMessage(dlg, IDC_LOCALUSERNAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1637     SendDlgItemMessage(dlg, IDC_CHOOSEHOSTRSAFILE, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1638     SendDlgItemMessage(dlg, IDC_HOSTRSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1639     SendDlgItemMessage(dlg, IDC_SSHUSETIS, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1640     SendDlgItemMessage(dlg, IDC_SSHUSEPAGEANT, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1641     SendDlgItemMessage(dlg, IDC_CHECKAUTH, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1642     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1643     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1644     }
1645     else {
1646     DlgAuthSetupFont = NULL;
1647     }
1648 zmatsuo 7560 #endif
1649 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
1650 maya 3227 return TRUE; /* because we do not set the focus */
1651    
1652     case WM_COMMAND:
1653     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
1654    
1655     switch (LOWORD(wParam)) {
1656     case IDOK:
1657 zmatsuo 7560 #if 0
1658 maya 3227 if (DlgAuthSetupFont != NULL) {
1659     DeleteObject(DlgAuthSetupFont);
1660     }
1661 zmatsuo 7560 #endif
1662 maya 3227 return end_default_auth_dlg(pvar, dlg);
1663    
1664     case IDCANCEL:
1665     EndDialog(dlg, 0);
1666 zmatsuo 7560 #if 0
1667 maya 3227 if (DlgAuthSetupFont != NULL) {
1668     DeleteObject(DlgAuthSetupFont);
1669     }
1670 zmatsuo 7560 #endif
1671 maya 3227 return TRUE;
1672    
1673     case IDC_CHOOSERSAFILE:
1674     choose_RSA_key_file(dlg, pvar);
1675     return TRUE;
1676    
1677     case IDC_CHOOSEHOSTRSAFILE:
1678     choose_host_RSA_key_file(dlg, pvar);
1679     return TRUE;
1680    
1681     default:
1682     return FALSE;
1683     }
1684    
1685     default:
1686     return FALSE;
1687     }
1688     }
1689    
1690     void AUTH_init(PTInstVar pvar)
1691     {
1692     pvar->auth_state.failed_method = SSH_AUTH_NONE;
1693     pvar->auth_state.auth_dialog = NULL;
1694     pvar->auth_state.user = NULL;
1695     pvar->auth_state.flags = 0;
1696     pvar->auth_state.TIS_prompt = NULL;
1697 doda 7477 pvar->auth_state.echo = 0;
1698 maya 3227 pvar->auth_state.supported_types = 0;
1699     pvar->auth_state.cur_cred.method = SSH_AUTH_NONE;
1700     pvar->auth_state.cur_cred.password = NULL;
1701     pvar->auth_state.cur_cred.rhosts_client_user = NULL;
1702     pvar->auth_state.cur_cred.key_pair = NULL;
1703     AUTH_set_generic_mode(pvar);
1704     }
1705    
1706     void AUTH_set_generic_mode(PTInstVar pvar)
1707     {
1708     pvar->auth_state.mode = GENERIC_AUTH_MODE;
1709     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1710     }
1711    
1712 doda 7477 void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len, int echo)
1713 maya 3227 {
1714     if (pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1715     pvar->auth_state.mode = TIS_AUTH_MODE;
1716    
1717     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1718     pvar->auth_state.TIS_prompt = malloc(len + 1);
1719     memcpy(pvar->auth_state.TIS_prompt, prompt, len);
1720     pvar->auth_state.TIS_prompt[len] = 0;
1721 doda 7477 pvar->auth_state.echo = echo;
1722 maya 3227 } else {
1723     AUTH_set_generic_mode(pvar);
1724     }
1725     }
1726    
1727     void AUTH_do_default_cred_dialog(PTInstVar pvar)
1728     {
1729     HWND cur_active = GetActiveWindow();
1730    
1731     if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHAUTHSETUP),
1732     cur_active != NULL ? cur_active
1733     : pvar->NotificationWindow,
1734     default_auth_dlg_proc, (LPARAM) pvar) == -1) {
1735     UTIL_get_lang_msg("MSG_CREATEWINDOW_AUTHSETUP_ERROR", pvar,
1736     "Unable to display authentication setup dialog box.");
1737     notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1738     }
1739     }
1740    
1741     void AUTH_destroy_cur_cred(PTInstVar pvar)
1742     {
1743     destroy_malloced_string(&pvar->auth_state.cur_cred.password);
1744     destroy_malloced_string(&pvar->auth_state.cur_cred.rhosts_client_user);
1745     if (pvar->auth_state.cur_cred.key_pair != NULL) {
1746 maya 4307 key_free(pvar->auth_state.cur_cred.key_pair);
1747 maya 3227 pvar->auth_state.cur_cred.key_pair = NULL;
1748     }
1749     }
1750    
1751 maya 4307 static const char *get_auth_method_name(SSHAuthMethod auth)
1752 maya 3227 {
1753     switch (auth) {
1754     case SSH_AUTH_PASSWORD:
1755     return "password";
1756     case SSH_AUTH_RSA:
1757 maya 5550 return "publickey";
1758 maya 3227 case SSH_AUTH_PAGEANT:
1759 maya 5550 return "publickey";
1760 maya 3227 case SSH_AUTH_RHOSTS:
1761     return "rhosts";
1762     case SSH_AUTH_RHOSTS_RSA:
1763     return "rhosts with RSA";
1764     case SSH_AUTH_TIS:
1765     return "challenge/response (TIS)";
1766     default:
1767     return "unknown method";
1768     }
1769     }
1770    
1771 doda 6801 void AUTH_get_auth_info(PTInstVar pvar, char *dest, int len)
1772 maya 3227 {
1773 maya 4307 const char *method = "unknown";
1774 yutakapon 5545 char buf[256];
1775 maya 3227
1776     if (pvar->auth_state.user == NULL) {
1777     strncpy_s(dest, len, "None", _TRUNCATE);
1778     } else if (pvar->auth_state.cur_cred.method != SSH_AUTH_NONE) {
1779     if (SSHv1(pvar)) {
1780     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1781 maya 5550 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1782     pvar->auth_state.user,
1783 maya 3227 get_auth_method_name(pvar->auth_state.cur_cred.method));
1784    
1785 maya 5550 if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1786     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1787     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1788     "RSA");
1789     strncat_s(dest, len, buf, _TRUNCATE);
1790     }
1791     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
1792     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1793     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1794     "RSA");
1795     strncat_s(dest, len, buf, _TRUNCATE);
1796     }
1797 maya 3227 } else {
1798     // SSH2:�F�����\�b�h������ (2004.12.23 yutaka)
1799     // keyboard-interactive���\�b�h������ (2005.3.12 yutaka)
1800     if (pvar->auth_state.cur_cred.method == SSH_AUTH_PASSWORD ||
1801     pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1802     // keyboard-interactive���\�b�h������ (2005.1.24 yutaka)
1803     if (pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1804     method = "keyboard-interactive";
1805     } else {
1806     method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1807     }
1808     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1809 maya 5550 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1810     pvar->auth_state.user, method);
1811     }
1812     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1813     method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1814     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1815     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1816     pvar->auth_state.user,
1817     get_auth_method_name(pvar->auth_state.cur_cred.method));
1818 maya 3227
1819 maya 5550 UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1820     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1821     ssh_key_type(pvar->auth_state.cur_cred.key_pair->type));
1822     strncat_s(dest, len, buf, _TRUNCATE);
1823     }
1824     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
1825     int key_len = get_uint32_MSBfirst(pvar->pageant_curkey + 4);
1826     char *s = (char *)malloc(key_len+1);
1827 yutakapon 5545
1828 maya 5550 method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1829     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1830     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1831     pvar->auth_state.user,
1832     get_auth_method_name(pvar->auth_state.cur_cred.method));
1833 maya 3227
1834 maya 5550 memcpy(s, pvar->pageant_curkey+4+4, key_len);
1835     s[key_len] = '\0';
1836     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1837     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1838     ssh_key_type(get_keytype_from_name(s)));
1839     strncat_s(dest, len, buf, _TRUNCATE);
1840    
1841     free(s);
1842 maya 3227 }
1843     }
1844    
1845     } else {
1846     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1847     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, pvar->auth_state.user,
1848     get_auth_method_name(pvar->auth_state.failed_method));
1849     }
1850    
1851     dest[len - 1] = 0;
1852     }
1853    
1854     void AUTH_notify_disconnecting(PTInstVar pvar)
1855     {
1856     if (pvar->auth_state.auth_dialog != NULL) {
1857     PostMessage(pvar->auth_state.auth_dialog, WM_COMMAND, IDCANCEL, 0);
1858     /* the main window might not go away if it's not enabled. (see vtwin.cpp) */
1859     EnableWindow(pvar->NotificationWindow, TRUE);
1860     }
1861     }
1862    
1863     void AUTH_end(PTInstVar pvar)
1864     {
1865     destroy_malloced_string(&pvar->auth_state.user);
1866     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1867    
1868     AUTH_destroy_cur_cred(pvar);
1869     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26