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 7632 - (hide annotations) (download) (as text)
Fri Apr 26 17:18:36 2019 UTC (4 years, 11 months ago) by zmatsuo
Original Path: trunk/ttssh2/ttxssh/auth.c
File MIME type: text/x-csrc
File size: 63410 byte(s)
Merge branch 'ssh_auth_dialog' into trunk
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 maya 3227
805     switch (msg) {
806     case WM_INITDIALOG:
807     pvar = (PTInstVar) lParam;
808     pvar->auth_state.auth_dialog = dlg;
809     SetWindowLong(dlg, DWL_USER, lParam);
810    
811 zmatsuo 7632 UseControlChar = TRUE;
812     ShowPassPhrase = FALSE;
813     init_auth_dlg(pvar, dlg, &UseControlChar);
814 zmatsuo 7560 #if 0
815 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
816     GetObject(font, sizeof(LOGFONT), &logfont);
817     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgAuthFont, pvar)) {
818     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
819     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER2, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
820     SendDlgItemMessage(dlg, IDC_SSHUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
821     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
822     SendDlgItemMessage(dlg, IDC_SSHPASSWORDCAPTION, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
823     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
824     SendDlgItemMessage(dlg, IDC_REMEMBER_PASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
825     SendDlgItemMessage(dlg, IDC_FORWARD_AGENT, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
826     SendDlgItemMessage(dlg, IDC_SSHUSEPASSWORD, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
827     SendDlgItemMessage(dlg, IDC_SSHUSERSA, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
828     SendDlgItemMessage(dlg, IDC_CHOOSERSAFILE, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
829     SendDlgItemMessage(dlg, IDC_RSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
830     SendDlgItemMessage(dlg, IDC_SSHUSERHOSTS, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
831     SendDlgItemMessage(dlg, IDC_LOCALUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
832     SendDlgItemMessage(dlg, IDC_LOCALUSERNAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
833     SendDlgItemMessage(dlg, IDC_CHOOSEHOSTRSAFILE, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
834     SendDlgItemMessage(dlg, IDC_HOSTRSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
835     SendDlgItemMessage(dlg, IDC_SSHUSETIS, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
836     SendDlgItemMessage(dlg, IDC_SSHUSEPAGEANT, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
837     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
838     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgAuthFont, MAKELPARAM(TRUE,0));
839     }
840     else {
841     DlgAuthFont = NULL;
842     }
843 zmatsuo 7560 #endif
844 zmatsuo 7632
845 maya 3227 // SSH2 autologin���L�����������A�^�C�}���d�|�����B (2004.12.1 yutaka)
846     if (pvar->ssh2_autologin == 1) {
847     autologin_sent_none = FALSE;
848     SetTimer(dlg, IDC_TIMER1, autologin_timeout, 0);
849     }
850     else {
851     // �T�|�[�g�������������\�b�h���`�F�b�N�����B(2007.9.24 maya)
852     // �������L�����A�����������s�����������A���[�U�����m����������
853     if (pvar->session_settings.CheckAuthListFirst &&
854     !pvar->tryed_ssh2_authlist &&
855     GetWindowTextLength(GetDlgItem(dlg, IDC_SSHUSERNAME)) > 0) {
856     SetTimer(dlg, IDC_TIMER2, autologin_timeout, 0);
857     }
858 maya 3342 // /auth=challenge �� /ask4passwd ���w���������������[�U�����m����������
859     // �������AOK �{�^���������� TIS auth �_�C�A���O���o��
860     else if (pvar->ssh2_authmethod == SSH_AUTH_TIS &&
861     pvar->ask4passwd &&
862     GetWindowTextLength(GetDlgItem(dlg, IDC_SSHUSERNAME)) > 0) {
863 maya 3227 SetTimer(dlg, IDC_TIMER3, autologin_timeout, 0);
864     }
865     }
866 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
867 maya 3227 return FALSE; /* because we set the focus */
868    
869     case WM_TIMER:
870     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
871     // �F�������������������A�F���f�[�^�����M�����B�����������A�������B(2004.12.16 yutaka)
872     if (wParam == IDC_TIMER1) {
873     // �������O�C��������
874     if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
875     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
876     if (SSHv2(pvar) &&
877     pvar->session_settings.CheckAuthListFirst &&
878     !pvar->tryed_ssh2_authlist) {
879     if (!autologin_sent_none) {
880 maya 3342 autologin_sent_none = TRUE;
881    
882 maya 3336 // �_�C�A���O�����[�U������������
883     if (pvar->auth_state.user == NULL) {
884     pvar->auth_state.user =
885     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
886     }
887    
888 maya 3342 // CheckAuthListFirst �� TRUE �������� AuthList ���A����������������
889     // IDOK �����������i�����������A�F�����\�b�h none ������ (2008.10.12 maya)
890 maya 3227 do_SSH2_userauth(pvar);
891     }
892     //else {
893     // none �������������A����������������
894     //}
895     }
896     else {
897 maya 3342 // SSH1 ������
898     // ������ CheckAuthListFirst �� FALSE ������
899     // ������ CheckAuthListFirst TRUE ���Aauthlist ���A������������
900 maya 3346 KillTimer(dlg, IDC_TIMER1);
901 maya 3342
902     // �_�C�A���O�����[�U������������
903     if (pvar->auth_state.user == NULL) {
904     pvar->auth_state.user =
905     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
906     }
907    
908 maya 3227 SendMessage(dlg, WM_COMMAND, IDOK, 0);
909     }
910     }
911     }
912     else if (wParam == IDC_TIMER2) {
913     // authlist ����������
914 maya 3346 if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
915     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
916     if (SSHv2(pvar)) {
917 maya 3227 KillTimer(dlg, IDC_TIMER2);
918    
919     // �_�C�A���O�����[�U������������
920     if (pvar->auth_state.user == NULL) {
921     pvar->auth_state.user =
922     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
923     }
924    
925     // ���[�U�������X��������
926     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
927 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
928 maya 3227
929 maya 3342 // �F�����\�b�h none ������
930 maya 3227 do_SSH2_userauth(pvar);
931    
932 maya 3342 // TIS �p�� OK �����������F�������s������������������
933 maya 3227 // Unexpected SSH2 message �������B
934     }
935 maya 3346 else if (SSHv1(pvar)) {
936     KillTimer(dlg, IDC_TIMER2);
937    
938     // TIS �p�� OK ������
939     if (pvar->ssh2_authmethod == SSH_AUTH_TIS) {
940     SendMessage(dlg, WM_COMMAND, IDOK, 0);
941     }
942     // SSH1 �����F�����\�b�h none ����������
943 maya 3227 }
944 maya 3346 // �v���g�R���o�[�W�����m���O������������
945 maya 3227 }
946     }
947     else if (wParam == IDC_TIMER3) {
948 maya 3346 if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
949     (pvar->ssh_state.status_flags & STATUS_HOST_OK)) {
950     if (SSHv2(pvar) || SSHv1(pvar)) {
951     KillTimer(dlg, IDC_TIMER3);
952    
953     // TIS �p�� OK ������
954     SendMessage(dlg, WM_COMMAND, IDOK, 0);
955 maya 3227 }
956 maya 3346 // �v���g�R���o�[�W�����m���O������������
957 maya 3227 }
958     }
959     return FALSE;
960    
961     case WM_COMMAND:
962     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
963    
964     switch (LOWORD(wParam)) {
965     case IDOK:
966 yutakapon 5562 // �F�������T�[�o�������f�������������A�L�����Z�������������B(2014.3.31 yutaka)
967     if (!pvar->cv->Ready) {
968     goto canceled;
969     }
970    
971 maya 3227 // �F�������������������A�F���f�[�^�����M�����B�����������A�������B(2001.1.25 yutaka)
972     if (pvar->userauth_retry_count == 0 &&
973     ((pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) ||
974     !(pvar->ssh_state.status_flags & STATUS_HOST_OK))) {
975     return FALSE;
976     }
977     else if (SSHv2(pvar) &&
978     pvar->session_settings.CheckAuthListFirst &&
979     !pvar->tryed_ssh2_authlist) {
980     // CheckAuthListFirst ���L�����F������������������������
981     // OK �������������������� (2008.10.4 maya)
982     return FALSE;
983     }
984    
985     return end_auth_dlg(pvar, dlg);
986    
987     case IDCANCEL: /* kill the connection */
988 yutakapon 5562 canceled:
989 maya 3227 pvar->auth_state.auth_dialog = NULL;
990 maya 5678 notify_closed_connection(pvar, "authentication cancelled");
991 maya 3227 EndDialog(dlg, 0);
992 zmatsuo 7560 #if 0
993 maya 3227 if (DlgAuthFont != NULL) {
994     DeleteObject(DlgAuthFont);
995     }
996 zmatsuo 7560 #endif
997 maya 3227 return TRUE;
998    
999     case IDC_SSHUSERNAME:
1000     // ���[�U�����t�H�[�J�X������������ (2007.9.29 maya)
1001     if (!(pvar->ssh_state.status_flags & STATUS_DONT_SEND_USER_NAME) &&
1002     (pvar->ssh_state.status_flags & STATUS_HOST_OK) &&
1003     HIWORD(wParam) == EN_KILLFOCUS) {
1004     // �������L���������������s��������������
1005     if (SSHv2(pvar) &&
1006     pvar->session_settings.CheckAuthListFirst &&
1007     !pvar->tryed_ssh2_authlist) {
1008     // �_�C�A���O�����[�U�������f
1009     if (pvar->auth_state.user == NULL) {
1010     pvar->auth_state.user =
1011     alloc_control_text(GetDlgItem(dlg, IDC_SSHUSERNAME));
1012     }
1013    
1014     // ���[�U���������������������`�F�b�N����
1015     if (strlen(pvar->auth_state.user) == 0) {
1016     return FALSE;
1017     }
1018    
1019     // ���[�U�������X��������
1020     EnableWindow(GetDlgItem(dlg, IDC_SSHUSERNAME), FALSE);
1021 zmatsuo 7632 EnableWindow(GetDlgItem(dlg, IDC_USERNAME_OPTION), FALSE);
1022 maya 3227
1023 maya 3342 // �F�����\�b�h none ������
1024 maya 3227 do_SSH2_userauth(pvar);
1025     return TRUE;
1026     }
1027     }
1028    
1029     return FALSE;
1030    
1031     case IDC_SSHUSEPASSWORD:
1032     case IDC_SSHUSERSA:
1033     case IDC_SSHUSERHOSTS:
1034     case IDC_SSHUSETIS:
1035     case IDC_SSHUSEPAGEANT:
1036     set_auth_options_status(dlg, LOWORD(wParam));
1037     return TRUE;
1038    
1039     case IDC_CHOOSERSAFILE:
1040     choose_RSA_key_file(dlg, pvar);
1041     return TRUE;
1042    
1043     case IDC_CHOOSEHOSTRSAFILE:
1044     choose_host_RSA_key_file(dlg, pvar);
1045     return TRUE;
1046    
1047     case IDC_FORWARD_AGENT:
1048     // �����Z�b�V�������������f������ (2008.12.4 maya)
1049     pvar->session_settings.ForwardAgent = IsDlgButtonChecked(dlg, IDC_FORWARD_AGENT);
1050     return TRUE;
1051    
1052 zmatsuo 7632 case IDC_SSHPASSWORD_OPTION: {
1053     TCHAR uimsg[MAX_UIMSG];
1054     HMENU hMenu= CreatePopupMenu();
1055     GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_CLIPBOARD",
1056     uimsg, _countof(uimsg),
1057     "Paste from &clipboard",
1058     pvar->ts->UILanguageFile);
1059     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
1060     GetI18nStrT("ttssh", "DLG_AUTH_CLEAR_CLIPBOARD",
1061     uimsg, _countof(uimsg),
1062     "Paste from &clipboard and cl&ear clipboard",
1063     pvar->ts->UILanguageFile);
1064     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 2, uimsg);
1065     GetI18nStrT("ttssh", "DLG_AUTH_USE_CONTORL_CHARACTERS",
1066     uimsg, _countof(uimsg),
1067     "Use control charac&ters",
1068     pvar->ts->UILanguageFile);
1069     AppendMenu(hMenu, MF_ENABLED | MF_STRING | (UseControlChar ? MFS_CHECKED : 0), 3, uimsg);
1070     GetI18nStrT("ttssh", "DLG_AUTH_SHOW_PASSPHRASE",
1071     uimsg, _countof(uimsg),
1072     "&Show passphrase",
1073     pvar->ts->UILanguageFile);
1074     AppendMenu(hMenu, MF_ENABLED | MF_STRING | (ShowPassPhrase ? MFS_CHECKED : 0), 4, uimsg);
1075     RECT rect;
1076     HWND hWndButton = GetDlgItem(dlg, IDC_SSHPASSWORD_OPTION);
1077     GetWindowRect(hWndButton, &rect);
1078     int result = TrackPopupMenu(hMenu, TPM_RETURNCMD, rect.left, rect.bottom, 0 , hWndButton, NULL);
1079     DestroyMenu(hMenu);
1080     switch(result) {
1081     case 1:
1082     case 2: {
1083     // �N���b�v�{�[�h�����y�[�X�g
1084     BOOL clear_clipboard = result == 2;
1085     char *clipboard = GetClipboardTextA(dlg, clear_clipboard);
1086     if (clipboard != NULL) {
1087     SetDlgItemTextA(dlg, IDC_SSHPASSWORD, clipboard);
1088     free(clipboard);
1089     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1090     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
1091     return FALSE;
1092     }
1093     return TRUE;
1094 zmatsuo 7507 }
1095 zmatsuo 7632 case 3:
1096     // �����R�[�h�g�p/���g�p
1097     UseControlChar = !UseControlChar;
1098     break;
1099     case 4:
1100     // �p�X�t���[�Y�\��/���\��
1101     ShowPassPhrase = !ShowPassPhrase;
1102     {
1103     // ������ on/off ������������
1104     HWND hWnd = GetDlgItem(dlg, IDC_SSHPASSWORD);
1105     static wchar_t password_char;
1106     if (password_char == 0) {
1107     wchar_t c = (wchar_t)SendMessage(hWnd, EM_GETPASSWORDCHAR, 0, 0);
1108     password_char = c;
1109     }
1110     if (ShowPassPhrase) {
1111     SendMessage(hWnd, EM_SETPASSWORDCHAR, 0, 0);
1112     } else {
1113     #if !defined(UNICODE)
1114     if (password_char < 0x100) {
1115     SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1116     } else {
1117     // TODO W�n������ ����������������
1118     //SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1119     SendMessageA(hWnd, EM_SETPASSWORDCHAR, (WPARAM)'*', 0);
1120     }
1121     #else
1122     SendMessageW(hWnd, EM_SETPASSWORDCHAR, (WPARAM)password_char, 0);
1123     #endif
1124     }
1125     //InvalidateRect(hWnd, NULL, TRUE);
1126     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, EM_SETSEL, 0, -1);
1127     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHPASSWORD), TRUE);
1128     return TRUE;
1129     }
1130     break;
1131     }
1132     break;
1133     }
1134    
1135     case IDC_USERNAME_OPTION: {
1136     TCHAR uimsg[MAX_UIMSG];
1137     HMENU hMenu= CreatePopupMenu();
1138     GetI18nStrT("TTSSH", "DLG_AUTH_PASTE_WINDOWS_USERNAME",
1139     uimsg, _countof(uimsg),
1140     "Paste &Windows username",
1141     pvar->ts->UILanguageFile);
1142     AppendMenu(hMenu, MF_ENABLED | MF_STRING, 1, uimsg);
1143     RECT rect;
1144     HWND hWndButton = GetDlgItem(dlg, IDC_USERNAME_OPTION);
1145     GetWindowRect(hWndButton, &rect);
1146     int result = TrackPopupMenu(hMenu, TPM_RETURNCMD, rect.left, rect.bottom, 0 , hWndButton, NULL);
1147     DestroyMenu(hMenu);
1148     switch (result) {
1149     case 1: {
1150     TCHAR user_name[UNLEN+1];
1151     DWORD len = _countof(user_name);
1152     BOOL r = GetUserName(user_name, &len);
1153     if (r != 0) {
1154     SetDlgItemText(dlg, IDC_SSHUSERNAME, user_name);
1155     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, EM_SETSEL, 0, -1);
1156     SendMessage(dlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(dlg, IDC_SSHUSERNAME), TRUE);
1157     }
1158     break;
1159     }
1160     }
1161 zmatsuo 7507 return TRUE;
1162     }
1163    
1164 maya 3227 default:
1165     return FALSE;
1166     }
1167    
1168     default:
1169     return FALSE;
1170     }
1171     }
1172    
1173 doda 6801 char *AUTH_get_user_name(PTInstVar pvar)
1174 maya 3227 {
1175     return pvar->auth_state.user;
1176     }
1177    
1178     int AUTH_set_supported_auth_types(PTInstVar pvar, int types)
1179     {
1180 doda 6809 logprintf(LOG_LEVEL_VERBOSE, "Server reports supported authentication method mask = %d", types);
1181 maya 3227
1182     if (SSHv1(pvar)) {
1183     types &= (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA)
1184     | (1 << SSH_AUTH_RHOSTS_RSA) | (1 << SSH_AUTH_RHOSTS)
1185     | (1 << SSH_AUTH_TIS) | (1 << SSH_AUTH_PAGEANT);
1186     } else {
1187     // for SSH2(yutaka)
1188     // types &= (1 << SSH_AUTH_PASSWORD);
1189     // ���J���F�����L�������� (2004.12.18 yutaka)
1190     // TIS�������BSSH2����keyboard-interactive�����������B(2005.3.12 yutaka)
1191     types &= (1 << SSH_AUTH_PASSWORD) | (1 << SSH_AUTH_RSA)
1192     | (1 << SSH_AUTH_TIS) | (1 << SSH_AUTH_PAGEANT);
1193     }
1194     pvar->auth_state.supported_types = types;
1195    
1196     if (types == 0) {
1197     UTIL_get_lang_msg("MSG_NOAUTHMETHOD_ERROR", pvar,
1198     "Server does not support any of the authentication options\n"
1199     "provided by TTSSH. This connection will now close.");
1200 maya 5678 notify_fatal_error(pvar, pvar->ts->UIMsg, TRUE);
1201 maya 3227 return 0;
1202     } else {
1203     if (pvar->auth_state.auth_dialog != NULL) {
1204 doda 6809 update_server_supported_types(pvar, pvar->auth_state.auth_dialog);
1205 maya 3227 }
1206    
1207     return 1;
1208     }
1209     }
1210    
1211     static void start_user_auth(PTInstVar pvar)
1212     {
1213     // �F���_�C�A���O���\�������� (2004.12.1 yutaka)
1214     PostMessage(pvar->NotificationWindow, WM_COMMAND, (WPARAM) ID_SSHAUTH,
1215     (LPARAM) NULL);
1216     pvar->auth_state.cur_cred.method = SSH_AUTH_NONE;
1217     }
1218    
1219     static void try_default_auth(PTInstVar pvar)
1220     {
1221     if (pvar->session_settings.TryDefaultAuth) {
1222     switch (pvar->session_settings.DefaultAuthMethod) {
1223     case SSH_AUTH_RSA:{
1224     BOOL invalid_passphrase;
1225     char password[] = "";
1226    
1227     pvar->auth_state.cur_cred.key_pair
1228     =
1229     KEYFILES_read_private_key(pvar,
1230     pvar->session_settings.
1231     DefaultRSAPrivateKeyFile,
1232     password,
1233     &invalid_passphrase, TRUE);
1234     if (pvar->auth_state.cur_cred.key_pair == NULL) {
1235     return;
1236     } else {
1237     pvar->auth_state.cur_cred.method = SSH_AUTH_RSA;
1238     }
1239     break;
1240     }
1241    
1242     case SSH_AUTH_RHOSTS:
1243     if (pvar->session_settings.
1244     DefaultRhostsHostPrivateKeyFile[0] != 0) {
1245     BOOL invalid_passphrase;
1246     char password[] = "";
1247    
1248     pvar->auth_state.cur_cred.key_pair
1249     =
1250     KEYFILES_read_private_key(pvar,
1251     pvar->session_settings.
1252     DefaultRhostsHostPrivateKeyFile,
1253     password,
1254     &invalid_passphrase, TRUE);
1255     if (pvar->auth_state.cur_cred.key_pair == NULL) {
1256     return;
1257     } else {
1258     pvar->auth_state.cur_cred.method = SSH_AUTH_RHOSTS_RSA;
1259     }
1260     } else {
1261     pvar->auth_state.cur_cred.method = SSH_AUTH_RHOSTS;
1262     }
1263    
1264     pvar->auth_state.cur_cred.rhosts_client_user =
1265     _strdup(pvar->session_settings.DefaultRhostsLocalUserName);
1266     break;
1267    
1268     case SSH_AUTH_PAGEANT:
1269     pvar->auth_state.cur_cred.method = SSH_AUTH_PAGEANT;
1270     break;
1271    
1272     case SSH_AUTH_PASSWORD:
1273     pvar->auth_state.cur_cred.password = _strdup("");
1274     pvar->auth_state.cur_cred.method = SSH_AUTH_PASSWORD;
1275     break;
1276    
1277     case SSH_AUTH_TIS:
1278     default:
1279     return;
1280     }
1281    
1282     pvar->auth_state.user =
1283     _strdup(pvar->session_settings.DefaultUserName);
1284     }
1285     }
1286    
1287     void AUTH_notify_end_error(PTInstVar pvar)
1288     {
1289     if ((pvar->auth_state.flags & AUTH_START_USER_AUTH_ON_ERROR_END) != 0) {
1290     start_user_auth(pvar);
1291     pvar->auth_state.flags &= ~AUTH_START_USER_AUTH_ON_ERROR_END;
1292     }
1293     }
1294    
1295     void AUTH_advance_to_next_cred(PTInstVar pvar)
1296     {
1297     pvar->auth_state.failed_method = pvar->auth_state.cur_cred.method;
1298    
1299     if (pvar->auth_state.cur_cred.method == SSH_AUTH_NONE) {
1300     try_default_auth(pvar);
1301    
1302     if (pvar->auth_state.cur_cred.method == SSH_AUTH_NONE) {
1303     if (pvar->err_msg != NULL) {
1304     pvar->auth_state.flags |=
1305     AUTH_START_USER_AUTH_ON_ERROR_END;
1306     } else {
1307     // �������F���_�C�A���O���o�������� (2004.12.1 yutaka)
1308     // �R�}���h���C���w������������
1309     start_user_auth(pvar);
1310     }
1311     }
1312     } else {
1313     // �������F���_�C�A���O���o�������� (2004.12.1 yutaka)
1314     // �R�}���h���C���w������(/auth=xxxx)������
1315     start_user_auth(pvar);
1316     }
1317     }
1318    
1319     static void init_TIS_dlg(PTInstVar pvar, HWND dlg)
1320     {
1321     char uimsg[MAX_UIMSG];
1322    
1323     GetWindowText(dlg, uimsg, sizeof(uimsg));
1324     UTIL_get_lang_msg("DLG_TIS_TITLE", pvar, uimsg);
1325     SetWindowText(dlg, pvar->ts->UIMsg);
1326     GetDlgItemText(dlg, IDC_SSHAUTHBANNER, uimsg, sizeof(uimsg));
1327     UTIL_get_lang_msg("DLG_TIS_BANNER", pvar, uimsg);
1328     SetDlgItemText(dlg, IDC_SSHAUTHBANNER, pvar->ts->UIMsg);
1329     GetDlgItemText(dlg, IDOK, uimsg, sizeof(uimsg));
1330     UTIL_get_lang_msg("BTN_OK", pvar, uimsg);
1331     SetDlgItemText(dlg, IDOK, pvar->ts->UIMsg);
1332     GetDlgItemText(dlg, IDCANCEL, uimsg, sizeof(uimsg));
1333     UTIL_get_lang_msg("BTN_DISCONNECT", pvar, uimsg);
1334     SetDlgItemText(dlg, IDCANCEL, pvar->ts->UIMsg);
1335    
1336     init_auth_machine_banner(pvar, dlg);
1337 zmatsuo 7632 init_password_control(pvar, dlg, IDC_SSHPASSWORD, NULL);
1338 maya 3227
1339     if (pvar->auth_state.TIS_prompt != NULL) {
1340     if (strlen(pvar->auth_state.TIS_prompt) > 10000) {
1341     pvar->auth_state.TIS_prompt[10000] = 0;
1342     }
1343     SetDlgItemText(dlg, IDC_SSHAUTHBANNER2,
1344     pvar->auth_state.TIS_prompt);
1345     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1346     }
1347 doda 7477
1348     if (pvar->auth_state.echo) {
1349     SendMessage(GetDlgItem(dlg, IDC_SSHPASSWORD), EM_SETPASSWORDCHAR, 0, 0);
1350     }
1351 maya 3227 }
1352    
1353     static BOOL end_TIS_dlg(PTInstVar pvar, HWND dlg)
1354     {
1355 doda 6801 char *password =
1356 maya 3227 alloc_control_text(GetDlgItem(dlg, IDC_SSHPASSWORD));
1357    
1358     pvar->auth_state.cur_cred.method = SSH_AUTH_TIS;
1359     pvar->auth_state.cur_cred.password = password;
1360     pvar->auth_state.auth_dialog = NULL;
1361    
1362     // add
1363     if (SSHv2(pvar)) {
1364     pvar->keyboard_interactive_password_input = 1;
1365     handle_SSH2_userauth_inforeq(pvar);
1366     }
1367    
1368     SSH_notify_cred(pvar);
1369    
1370     EndDialog(dlg, 1);
1371     return TRUE;
1372     }
1373    
1374     static BOOL CALLBACK TIS_dlg_proc(HWND dlg, UINT msg, WPARAM wParam,
1375     LPARAM lParam)
1376     {
1377     PTInstVar pvar;
1378 zmatsuo 7560 // LOGFONT logfont;
1379     // HFONT font;
1380 maya 3227
1381     switch (msg) {
1382     case WM_INITDIALOG:
1383     pvar = (PTInstVar) lParam;
1384     pvar->auth_state.auth_dialog = dlg;
1385     SetWindowLong(dlg, DWL_USER, lParam);
1386    
1387     init_TIS_dlg(pvar, dlg);
1388 zmatsuo 7560 #if 0
1389 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
1390     GetObject(font, sizeof(LOGFONT), &logfont);
1391     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgTisFont, pvar)) {
1392     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1393     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER2, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1394     SendDlgItemMessage(dlg, IDC_SSHPASSWORD, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1395     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1396     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgTisFont, MAKELPARAM(TRUE,0));
1397     }
1398     else {
1399     DlgTisFont = NULL;
1400     }
1401 zmatsuo 7560 #endif
1402 maya 3227 // /auth=challenge ������ (2007.10.5 maya)
1403     if (pvar->ssh2_autologin == 1) {
1404     SetDlgItemText(dlg, IDC_SSHPASSWORD, pvar->ssh2_password);
1405     SendMessage(dlg, WM_COMMAND, IDOK, 0);
1406     }
1407    
1408 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
1409 maya 3227 return FALSE; /* because we set the focus */
1410    
1411     case WM_COMMAND:
1412     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
1413    
1414     switch (LOWORD(wParam)) {
1415     case IDOK:
1416 zmatsuo 7560 #if 0
1417 maya 3227 if (DlgTisFont != NULL) {
1418     DeleteObject(DlgTisFont);
1419     }
1420 zmatsuo 7560 #endif
1421 maya 3227 return end_TIS_dlg(pvar, dlg);
1422    
1423     case IDCANCEL: /* kill the connection */
1424     pvar->auth_state.auth_dialog = NULL;
1425 maya 5678 notify_closed_connection(pvar, "authentication cancelled");
1426 maya 3227 EndDialog(dlg, 0);
1427 zmatsuo 7560 #if 0
1428 maya 3227 if (DlgTisFont != NULL) {
1429     DeleteObject(DlgTisFont);
1430     }
1431 zmatsuo 7560 #endif
1432 maya 3227 return TRUE;
1433    
1434     default:
1435     return FALSE;
1436     }
1437    
1438     default:
1439     return FALSE;
1440     }
1441     }
1442    
1443     void AUTH_do_cred_dialog(PTInstVar pvar)
1444     {
1445     if (pvar->auth_state.auth_dialog == NULL) {
1446     HWND cur_active = GetActiveWindow();
1447     DLGPROC dlg_proc;
1448     LPCTSTR dialog_template;
1449    
1450     switch (pvar->auth_state.mode) {
1451     case TIS_AUTH_MODE:
1452     dialog_template = MAKEINTRESOURCE(IDD_SSHTISAUTH);
1453     dlg_proc = TIS_dlg_proc;
1454     break;
1455     case GENERIC_AUTH_MODE:
1456     default:
1457     dialog_template = MAKEINTRESOURCE(IDD_SSHAUTH);
1458     dlg_proc = auth_dlg_proc;
1459     }
1460    
1461     if (!DialogBoxParam(hInst, dialog_template,
1462     cur_active !=
1463     NULL ? cur_active : pvar->NotificationWindow,
1464     dlg_proc, (LPARAM) pvar) == -1) {
1465     UTIL_get_lang_msg("MSG_CREATEWINDOW_AUTH_ERROR", pvar,
1466     "Unable to display authentication dialog box.\n"
1467     "Connection terminated.");
1468 maya 5678 notify_fatal_error(pvar, pvar->ts->UIMsg, TRUE);
1469 maya 3227 }
1470     }
1471     }
1472    
1473     static void init_default_auth_dlg(PTInstVar pvar, HWND dlg)
1474     {
1475 zmatsuo 7632 int id;
1476     TCHAR user_name[UNLEN+1];
1477     DWORD len;
1478     TCHAR uimsg[MAX_UIMSG];
1479     TCHAR uimsg2[MAX_UIMSG];
1480     const static DlgTextInfo text_info[] = {
1481     { 0, "DLG_AUTHSETUP_TITLE" },
1482     { IDC_SSHAUTHBANNER, "DLG_AUTHSETUP_BANNER" },
1483     { IDC_SSH_NO_USERNAME, "DLG_AUTHSETUP_NO_USERNAME" },
1484     { IDC_SSH_DEFAULTUSERNAME, "DLG_AUTHSETUP_USERNAME" },
1485     { IDC_SSH_WINDOWS_USERNAME, "DLG_AUTHSETUP_SYSTEM_USERNAME" },
1486     { IDC_SSH_WINDOWS_USERNAME_TEXT, "DLG_AUTHSETUP_SYSTEM_USERNAME_TEXT" },
1487     { IDC_SSHUSEPASSWORD, "DLG_AUTHSETUP_METHOD_PASSWORD" },
1488     { IDC_SSHUSERSA, "DLG_AUTHSETUP_METHOD_RSA" },
1489     { IDC_SSHUSERHOSTS, "DLG_AUTHSETUP_METHOD_RHOST" },
1490     { IDC_SSHUSETIS, "DLG_AUTHSETUP_METHOD_CHALLENGE" },
1491     { IDC_SSHUSEPAGEANT, "DLG_AUTHSETUP_METHOD_PAGEANT" },
1492     { IDC_RSAFILENAMELABEL, "DLG_AUTH_PRIVATEKEY" },
1493     { IDC_LOCALUSERNAMELABEL, "DLG_AUTH_LOCALUSER" },
1494     { IDC_HOSTRSAFILENAMELABEL, "DLG_AUTH_HOST_PRIVATEKEY" },
1495     { IDC_CHECKAUTH, "DLG_AUTHSETUP_CHECKAUTH" },
1496     { IDOK, "BTN_OK" },
1497     { IDCANCEL, "BTN_CANCEL" },
1498     };
1499 maya 3227
1500 zmatsuo 7632 SetI18DlgStrs("TTSSH", dlg, text_info, _countof(text_info), pvar->ts->UILanguageFile);
1501 maya 3227
1502     switch (pvar->settings.DefaultAuthMethod) {
1503     case SSH_AUTH_RSA:
1504     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1505     IDC_SSHUSERSA);
1506     break;
1507     case SSH_AUTH_RHOSTS:
1508     case SSH_AUTH_RHOSTS_RSA:
1509     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1510     IDC_SSHUSERHOSTS);
1511     break;
1512     case SSH_AUTH_TIS:
1513     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1514     IDC_SSHUSETIS);
1515     break;
1516     case SSH_AUTH_PAGEANT:
1517     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1518     IDC_SSHUSEPAGEANT);
1519     break;
1520     case SSH_AUTH_PASSWORD:
1521     default:
1522     CheckRadioButton(dlg, IDC_SSHUSEPASSWORD, MAX_AUTH_CONTROL,
1523     IDC_SSHUSEPASSWORD);
1524     }
1525    
1526     SetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->settings.DefaultUserName);
1527     SetDlgItemText(dlg, IDC_RSAFILENAME,
1528     pvar->settings.DefaultRSAPrivateKeyFile);
1529     SetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
1530     pvar->settings.DefaultRhostsHostPrivateKeyFile);
1531     SetDlgItemText(dlg, IDC_LOCALUSERNAME,
1532     pvar->settings.DefaultRhostsLocalUserName);
1533    
1534     if (pvar->settings.CheckAuthListFirst) {
1535     CheckDlgButton(dlg, IDC_CHECKAUTH, TRUE);
1536     }
1537 zmatsuo 7632
1538     if (pvar->session_settings.DefaultUserName[0] == 0) {
1539     // ���������u�����������v����������
1540     pvar->session_settings.DefaultUserType = 0;
1541     }
1542     id = pvar->settings.DefaultUserType == 1 ? IDC_SSH_DEFAULTUSERNAME :
1543     pvar->settings.DefaultUserType == 2 ? IDC_SSH_WINDOWS_USERNAME :
1544     IDC_SSH_NO_USERNAME;
1545     CheckRadioButton(dlg, IDC_SSH_NO_USERNAME, IDC_SSH_WINDOWS_USERNAME, id);
1546    
1547     len = _countof(user_name);
1548     GetUserName(user_name, &len);
1549    
1550     GetDlgItemText(dlg, IDC_SSH_WINDOWS_USERNAME_TEXT, uimsg, _countof(uimsg));
1551     _stprintf_s(uimsg2, _countof(uimsg2), uimsg, user_name);
1552     SetDlgItemText(dlg, IDC_SSH_WINDOWS_USERNAME_TEXT, uimsg2);
1553 maya 3227 }
1554    
1555     static BOOL end_default_auth_dlg(PTInstVar pvar, HWND dlg)
1556     {
1557     if (IsDlgButtonChecked(dlg, IDC_SSHUSERSA)) {
1558     pvar->settings.DefaultAuthMethod = SSH_AUTH_RSA;
1559     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSERHOSTS)) {
1560     if (GetWindowTextLength(GetDlgItem(dlg, IDC_HOSTRSAFILENAME)) > 0) {
1561     pvar->settings.DefaultAuthMethod = SSH_AUTH_RHOSTS_RSA;
1562     } else {
1563     pvar->settings.DefaultAuthMethod = SSH_AUTH_RHOSTS;
1564     }
1565     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSETIS)) {
1566     pvar->settings.DefaultAuthMethod = SSH_AUTH_TIS;
1567     } else if (IsDlgButtonChecked(dlg, IDC_SSHUSEPAGEANT)) {
1568     pvar->settings.DefaultAuthMethod = SSH_AUTH_PAGEANT;
1569     } else {
1570     pvar->settings.DefaultAuthMethod = SSH_AUTH_PASSWORD;
1571     }
1572    
1573     GetDlgItemText(dlg, IDC_SSHUSERNAME, pvar->settings.DefaultUserName,
1574     sizeof(pvar->settings.DefaultUserName));
1575     GetDlgItemText(dlg, IDC_RSAFILENAME,
1576     pvar->settings.DefaultRSAPrivateKeyFile,
1577     sizeof(pvar->settings.DefaultRSAPrivateKeyFile));
1578     GetDlgItemText(dlg, IDC_HOSTRSAFILENAME,
1579     pvar->settings.DefaultRhostsHostPrivateKeyFile,
1580     sizeof(pvar->settings.DefaultRhostsHostPrivateKeyFile));
1581     GetDlgItemText(dlg, IDC_LOCALUSERNAME,
1582     pvar->settings.DefaultRhostsLocalUserName,
1583     sizeof(pvar->settings.DefaultRhostsLocalUserName));
1584 zmatsuo 7632 pvar->settings.DefaultUserType =
1585     IsDlgButtonChecked(dlg, IDC_SSH_DEFAULTUSERNAME) ? 1 :
1586     IsDlgButtonChecked(dlg, IDC_SSH_WINDOWS_USERNAME) ? 2 : 0;
1587 maya 3227
1588     if (IsDlgButtonChecked(dlg, IDC_CHECKAUTH)) {
1589     pvar->settings.CheckAuthListFirst = TRUE;
1590     }
1591     else {
1592     pvar->settings.CheckAuthListFirst = FALSE;
1593     }
1594    
1595     EndDialog(dlg, 1);
1596     return TRUE;
1597     }
1598    
1599     static BOOL CALLBACK default_auth_dlg_proc(HWND dlg, UINT msg,
1600     WPARAM wParam, LPARAM lParam)
1601     {
1602     PTInstVar pvar;
1603 zmatsuo 7560 // LOGFONT logfont;
1604     // HFONT font;
1605 maya 3227
1606     switch (msg) {
1607     case WM_INITDIALOG:
1608     pvar = (PTInstVar) lParam;
1609     SetWindowLong(dlg, DWL_USER, lParam);
1610    
1611     init_default_auth_dlg(pvar, dlg);
1612 zmatsuo 7560 #if 0
1613 maya 3227 font = (HFONT)SendMessage(dlg, WM_GETFONT, 0, 0);
1614     GetObject(font, sizeof(LOGFONT), &logfont);
1615     if (UTIL_get_lang_font("DLG_TAHOMA_FONT", dlg, &logfont, &DlgAuthSetupFont, pvar)) {
1616     SendDlgItemMessage(dlg, IDC_SSHAUTHBANNER, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1617     SendDlgItemMessage(dlg, IDC_SSHUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1618     SendDlgItemMessage(dlg, IDC_SSHUSERNAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1619     SendDlgItemMessage(dlg, IDC_SSHUSEPASSWORD, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1620     SendDlgItemMessage(dlg, IDC_SSHUSERSA, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1621     SendDlgItemMessage(dlg, IDC_CHOOSERSAFILE, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1622     SendDlgItemMessage(dlg, IDC_RSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1623     SendDlgItemMessage(dlg, IDC_SSHUSERHOSTS, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1624     SendDlgItemMessage(dlg, IDC_LOCALUSERNAMELABEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1625     SendDlgItemMessage(dlg, IDC_LOCALUSERNAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1626     SendDlgItemMessage(dlg, IDC_CHOOSEHOSTRSAFILE, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1627     SendDlgItemMessage(dlg, IDC_HOSTRSAFILENAME, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1628     SendDlgItemMessage(dlg, IDC_SSHUSETIS, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1629     SendDlgItemMessage(dlg, IDC_SSHUSEPAGEANT, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1630     SendDlgItemMessage(dlg, IDC_CHECKAUTH, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1631     SendDlgItemMessage(dlg, IDOK, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1632     SendDlgItemMessage(dlg, IDCANCEL, WM_SETFONT, (WPARAM)DlgAuthSetupFont, MAKELPARAM(TRUE,0));
1633     }
1634     else {
1635     DlgAuthSetupFont = NULL;
1636     }
1637 zmatsuo 7560 #endif
1638 zmatsuo 7592 CenterWindow(dlg, GetParent(dlg));
1639 maya 3227 return TRUE; /* because we do not set the focus */
1640    
1641     case WM_COMMAND:
1642     pvar = (PTInstVar) GetWindowLong(dlg, DWL_USER);
1643    
1644     switch (LOWORD(wParam)) {
1645     case IDOK:
1646 zmatsuo 7560 #if 0
1647 maya 3227 if (DlgAuthSetupFont != NULL) {
1648     DeleteObject(DlgAuthSetupFont);
1649     }
1650 zmatsuo 7560 #endif
1651 maya 3227 return end_default_auth_dlg(pvar, dlg);
1652    
1653     case IDCANCEL:
1654     EndDialog(dlg, 0);
1655 zmatsuo 7560 #if 0
1656 maya 3227 if (DlgAuthSetupFont != NULL) {
1657     DeleteObject(DlgAuthSetupFont);
1658     }
1659 zmatsuo 7560 #endif
1660 maya 3227 return TRUE;
1661    
1662     case IDC_CHOOSERSAFILE:
1663     choose_RSA_key_file(dlg, pvar);
1664     return TRUE;
1665    
1666     case IDC_CHOOSEHOSTRSAFILE:
1667     choose_host_RSA_key_file(dlg, pvar);
1668     return TRUE;
1669    
1670     default:
1671     return FALSE;
1672     }
1673    
1674     default:
1675     return FALSE;
1676     }
1677     }
1678    
1679     void AUTH_init(PTInstVar pvar)
1680     {
1681     pvar->auth_state.failed_method = SSH_AUTH_NONE;
1682     pvar->auth_state.auth_dialog = NULL;
1683     pvar->auth_state.user = NULL;
1684     pvar->auth_state.flags = 0;
1685     pvar->auth_state.TIS_prompt = NULL;
1686 doda 7477 pvar->auth_state.echo = 0;
1687 maya 3227 pvar->auth_state.supported_types = 0;
1688     pvar->auth_state.cur_cred.method = SSH_AUTH_NONE;
1689     pvar->auth_state.cur_cred.password = NULL;
1690     pvar->auth_state.cur_cred.rhosts_client_user = NULL;
1691     pvar->auth_state.cur_cred.key_pair = NULL;
1692     AUTH_set_generic_mode(pvar);
1693     }
1694    
1695     void AUTH_set_generic_mode(PTInstVar pvar)
1696     {
1697     pvar->auth_state.mode = GENERIC_AUTH_MODE;
1698     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1699     }
1700    
1701 doda 7477 void AUTH_set_TIS_mode(PTInstVar pvar, char *prompt, int len, int echo)
1702 maya 3227 {
1703     if (pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1704     pvar->auth_state.mode = TIS_AUTH_MODE;
1705    
1706     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1707     pvar->auth_state.TIS_prompt = malloc(len + 1);
1708     memcpy(pvar->auth_state.TIS_prompt, prompt, len);
1709     pvar->auth_state.TIS_prompt[len] = 0;
1710 doda 7477 pvar->auth_state.echo = echo;
1711 maya 3227 } else {
1712     AUTH_set_generic_mode(pvar);
1713     }
1714     }
1715    
1716     void AUTH_do_default_cred_dialog(PTInstVar pvar)
1717     {
1718     HWND cur_active = GetActiveWindow();
1719    
1720     if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHAUTHSETUP),
1721     cur_active != NULL ? cur_active
1722     : pvar->NotificationWindow,
1723     default_auth_dlg_proc, (LPARAM) pvar) == -1) {
1724     UTIL_get_lang_msg("MSG_CREATEWINDOW_AUTHSETUP_ERROR", pvar,
1725     "Unable to display authentication setup dialog box.");
1726     notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1727     }
1728     }
1729    
1730     void AUTH_destroy_cur_cred(PTInstVar pvar)
1731     {
1732     destroy_malloced_string(&pvar->auth_state.cur_cred.password);
1733     destroy_malloced_string(&pvar->auth_state.cur_cred.rhosts_client_user);
1734     if (pvar->auth_state.cur_cred.key_pair != NULL) {
1735 maya 4307 key_free(pvar->auth_state.cur_cred.key_pair);
1736 maya 3227 pvar->auth_state.cur_cred.key_pair = NULL;
1737     }
1738     }
1739    
1740 maya 4307 static const char *get_auth_method_name(SSHAuthMethod auth)
1741 maya 3227 {
1742     switch (auth) {
1743     case SSH_AUTH_PASSWORD:
1744     return "password";
1745     case SSH_AUTH_RSA:
1746 maya 5550 return "publickey";
1747 maya 3227 case SSH_AUTH_PAGEANT:
1748 maya 5550 return "publickey";
1749 maya 3227 case SSH_AUTH_RHOSTS:
1750     return "rhosts";
1751     case SSH_AUTH_RHOSTS_RSA:
1752     return "rhosts with RSA";
1753     case SSH_AUTH_TIS:
1754     return "challenge/response (TIS)";
1755     default:
1756     return "unknown method";
1757     }
1758     }
1759    
1760 doda 6801 void AUTH_get_auth_info(PTInstVar pvar, char *dest, int len)
1761 maya 3227 {
1762 maya 4307 const char *method = "unknown";
1763 yutakapon 5545 char buf[256];
1764 maya 3227
1765     if (pvar->auth_state.user == NULL) {
1766     strncpy_s(dest, len, "None", _TRUNCATE);
1767     } else if (pvar->auth_state.cur_cred.method != SSH_AUTH_NONE) {
1768     if (SSHv1(pvar)) {
1769     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1770 maya 5550 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1771     pvar->auth_state.user,
1772 maya 3227 get_auth_method_name(pvar->auth_state.cur_cred.method));
1773    
1774 maya 5550 if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1775     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1776     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1777     "RSA");
1778     strncat_s(dest, len, buf, _TRUNCATE);
1779     }
1780     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
1781     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1782     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1783     "RSA");
1784     strncat_s(dest, len, buf, _TRUNCATE);
1785     }
1786 maya 3227 } else {
1787     // SSH2:�F�����\�b�h������ (2004.12.23 yutaka)
1788     // keyboard-interactive���\�b�h������ (2005.3.12 yutaka)
1789     if (pvar->auth_state.cur_cred.method == SSH_AUTH_PASSWORD ||
1790     pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1791     // keyboard-interactive���\�b�h������ (2005.1.24 yutaka)
1792     if (pvar->auth_state.cur_cred.method == SSH_AUTH_TIS) {
1793     method = "keyboard-interactive";
1794     } else {
1795     method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1796     }
1797     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1798 maya 5550 _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1799     pvar->auth_state.user, method);
1800     }
1801     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_RSA) {
1802     method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1803     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1804     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1805     pvar->auth_state.user,
1806     get_auth_method_name(pvar->auth_state.cur_cred.method));
1807 maya 3227
1808 maya 5550 UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO2", pvar, " with %s key");
1809     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1810     ssh_key_type(pvar->auth_state.cur_cred.key_pair->type));
1811     strncat_s(dest, len, buf, _TRUNCATE);
1812     }
1813     else if (pvar->auth_state.cur_cred.method == SSH_AUTH_PAGEANT) {
1814     int key_len = get_uint32_MSBfirst(pvar->pageant_curkey + 4);
1815     char *s = (char *)malloc(key_len+1);
1816 yutakapon 5545
1817 maya 5550 method = get_auth_method_name(pvar->auth_state.cur_cred.method);
1818     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1819     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg,
1820     pvar->auth_state.user,
1821     get_auth_method_name(pvar->auth_state.cur_cred.method));
1822 maya 3227
1823 maya 5550 memcpy(s, pvar->pageant_curkey+4+4, key_len);
1824     s[key_len] = '\0';
1825     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO3", pvar, " with %s key from Pageant");
1826     _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg,
1827     ssh_key_type(get_keytype_from_name(s)));
1828     strncat_s(dest, len, buf, _TRUNCATE);
1829    
1830     free(s);
1831 maya 3227 }
1832     }
1833    
1834     } else {
1835     UTIL_get_lang_msg("DLG_ABOUT_AUTH_INFO", pvar, "User '%s', using %s");
1836     _snprintf_s(dest, len, _TRUNCATE, pvar->ts->UIMsg, pvar->auth_state.user,
1837     get_auth_method_name(pvar->auth_state.failed_method));
1838     }
1839    
1840     dest[len - 1] = 0;
1841     }
1842    
1843     void AUTH_notify_disconnecting(PTInstVar pvar)
1844     {
1845     if (pvar->auth_state.auth_dialog != NULL) {
1846     PostMessage(pvar->auth_state.auth_dialog, WM_COMMAND, IDCANCEL, 0);
1847     /* the main window might not go away if it's not enabled. (see vtwin.cpp) */
1848     EnableWindow(pvar->NotificationWindow, TRUE);
1849     }
1850     }
1851    
1852     void AUTH_end(PTInstVar pvar)
1853     {
1854     destroy_malloced_string(&pvar->auth_state.user);
1855     destroy_malloced_string(&pvar->auth_state.TIS_prompt);
1856    
1857     AUTH_destroy_cur_cred(pvar);
1858     }

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