Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/ttssh2/ttxssh/ttxssh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8093 - (show annotations) (download) (as text)
Sun Sep 8 10:16:41 2019 UTC (4 years, 7 months ago) by yutakapon
File MIME type: text/x-chdr
File size: 11325 byte(s)
・known_hostsダイアログおよびユーザ認証ダイアログの表示中に、SSHサーバ側からネットワーク切断された場合、ダイアログを自動で閉じるようにした。
・known_hostsダイアログの表示中にSSHサーバ側からネットワーク切断されると、アプリがクラッシュすることがある問題を修正した。
・SSH1: /nosecuritywarningオプションが機能していなかった問題を修正した。
・/nosecuritywarningオプションに関する注意事項を追記した。

branches/ttssh_improvedからリビジョン8036をマージ:
SSHサーバと認証中にネットワーク切断された場合、認証ダイアログが残ったままとならないようにした。

........
branches/ttssh_improvedからリビジョン8044をマージ:
r8036でダイアログの処理追加漏れ。
SSHサーバと認証中にネットワーク切断された場合、認証ダイアログが残ったままとならないようにした。

........

branches/ttssh_improvedからリビジョン8063をマージ:
known_hostsダイアログが表示されている状態で、サーバから切断を行うと、
TTXCloseTCPが呼び出され、TTSSHのリソースが解放されてしまう。
SSHハンドラの延長でknown_hostsダイアログを出して止まっているため、
ダイアログを閉じて、処理再開すると、SSHの内部情報が壊れる。
その状態で再度SSH接続しようとすると100%アプリが落ちる。

上記問題に対して、まずは SSH1 に処置した。

........

branches/ttssh_improvedからリビジョン8081をマージ:
known_hostsダイアログが表示されている状態で、サーバから切断を行うと、
TTXCloseTCPが呼び出され、TTSSHのリソースが解放されてしまう。
SSHハンドラの延長でknown_hostsダイアログを出して止まっているため、
ダイアログを閉じて、処理再開すると、SSHの内部情報が壊れる。
その状態で再度SSH接続しようとすると100%アプリが落ちる。

上記問題に対して、SSH2 に対応した。

パケット受信時のSSHハンドラのコンテキストで known_hosts ダイアログを表示
させていたが、TTXCloseTCPの非同期呼び出しに対処できないため、
TTSSH1で使われていたknown_hosts ダイアログの非同期呼び出しに
実装を変更した。
これにより、比較的大きくロジックの修正を行っている。

........

branches/ttssh_improvedからリビジョン8085をマージ:
前回のオプション指定(/nosecuritywarning)が残らないように初期化する。
........


1 /*
2 * Copyright (c) 1998-2001, Robert O'Callahan
3 * (C) 2004-2019 TeraTerm Project
4 * 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
30 /*
31 This code is copyright (C) 1998-1999 Robert O'Callahan.
32 See LICENSE.TXT for the license.
33 */
34
35 #ifndef __TTXSSH_H
36 #define __TTXSSH_H
37
38 #pragma warning(3 : 4035)
39
40 /* VS2015(VC14.0)�����AWSASocketA(), inet_ntoa() ������API��deprecated��������
41 * �x�������������A�x�����}�~�����B�����������u���������AVS2005(VC8.0)���r���h
42 * �����������������A�x�����}�~���������������B
43 */
44 #if _MSC_VER >= 1800 // VSC2013(VC12.0) or later
45 #ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
46 #define _WINSOCK_DEPRECATED_NO_WARNINGS
47 #endif
48 #endif
49
50 #include <winsock2.h>
51 #include <ws2tcpip.h>
52 #include <wspiapi.h>
53 /* actual body of in6addr_any and in6addr_loopback is disappeared?? */
54 #undef IN6_IS_ADDR_LOOPBACK
55 #define IN6_IS_ADDR_LOOPBACK(a) \
56 ((*(unsigned int *)(&(a)->s6_addr[0]) == 0) && \
57 (*(unsigned int *)(&(a)->s6_addr[4]) == 0) && \
58 (*(unsigned int *)(&(a)->s6_addr[8]) == 0) && \
59 (*(unsigned int *)(&(a)->s6_addr[12]) == ntohl(1)))
60 /* work around for MS Platform SDK Oct 2000 */
61 #include <malloc.h> /* prevent of conflict stdlib.h */
62 #include <stdlib.h>
63 #include <stdarg.h>
64 #include <crtdbg.h>
65
66 #include "i18n.h"
67 #include "ttlib.h"
68
69 typedef struct _TInstVar *PTInstVar;
70
71 #include "ttxssh-version.h"
72 #include "util.h"
73 #include "pkt.h"
74 #include "ssh.h"
75 #include "auth.h"
76 #include "crypt.h"
77 #include "hosts.h"
78 #include "fwd.h"
79
80 #include <openssl/dh.h>
81 #include <openssl/ec.h>
82 #include <openssl/evp.h>
83 #include "buffer.h"
84
85 /* tttypes.h �����`���������� EM �}�N���� openssl/rsa.h (OpenSSL 0.9.8)�������v���g�^�C�v������
86 * �������������d�����������������A�r���h�G���[�������B���L3�w�b�_��include���u�����L�����������B
87 * (2005.7.9 yutaka)
88 */
89 #include "teraterm.h"
90 #include "tttypes.h"
91 #include "ttplugin.h"
92
93 #if defined(_MSC_VER) && !defined(_Printf_format_string_)
94 // ���`�������������������������������������`��������
95 #define _Printf_format_string_
96 #endif
97
98 HANDLE hInst; /* Instance handle of TTXSSH.DLL */
99
100 #define ID_SSHSCPMENU 52110
101 #define ID_SSHSETUPMENU 52310
102 #define ID_SSHAUTHSETUPMENU 52320
103 #define ID_SSHFWDSETUPMENU 52330
104 #define ID_SSHKEYGENMENU 52340
105 #define ID_ABOUTMENU 52910
106
107 #define ID_SSHAUTH 62501
108 #define ID_SSHUNKNOWNHOST 62502
109 #define ID_SSHDIFFERENTKEY 62503
110 #define ID_SSHASYNCMESSAGEBOX 62504
111 #define ID_SSHDIFFERENT_TYPE_KEY 62505
112
113 #define OPTION_NONE 0
114 #define OPTION_CLEAR 1
115 #define OPTION_REPLACE 2
116
117 /*
118 * DisablePopupMessage �p���r�b�g���`
119 */
120 #define POPUP_MSG_default 0
121 #define POPUP_MSG_FWD_received_data (1 << 0)
122
123
124 /*
125 * Host key rotation
126 */
127 #define SSH_UPDATE_HOSTKEYS_NO 0
128 #define SSH_UPDATE_HOSTKEYS_YES 1
129 #define SSH_UPDATE_HOSTKEYS_ASK 2
130 #define SSH_UPDATE_HOSTKEYS_MAX 3
131
132 /*
133 * Server compatibility flag
134 */
135 #define SSH_BUG_DHGEX_LARGE 0x00000001
136
137
138 /*
139 These are the fields that WOULD go in Tera Term's 'ts' structure, if
140 we could put them there.
141 */
142 typedef struct _TS_SSH {
143 BOOL Enabled;
144 int CompressionLevel; /* 0 = NONE, else 1-9 */
145
146 int DefaultUserType; /* 0/1/2 = no input/DefaultUserName/Windows logon user */
147 char DefaultUserName[256];
148
149 /* this next option is a string of digits. Each digit represents a
150 cipher. The first digit is the most preferred cipher, and so on.
151 The digit SSH_CIPHER_NONE signifies that any ciphers after it are
152 disabled. */
153 char CipherOrder[SSH_CIPHER_MAX+2];
154
155 char KnownHostsFiles[2048];
156 int DefaultAuthMethod;
157 char DefaultRhostsLocalUserName[256];
158 char DefaultRhostsHostPrivateKeyFile[1024];
159 char DefaultRSAPrivateKeyFile[1024];
160
161 char DefaultForwarding[4096];
162 BOOL TryDefaultAuth;
163
164 int LogLevel; /* 0 = NONE, 100 = Verbose */
165 int WriteBufferSize;
166
167 int ssh_protocol_version; // SSH version (2004.10.11 yutaka)
168 int ssh_heartbeat_overtime; // SSH heartbeat(keepalive) (2004.12.11 yutaka)
169 // whether password will permanently store on heap memory (2006.8.5 yutaka)
170 int remember_password;
171
172 // try auth with "none" method for disable unsupported on dialog (2007.9.24 maya)
173 BOOL CheckAuthListFirst;
174
175 // Enable connection to the server that has RSA key length less than 768 bit (2008.9.11 maya)
176 BOOL EnableRsaShortKeyServer;
177
178 // Enable Agent forwarding
179 BOOL ForwardAgent;
180
181 // Confirm Agent forwarding
182 BOOL ForwardAgentConfirm;
183
184 // Confirm Agent forwarding
185 BOOL ForwardAgentNotify;
186
187 // KEX order(derived from teraterm.ini)
188 char KexOrder[KEX_DH_MAX+1];
189 char HostKeyOrder[KEY_MAX+1];
190 char MacOrder[HMAC_MAX+1];
191 char CompOrder[COMP_MAX+1];
192
193 BOOL VerifyHostKeyDNS;
194
195 int IconID;
196
197 int DisablePopupMessage;
198
199 char X11Display[128];
200
201 int UpdateHostkeys;
202
203 int GexMinimalGroupSize;
204
205 int AuthBanner;
206 } TS_SSH;
207
208 typedef struct _TInstVar {
209 PTTSet ts;
210 PComVar cv;
211
212 /* shared memory for settings across instances. Basically it's
213 a cache for the INI file.*/
214 TS_SSH *ts_SSH;
215
216 int fatal_error;
217 int showing_err;
218 char *err_msg;
219
220 Tconnect Pconnect;
221 Trecv Precv;
222 Tsend Psend;
223 TWSAAsyncSelect PWSAAsyncSelect;
224 TWSAGetLastError PWSAGetLastError;
225
226 PReadIniFile ReadIniFile;
227 PWriteIniFile WriteIniFile;
228 PParseParam ParseParam;
229
230 HMENU FileMenu;
231
232 SOCKET socket;
233 HWND NotificationWindow;
234 unsigned int notification_msg;
235 long notification_events;
236 HICON OldSmallIcon;
237 HICON OldLargeIcon;
238
239 BOOL hostdlg_activated;
240 BOOL hostdlg_Enabled;
241
242 int protocol_major;
243 int protocol_minor;
244
245 PKTState pkt_state;
246 SSHState ssh_state;
247 AUTHState auth_state;
248 CRYPTState crypt_state;
249 HOSTSState hosts_state;
250 FWDState fwd_state;
251
252 /* The settings applied to the current session. The user may change
253 the settings but usually we don't want that to affect the session
254 in progress (race conditions). So user setup changes usually
255 modify the 'settings' field below. */
256 TS_SSH session_settings;
257
258 /* our copy of the global settings. This is synced up with the shared
259 memory only when we do a ReadIniFile or WriteIniFile
260 (i.e. the user loads or saves setup) */
261 TS_SSH settings;
262
263 // SSH2
264 DH *kexdh;
265 char server_version_string[128];
266 char client_version_string[128];
267 buffer_t *my_kex;
268 buffer_t *peer_kex;
269 kex_algorithm kex_type; // KEX algorithm
270 ssh_keytype hostkey_type;
271 SSH2Cipher *ciphers[MODE_MAX];
272 SSH2Mac *macs[MODE_MAX];
273 compression_type ctos_compression;
274 compression_type stoc_compression;
275 int we_need;
276 int key_done;
277 int rekeying;
278 char *session_id;
279 int session_id_len;
280 SSHKeys ssh2_keys[MODE_MAX];
281 EVP_CIPHER_CTX evpcip[MODE_MAX];
282 int userauth_success;
283 int shell_id;
284 /*int remote_id;*/
285 int session_nego_status;
286 /*
287 unsigned int local_window;
288 unsigned int local_window_max;
289 unsigned int local_consumed;
290 unsigned int local_maxpacket;
291 unsigned int remote_window;
292 unsigned int remote_maxpacket;
293 */
294 int client_key_bits;
295 int server_key_bits;
296 int kexgex_min;
297 int kexgex_bits;
298 int kexgex_max;
299 int ssh2_autologin;
300 int ask4passwd;
301 SSHAuthMethod ssh2_authmethod;
302 char ssh2_username[MAX_PATH];
303 char ssh2_password[MAX_PATH];
304 char ssh2_keyfile[MAX_PATH];
305 time_t ssh_heartbeat_tick;
306 HANDLE ssh_heartbeat_thread;
307 int keyboard_interactive_password_input;
308 int userauth_retry_count;
309 buffer_t *decomp_buffer;
310 buffer_t *authbanner_buffer;
311 char *ssh2_authlist;
312 BOOL tryed_ssh2_authlist;
313 HWND ssh_hearbeat_dialog;
314
315 /* Pageant �������M�p */
316 unsigned char *pageant_key;
317 unsigned char *pageant_curkey;
318 int pageant_keylistlen;
319 int pageant_keycount;
320 int pageant_keycurrent;
321 BOOL pageant_keyfinal;// SSH2 PK_OK ������������ TRUE ������
322
323 // agent forward
324 BOOL agentfwd_enable;
325
326 BOOL origDisableTCPEchoCR;
327
328 BOOL nocheck_known_hosts;
329
330 EC_KEY *ecdh_client_key;
331
332 int dns_key_check;
333
334 unsigned int server_compat_flag;
335
336 void *hostkey_ctx;
337
338 BOOL use_subsystem;
339 char subsystem_name[256];
340
341 BOOL nosession;
342
343 // dialog resource
344 HFONT hFontFixed; // hosts.c�����_�C�A���O�p
345
346 bottom_half_known_hosts_t contents_after_known_hosts;
347
348 } TInstVar;
349
350 // �o�[�W���������������������X�������B ��: TTSSH_2-81_TS_data
351 #define TTSSH_FILEMAPNAME "TTSSH_" TTSSH_VERSION_STR("-") "_TS_data"
352
353 #define LOG_LEVEL_FATAL 5
354 #define LOG_LEVEL_ERROR 10
355 #define LOG_LEVEL_WARNING 30
356 #define LOG_LEVEL_NOTICE 50
357 #define LOG_LEVEL_INFO 80
358 #define LOG_LEVEL_VERBOSE 100
359 #define LOG_LEVEL_SSHDUMP 200
360
361 #define SSHv1(pvar) ((pvar)->protocol_major == 1)
362 #define SSHv2(pvar) ((pvar)->protocol_major == 2)
363
364 #define LogLevel(pvar, level) ((pvar)->settings.LogLevel >= (level))
365
366 void notify_established_secure_connection(PTInstVar pvar);
367 void notify_closed_connection(PTInstVar pvar, char *send_msg);
368 void notify_nonfatal_error(PTInstVar pvar, char *msg);
369 void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect);
370 void logputs(int level, char *msg);
371 #if defined(_MSC_VER)
372 void logprintf(int level, _Printf_format_string_ const char *fmt, ...);
373 void logprintf_hexdump(int level, const char *data, int len, _Printf_format_string_ const char *fmt, ...);
374 #elif defined(__GNUC__)
375 void logprintf(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
376 void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...) __attribute__ ((format (printf, 4, 5)));
377 #else
378 void logprintf(int level, const char *fmt, ...);
379 void logprintf_hexdump(int level, const char *data, int len, const char *fmt, ...);
380 #endif
381
382 void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename);
383 int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename);
384 int uuencode(unsigned char *src, int srclen, unsigned char *target, int targsize);
385
386 #endif

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