• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision29213 (tree)
Zeit2021-05-22 03:39:27
Autorstefankueng

Log Message

apply the TortoisePlink patch

Ändern Zusammenfassung

Diff

--- trunk/ext/TortoisePlink/be_all_s.c (revision 29212)
+++ trunk/ext/TortoisePlink/be_all_s.c (revision 29213)
@@ -14,7 +14,7 @@
1414 * have tiny little source modules containing nothing but
1515 * declarations of appname, for as long as I can...
1616 */
17-const char *const appname = "PuTTY";
17+const char *const appname = "TortoisePlink";
1818
1919 const int be_default_protocol = PROT_SSH;
2020
--- trunk/ext/TortoisePlink/console.c (revision 29212)
+++ trunk/ext/TortoisePlink/console.c (revision 29213)
@@ -9,41 +9,37 @@
99 #include "misc.h"
1010 #include "console.h"
1111
12+#include "LoginDialog.h"
13+
1214 const char hk_absentmsg_common_fmt[] =
1315 "The server's host key is not cached. You have no guarantee\n"
1416 "that the server is the computer you think it is.\n"
1517 "The server's %s key fingerprint is:\n"
16- "%s\n";
17-const char hk_absentmsg_interactive_intro[] =
18- "If you trust this host, enter \"y\" to add the key to\n"
18+ "%s\n"
19+ "%s\n\n"
20+ "If you trust this host, hit Yes to add the key to\n"
1921 "PuTTY's cache and carry on connecting.\n"
2022 "If you want to carry on connecting just once, without\n"
21- "adding the key to the cache, enter \"n\".\n"
22- "If you do not trust this host, press Return to abandon the\n"
23+ "adding the key to the cache, hit No.\n"
24+ "If you do not trust this host, hit Cancel to abandon the\n"
2325 "connection.\n";
24-const char hk_absentmsg_interactive_prompt[] =
25- "Store key in cache? (y/n, Return cancels connection, "
26- "i for more info) ";
2726
2827 const char hk_wrongmsg_common_fmt[] =
2928 "WARNING - POTENTIAL SECURITY BREACH!\n"
29+ "\n"
3030 "The server's host key does not match the one PuTTY has\n"
3131 "cached. This means that either the server administrator\n"
3232 "has changed the host key, or you have actually connected\n"
3333 "to another computer pretending to be the server.\n"
3434 "The new %s key fingerprint is:\n"
35- "%s\n";
36-const char hk_wrongmsg_interactive_intro[] =
35+ "%s\n"
36+ "%s\n\n"
3737 "If you were expecting this change and trust the new key,\n"
38- "enter \"y\" to update PuTTY's cache and continue connecting.\n"
38+ "hit Yes to update PuTTY's cache and continue connecting.\n"
3939 "If you want to carry on connecting but without updating\n"
40- "the cache, enter \"n\".\n"
41- "If you want to abandon the connection completely, press\n"
42- "Return to cancel. Pressing Return is the ONLY guaranteed\n"
43- "safe choice.\n";
44-const char hk_wrongmsg_interactive_prompt[] =
45- "Update cached key? (y/n, Return cancels connection, "
46- "i for more info) ";
40+ "the cache, hit No.\n"
41+ "If you want to abandon the connection completely, hit\n"
42+ "Cancel. Hitting Cancel is the ONLY guaranteed safe choice.\n";
4743
4844 const char weakcrypto_msg_common_fmt[] =
4945 "The first %s supported by the server is\n"
@@ -56,8 +52,8 @@
5652 "above the threshold, which we do not have stored:\n"
5753 "%s\n";
5854
59-const char console_continue_prompt[] = "Continue with connection? (y/n) ";
60-const char console_abandoned_msg[] = "Connection abandoned.\n";
55+//const char console_continue_prompt[] = "Continue with connection? (y/n) ";
56+//const char console_abandoned_msg[] = "Connection abandoned.\n";
6157
6258 bool console_batch_mode = false;
6359
@@ -65,42 +61,36 @@
6561 * Error message and/or fatal exit functions, all based on
6662 * console_print_error_msg which the platform front end provides.
6763 */
68-void console_print_error_msg_fmt_v(
69- const char *prefix, const char *fmt, va_list ap)
70-{
71- char *msg = dupvprintf(fmt, ap);
72- console_print_error_msg(prefix, msg);
73- sfree(msg);
74-}
75-
76-void console_print_error_msg_fmt(const char *prefix, const char *fmt, ...)
77-{
78- va_list ap;
79- va_start(ap, fmt);
80- console_print_error_msg_fmt_v(prefix, fmt, ap);
81- va_end(ap);
82-}
83-
8464 void modalfatalbox(const char *fmt, ...)
8565 {
86- va_list ap;
87- va_start(ap, fmt);
88- console_print_error_msg_fmt_v("FATAL ERROR", fmt, ap);
89- va_end(ap);
66+ va_list ap;
67+ char *stuff, morestuff[100];
68+ va_start(ap, fmt);
69+ stuff = dupvprintf(fmt, ap);
70+ va_end(ap);
71+ sprintf(morestuff, "%.70s Fatal Error", appname);
72+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
73+ sfree(stuff);
9074 cleanup_exit(1);
9175 }
9276
9377 void nonfatal(const char *fmt, ...)
9478 {
95- va_list ap;
96- va_start(ap, fmt);
97- console_print_error_msg_fmt_v("ERROR", fmt, ap);
98- va_end(ap);
79+ va_list ap;
80+ char *stuff, morestuff[100];
81+ va_start(ap, fmt);
82+ stuff = dupvprintf(fmt, ap);
83+ va_end(ap);
84+ sprintf(morestuff, "%.70s Error", appname);
85+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
86+ sfree(stuff);
9987 }
10088
10189 void console_connection_fatal(Seat *seat, const char *msg)
10290 {
103- console_print_error_msg("FATAL ERROR", msg);
91+ char morestuff[100];
92+ sprintf(morestuff, "%.70s Fatal Error", appname);
93+ MessageBox(GetParentHwnd(), msg, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
10494 cleanup_exit(1);
10595 }
10696
--- trunk/ext/TortoisePlink/version.h (revision 29212)
+++ trunk/ext/TortoisePlink/version.h (revision 29213)
@@ -1,6 +1,6 @@
1-/* Generated by automated build script */
1+
22 #define RELEASE 0.75
33 #define TEXTVER "Release 0.75"
4-#define SSHVER "-Release-0.75"
4+#define SSHVER "TortoisePlink-Release-0.75"
55 #define BINARY_VERSION 0,75,0,0
66 #define SOURCE_COMMIT "c72200ff8851b0d95574b8a8a88a2780a243c66c"
--- trunk/ext/TortoisePlink/windows/wincons.c (revision 29212)
+++ trunk/ext/TortoisePlink/windows/wincons.c (revision 29213)
@@ -11,6 +11,8 @@
1111 #include "ssh.h"
1212 #include "console.h"
1313
14+#include "LoginDialog.h"
15+
1416 void cleanup_exit(int code)
1517 {
1618 /*
@@ -23,15 +25,6 @@
2325 exit(code);
2426 }
2527
26-void console_print_error_msg(const char *prefix, const char *msg)
27-{
28- fputs(prefix, stderr);
29- fputs(": ", stderr);
30- fputs(msg, stderr);
31- fputc('\n', stderr);
32- fflush(stderr);
33-}
34-
3528 int console_verify_ssh_host_key(
3629 Seat *seat, const char *host, int port, const char *keytype,
3730 char *keystr, const char *keydisp, char **fingerprints,
@@ -38,11 +31,8 @@
3831 void (*callback)(void *ctx, int result), void *ctx)
3932 {
4033 int ret;
41- HANDLE hin;
42- DWORD savemode, i;
43- const char *common_fmt, *intro, *prompt;
4434
45- char line[32];
35+ static const char mbtitle[] = "%s Security Alert";
4636
4737 /*
4838 * Verify the key against the registry.
@@ -53,64 +43,40 @@
5343 return 1;
5444
5545 if (ret == 2) { /* key was different */
56- common_fmt = hk_wrongmsg_common_fmt;
57- intro = hk_wrongmsg_interactive_intro;
58- prompt = hk_wrongmsg_interactive_prompt;
59- } else { /* key was absent */
60- common_fmt = hk_absentmsg_common_fmt;
61- intro = hk_absentmsg_interactive_intro;
62- prompt = hk_absentmsg_interactive_prompt;
63- }
64-
65- FingerprintType fptype_default =
66- ssh2_pick_default_fingerprint(fingerprints);
67-
68- fprintf(stderr, common_fmt, keytype, fingerprints[fptype_default]);
69- if (console_batch_mode) {
70- fputs(console_abandoned_msg, stderr);
71- return 0;
72- }
73-
74- fputs(intro, stderr);
75- fflush(stderr);
76-
77- while (true) {
78- fputs(prompt, stderr);
79- fflush(stderr);
80-
81- line[0] = '\0'; /* fail safe if ReadFile returns no data */
82-
83- hin = GetStdHandle(STD_INPUT_HANDLE);
84- GetConsoleMode(hin, &savemode);
85- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
86- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
87- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
88- SetConsoleMode(hin, savemode);
89-
90- if (line[0] == 'i' || line[0] == 'I') {
91- fprintf(stderr, "Full public key:\n%s\n", keydisp);
92- if (fingerprints[SSH_FPTYPE_SHA256])
93- fprintf(stderr, "SHA256 key fingerprint:\n%s\n",
94- fingerprints[SSH_FPTYPE_SHA256]);
95- if (fingerprints[SSH_FPTYPE_MD5])
96- fprintf(stderr, "MD5 key fingerprint:\n%s\n",
97- fingerprints[SSH_FPTYPE_MD5]);
46+ int mbret;
47+ char *message, *title;
48+ message = dupprintf(hk_wrongmsg_common_fmt, keytype, fingerprints[SSH_FPTYPE_SHA256], fingerprints[SSH_FPTYPE_MD5]);
49+ title = dupprintf(mbtitle, appname);
50+ mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
51+ sfree(message);
52+ sfree(title);
53+ if (mbret == IDYES) {
54+ store_host_key(host, port, keytype, keystr);
55+ return 1;
56+ } else if (mbret == IDNO) {
57+ return 1;
9858 } else {
99- break;
59+ return 0;
10060 }
10161 }
102-
103- /* In case of misplaced reflexes from another program, also recognise 'q'
104- * as 'abandon connection rather than trust this key' */
105- if (line[0] != '\0' && line[0] != '\r' && line[0] != '\n' &&
106- line[0] != 'q' && line[0] != 'Q') {
107- if (line[0] == 'y' || line[0] == 'Y')
62+ if (ret == 1) { /* key was absent */
63+ int mbret;
64+ char *message, *title;
65+ message = dupprintf(hk_absentmsg_common_fmt, keytype, fingerprints[SSH_FPTYPE_SHA256], fingerprints[SSH_FPTYPE_MD5]);
66+ title = dupprintf(mbtitle, appname);
67+ mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
68+ sfree(message);
69+ sfree(title);
70+ if (mbret == IDYES) {
10871 store_host_key(host, port, keytype, keystr);
109- return 1;
110- } else {
111- fputs(console_abandoned_msg, stderr);
112- return 0;
72+ return 1;
73+ } else if (mbret == IDNO) {
74+ return 1;
75+ } else {
76+ return 0;
77+ }
11378 }
79+ return 0;
11480 }
11581
11682 int console_confirm_weak_crypto_primitive(
@@ -117,32 +83,19 @@
11783 Seat *seat, const char *algtype, const char *algname,
11884 void (*callback)(void *ctx, int result), void *ctx)
11985 {
120- HANDLE hin;
121- DWORD savemode, i;
86+ int mbret;
87+ char *message, *title;
88+ static const char mbtitle[] = "%s Security Alert";
12289
123- char line[32];
90+ message = dupprintf(weakcrypto_msg_common_fmt, algtype, algname);
91+ title = dupprintf(mbtitle, appname);
12492
125- fprintf(stderr, weakcrypto_msg_common_fmt, algtype, algname);
126-
127- if (console_batch_mode) {
128- fputs(console_abandoned_msg, stderr);
129- return 0;
130- }
131-
132- fputs(console_continue_prompt, stderr);
133- fflush(stderr);
134-
135- hin = GetStdHandle(STD_INPUT_HANDLE);
136- GetConsoleMode(hin, &savemode);
137- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
138- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
139- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
140- SetConsoleMode(hin, savemode);
141-
142- if (line[0] == 'y' || line[0] == 'Y') {
93+ mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2);
94+ sfree(message);
95+ sfree(title);
96+ if (mbret == IDYES) {
14397 return 1;
14498 } else {
145- fputs(console_abandoned_msg, stderr);
14699 return 0;
147100 }
148101 }
@@ -151,32 +104,20 @@
151104 Seat *seat, const char *algname, const char *betteralgs,
152105 void (*callback)(void *ctx, int result), void *ctx)
153106 {
154- HANDLE hin;
155- DWORD savemode, i;
107+ int mbret;
108+ char *message, *title;
109+ static const char mbtitle[] = "%s Security Alert";
156110
157- char line[32];
111+ message = dupprintf(weakhk_msg_common_fmt, algname, betteralgs);
112+ title = dupprintf(mbtitle, appname);
158113
159- fprintf(stderr, weakhk_msg_common_fmt, algname, betteralgs);
114+ mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
115+ sfree(message);
116+ sfree(title);
160117
161- if (console_batch_mode) {
162- fputs(console_abandoned_msg, stderr);
163- return 0;
164- }
165-
166- fputs(console_continue_prompt, stderr);
167- fflush(stderr);
168-
169- hin = GetStdHandle(STD_INPUT_HANDLE);
170- GetConsoleMode(hin, &savemode);
171- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
172- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
173- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
174- SetConsoleMode(hin, savemode);
175-
176- if (line[0] == 'y' || line[0] == 'Y') {
118+ if (mbret == IDYES) {
177119 return 1;
178120 } else {
179- fputs(console_abandoned_msg, stderr);
180121 return 0;
181122 }
182123 }
@@ -224,34 +165,28 @@
224165 "You can overwrite it with a new session log,\n"
225166 "append your session log to the end of it,\n"
226167 "or disable session logging for this session.\n"
227- "Enter \"y\" to wipe the file, \"n\" to append to it,\n"
228- "or just press Return to disable logging.\n"
229- "Wipe the log file? (y/n, Return cancels logging) ";
168+ "Hit Yes to wipe the file, hit No to append to it,\n"
169+ "or just press Cancel to disable logging.\n"
170+ "Wipe the log file?";
230171
231172 static const char msgtemplate_batch[] =
232173 "The session log file \"%.*s\" already exists.\n"
233174 "Logging will not be enabled.\n";
234175
235- char line[32];
176+ int mbret;
177+ char *message, *title;
178+ static const char mbtitle[] = "%s Session log";
236179
237- if (console_batch_mode) {
238- fprintf(stderr, msgtemplate_batch, FILENAME_MAX, filename->path);
239- fflush(stderr);
240- return 0;
241- }
242- fprintf(stderr, msgtemplate, FILENAME_MAX, filename->path);
243- fflush(stderr);
180+ message = dupprintf(msgtemplate, FILENAME_MAX, filename->path);
181+ title = dupprintf(mbtitle, appname);
244182
245- hin = GetStdHandle(STD_INPUT_HANDLE);
246- GetConsoleMode(hin, &savemode);
247- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
248- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
249- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
250- SetConsoleMode(hin, savemode);
183+ mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
184+ sfree(message);
185+ sfree(title);
251186
252- if (line[0] == 'y' || line[0] == 'Y')
187+ if (mbret == IDYES)
253188 return 2;
254- else if (line[0] == 'n' || line[0] == 'N')
189+ else if (mbret == IDNO)
255190 return 1;
256191 else
257192 return 0;
@@ -331,7 +266,6 @@
331266
332267 int console_get_userpass_input(prompts_t *p)
333268 {
334- HANDLE hin = INVALID_HANDLE_VALUE, hout = INVALID_HANDLE_VALUE;
335269 size_t curr_prompt;
336270
337271 /*
@@ -343,109 +277,16 @@
343277 prompt_set_result(p->prompts[i], "");
344278 }
345279
346- /*
347- * The prompts_t might contain a message to be displayed but no
348- * actual prompt. More usually, though, it will contain
349- * questions that the user needs to answer, in which case we
350- * need to ensure that we're able to get the answers.
351- */
352- if (p->n_prompts) {
353- if (console_batch_mode)
354- return 0;
355- hin = GetStdHandle(STD_INPUT_HANDLE);
356- if (hin == INVALID_HANDLE_VALUE) {
357- fprintf(stderr, "Cannot get standard input handle\n");
358- cleanup_exit(1);
359- }
360- }
280+ if (console_batch_mode)
281+ return 0;
361282
362- /*
363- * And if we have anything to print, we need standard output.
364- */
365- if ((p->name_reqd && p->name) || p->instruction || p->n_prompts) {
366- hout = GetStdHandle(STD_OUTPUT_HANDLE);
367- if (hout == INVALID_HANDLE_VALUE) {
368- fprintf(stderr, "Cannot get standard output handle\n");
369- cleanup_exit(1);
370- }
371- }
372-
373- /*
374- * Preamble.
375- */
376- /* We only print the `name' caption if we have to... */
377- if (p->name_reqd && p->name) {
378- ptrlen plname = ptrlen_from_asciz(p->name);
379- console_write(hout, plname);
380- if (!ptrlen_endswith(plname, PTRLEN_LITERAL("\n"), NULL))
381- console_write(hout, PTRLEN_LITERAL("\n"));
382- }
383- /* ...but we always print any `instruction'. */
384- if (p->instruction) {
385- ptrlen plinst = ptrlen_from_asciz(p->instruction);
386- console_write(hout, plinst);
387- if (!ptrlen_endswith(plinst, PTRLEN_LITERAL("\n"), NULL))
388- console_write(hout, PTRLEN_LITERAL("\n"));
389- }
390-
391283 for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
392-
393- DWORD savemode, newmode;
394284 prompt_t *pr = p->prompts[curr_prompt];
395-
396- GetConsoleMode(hin, &savemode);
397- newmode = savemode | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT;
398- if (!pr->echo)
399- newmode &= ~ENABLE_ECHO_INPUT;
400- else
401- newmode |= ENABLE_ECHO_INPUT;
402- SetConsoleMode(hin, newmode);
403-
404- console_write(hout, ptrlen_from_asciz(pr->prompt));
405-
406- bool failed = false;
407- while (1) {
408- /*
409- * Amount of data to try to read from the console in one
410- * go. This isn't completely arbitrary: a user reported
411- * that trying to read more than 31366 bytes at a time
412- * would fail with ERROR_NOT_ENOUGH_MEMORY on Windows 7,
413- * and Ruby's Win32 support module has evidence of a
414- * similar workaround:
415- *
416- * https://github.com/ruby/ruby/blob/0aa5195262d4193d3accf3e6b9bad236238b816b/win32/win32.c#L6842
417- *
418- * To keep things simple, I stick with a nice round power
419- * of 2 rather than trying to go to the very limit of that
420- * bug. (We're typically reading user passphrases and the
421- * like here, so even this much is overkill really.)
422- */
423- DWORD toread = 16384;
424-
425- size_t prev_result_len = pr->result->len;
426- void *ptr = strbuf_append(pr->result, toread);
427-
428- DWORD ret = 0;
429- if (!ReadFile(hin, ptr, toread, &ret, NULL) || ret == 0) {
430- failed = true;
431- break;
432- }
433-
434- strbuf_shrink_to(pr->result, prev_result_len + ret);
435- if (strbuf_chomp(pr->result, '\n')) {
436- strbuf_chomp(pr->result, '\r');
437- break;
438- }
439- }
440-
441- SetConsoleMode(hin, savemode);
442-
443- if (!pr->echo)
444- console_write(hout, PTRLEN_LITERAL("\r\n"));
445-
446- if (failed) {
447- return 0; /* failure due to read error */
448- }
285+ char result[MAX_LENGTH_PASSWORD] = { 0 };
286+ if (!DoLoginDialog(result, sizeof(result), pr->prompt))
287+ return 0;
288+ prompt_set_result(pr, result);
289+ SecureZeroMemory(&result, sizeof(result));
449290 }
450291
451292 return 1; /* success */
--- trunk/ext/TortoisePlink/windows/winplink.c (revision 29212)
+++ trunk/ext/TortoisePlink/windows/winplink.c (revision 29213)
@@ -12,12 +12,22 @@
1212 #include "tree234.h"
1313 #include "winsecur.h"
1414
15+extern HWND GetParentHwnd();
16+
17+#include <commctrl.h>
18+#pragma comment(lib, "comctl32.lib")
19+#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
20+
1521 void cmdline_error(const char *fmt, ...)
1622 {
1723 va_list ap;
24+ char *stuff, morestuff[100];
1825 va_start(ap, fmt);
19- console_print_error_msg_fmt_v("plink", fmt, ap);
26+ stuff = dupvprintf(fmt, ap);
2027 va_end(ap);
28+ sprintf(morestuff, "%.70s Command Line Error", appname);
29+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
30+ sfree(stuff);
2131 exit(1);
2232 }
2333
@@ -112,74 +122,79 @@
112122 */
113123 static void usage(void)
114124 {
115- printf("Plink: command-line connection utility\n");
116- printf("%s\n", ver);
117- printf("Usage: plink [options] [user@]host [command]\n");
118- printf(" (\"host\" can also be a PuTTY saved session name)\n");
119- printf("Options:\n");
120- printf(" -V print version information and exit\n");
121- printf(" -pgpfp print PGP key fingerprints and exit\n");
122- printf(" -v show verbose messages\n");
123- printf(" -load sessname Load settings from saved session\n");
124- printf(" -ssh -telnet -rlogin -raw -serial\n");
125- printf(" force use of a particular protocol\n");
126- printf(" -ssh-connection\n");
127- printf(" force use of the bare ssh-connection protocol\n");
128- printf(" -P port connect to specified port\n");
129- printf(" -l user connect with specified username\n");
130- printf(" -batch disable all interactive prompts\n");
131- printf(" -proxycmd command\n");
132- printf(" use 'command' as local proxy\n");
133- printf(" -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
134- printf(" Specify the serial configuration (serial only)\n");
135- printf("The following options only apply to SSH connections:\n");
136- printf(" -pw passw login with specified password\n");
137- printf(" -D [listen-IP:]listen-port\n");
138- printf(" Dynamic SOCKS-based port forwarding\n");
139- printf(" -L [listen-IP:]listen-port:host:port\n");
140- printf(" Forward local port to remote address\n");
141- printf(" -R [listen-IP:]listen-port:host:port\n");
142- printf(" Forward remote port to local address\n");
143- printf(" -X -x enable / disable X11 forwarding\n");
144- printf(" -A -a enable / disable agent forwarding\n");
145- printf(" -t -T enable / disable pty allocation\n");
146- printf(" -1 -2 force use of particular SSH protocol version\n");
147- printf(" -4 -6 force use of IPv4 or IPv6\n");
148- printf(" -C enable compression\n");
149- printf(" -i key private key file for user authentication\n");
150- printf(" -noagent disable use of Pageant\n");
151- printf(" -agent enable use of Pageant\n");
152- printf(" -noshare disable use of connection sharing\n");
153- printf(" -share enable use of connection sharing\n");
154- printf(" -hostkey keyid\n");
155- printf(" manually specify a host key (may be repeated)\n");
156- printf(" -sanitise-stderr, -sanitise-stdout, "
157- "-no-sanitise-stderr, -no-sanitise-stdout\n");
158- printf(" do/don't strip control chars from standard "
159- "output/error\n");
160- printf(" -no-antispoof omit anti-spoofing prompt after "
161- "authentication\n");
162- printf(" -m file read remote command(s) from file\n");
163- printf(" -s remote command is an SSH subsystem (SSH-2 only)\n");
164- printf(" -N don't start a shell/command (SSH-2 only)\n");
165- printf(" -nc host:port\n");
166- printf(" open tunnel in place of session (SSH-2 only)\n");
167- printf(" -sshlog file\n");
168- printf(" -sshrawlog file\n");
169- printf(" log protocol details to a file\n");
170- printf(" -logoverwrite\n");
171- printf(" -logappend\n");
172- printf(" control what happens when a log file already exists\n");
173- printf(" -shareexists\n");
174- printf(" test whether a connection-sharing upstream exists\n");
125+ char buf[10000];
126+ int j = 0;
127+ j += sprintf(buf + j, "TortoisePlink: command-line connection utility (based on PuTTY Plink)\n");
128+ j += sprintf(buf + j, "%s\n", ver);
129+ j += sprintf(buf + j, "Usage: tortoiseplink [options] [user@]host [command]\n");
130+ j += sprintf(buf + j, " (\"host\" can also be a PuTTY saved session name)\n");
131+ j += sprintf(buf + j, "Options:\n");
132+ j += sprintf(buf + j, " -V print version information and exit\n");
133+ j += sprintf(buf + j, " -pgpfp print PGP key fingerprints and exit\n");
134+ j += sprintf(buf + j, " -v show verbose messages\n");
135+ j += sprintf(buf + j, " -load sessname Load settings from saved session\n");
136+ j += sprintf(buf + j, " -ssh -telnet -rlogin -raw -serial\n");
137+ j += sprintf(buf + j, " force use of a particular protocol\n");
138+ j += sprintf(buf + j, " -ssh-connection\n");
139+ j += sprintf(buf + j, " force use of the bare ssh-connection protocol\n");
140+ j += sprintf(buf + j, " -P port connect to specified port\n");
141+ j += sprintf(buf + j, " -l user connect with specified username\n");
142+ j += sprintf(buf + j, " -batch disable all interactive prompts (ignored)\n");
143+ j += sprintf(buf + j, " -proxycmd command\n");
144+ j += sprintf(buf + j, " use 'command' as local proxy\n");
145+ j += sprintf(buf + j, " -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
146+ j += sprintf(buf + j, " Specify the serial configuration (serial only)\n");
147+ j += sprintf(buf + j, "The following options only apply to SSH connections:\n");
148+ j += sprintf(buf + j, " -pw passw login with specified password\n");
149+ j += sprintf(buf + j, " -D [listen-IP:]listen-port\n");
150+ j += sprintf(buf + j, " Dynamic SOCKS-based port forwarding\n");
151+ j += sprintf(buf + j, " -L [listen-IP:]listen-port:host:port\n");
152+ j += sprintf(buf + j, " Forward local port to remote address\n");
153+ j += sprintf(buf + j, " -R [listen-IP:]listen-port:host:port\n");
154+ j += sprintf(buf + j, " Forward remote port to local address\n");
155+ j += sprintf(buf + j, " -X -x enable / disable X11 forwarding\n");
156+ j += sprintf(buf + j, " -A -a enable / disable agent forwarding\n");
157+ j += sprintf(buf + j, " -t -T enable / disable pty allocation\n");
158+ j += sprintf(buf + j, " -1 -2 force use of particular SSH protocol version\n");
159+ j += sprintf(buf + j, " -4 -6 force use of IPv4 or IPv6\n");
160+ j += sprintf(buf + j, " -C enable compression\n");
161+ j += sprintf(buf + j, " -i key private key file for user authentication\n");
162+ j += sprintf(buf + j, " -noagent disable use of Pageant\n");
163+ j += sprintf(buf + j, " -agent enable use of Pageant\n");
164+ j += sprintf(buf + j, " -noshare disable use of connection sharing\n");
165+ j += sprintf(buf + j, " -share enable use of connection sharing\n");
166+ j += sprintf(buf + j, " -hostkey keyid\n");
167+ j += sprintf(buf + j, " manually specify a host key (may be repeated)\n");
168+ j += sprintf(buf + j, " -sanitise-stderr, -sanitise-stdout,\n");
169+ j += sprintf(buf + j, " -no-sanitise-stderr, -no-sanitise-stdout\n");
170+ j += sprintf(buf + j, " do/don't strip control chars from standard\n");
171+ j += sprintf(buf + j, " output/error\n");
172+ j += sprintf(buf + j, " -no-antispoof omit anti-spoofing prompt after\n");
173+ j += sprintf(buf + j, " authentication\n");
174+ j += sprintf(buf + j, " -m file read remote command(s) from file\n");
175+ j += sprintf(buf + j, " -s remote command is an SSH subsystem (SSH-2 only)\n");
176+ j += sprintf(buf + j, " -N don't start a shell/command (SSH-2 only)\n");
177+ j += sprintf(buf + j, " -nc host:port\n");
178+ j += sprintf(buf + j, " open tunnel in place of session (SSH-2 only)\n");
179+ j += sprintf(buf + j, " -sshlog file\n");
180+ j += sprintf(buf + j, " -sshrawlog file\n");
181+ j += sprintf(buf + j, " log protocol details to a file\n");
182+ j += sprintf(buf + j, " -logoverwrite\n");
183+ j += sprintf(buf + j, " -logappend\n");
184+ j += sprintf(buf + j, " control what happens when a log file already exists\n");
185+ j += sprintf(buf + j, " -shareexists\n");
186+ j += sprintf(buf + j, " test whether a connection-sharing upstream exists\n");
187+ MessageBox(NULL, buf, "TortoisePlink", MB_ICONINFORMATION);
175188 exit(1);
176189 }
177190
178191 static void version(void)
179192 {
180- char *buildinfo_text = buildinfo("\n");
181- printf("plink: %s\n%s\n", ver, buildinfo_text);
193+ char buf[1000];
194+ char* buildinfo_text = buildinfo("\n");
195+ sprintf(buf, "TortoisePlink: %s\n%s\n", ver, buildinfo_text);
182196 sfree(buildinfo_text);
197+ MessageBox(NULL, buf, "TortoisePlink", MB_ICONINFORMATION);
183198 exit(0);
184199 }
185200
@@ -274,6 +289,7 @@
274289
275290 dll_hijacking_protection();
276291
292+ InitCommonControls();
277293 /*
278294 * Initialise port and protocol to sensible defaults. (These
279295 * will be overridden by more or less anything.)
@@ -286,24 +302,11 @@
286302 */
287303 conf = conf_new();
288304 do_defaults(NULL, conf);
289- settings_set_default_protocol(conf_get_int(conf, CONF_protocol));
290- settings_set_default_port(conf_get_int(conf, CONF_port));
305+ settings_set_default_protocol(PROT_SSH);
306+ settings_set_default_port(22);
291307 errors = false;
292- {
293- /*
294- * Override the default protocol if PLINK_PROTOCOL is set.
295- */
296- char *p = getenv("PLINK_PROTOCOL");
297- if (p) {
298- const struct BackendVtable *vt = backend_vt_from_name(p);
299- if (vt) {
300- settings_set_default_protocol(vt->protocol);
301- settings_set_default_port(vt->default_port);
302- conf_set_int(conf, CONF_protocol, vt->protocol);
303- conf_set_int(conf, CONF_port, vt->default_port);
304- }
305- }
306- }
308+ conf_set_bool(conf, CONF_agentfwd, FALSE);
309+ conf_set_bool(conf, CONF_x11_forward, FALSE);
307310 while (--argc) {
308311 char *p = *++argv;
309312 int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
@@ -310,7 +313,7 @@
310313 1, conf);
311314 if (ret == -2) {
312315 fprintf(stderr,
313- "plink: option \"%s\" requires an argument\n", p);
316+ "TortoisePlink: option \"%s\" requires an argument\n", p);
314317 errors = true;
315318 } else if (ret == 2) {
316319 --argc, ++argv;
@@ -317,7 +320,7 @@
317320 } else if (ret == 1) {
318321 continue;
319322 } else if (!strcmp(p, "-batch")) {
320- console_batch_mode = true;
323+ // ignore and do not print an error message
321324 } else if (!strcmp(p, "-s")) {
322325 /* Save status to write to conf later. */
323326 use_subsystem = true;
@@ -362,7 +365,7 @@
362365 strbuf_free(cmdbuf);
363366 break; /* done with cmdline */
364367 } else {
365- fprintf(stderr, "plink: unknown option \"%s\"\n", p);
368+ fprintf(stderr, "TortoisePlink: unknown option \"%s\"\n", p);
366369 errors = true;
367370 }
368371 }
@@ -400,7 +403,7 @@
400403
401404 if (vt->flags & BACKEND_NEEDS_TERMINAL) {
402405 fprintf(stderr,
403- "Plink doesn't support %s, which needs terminal emulation\n",
406+ "TortoisePlink doesn't support %s, which needs terminal emulation\n",
404407 vt->displayname);
405408 return 1;
406409 }
@@ -407,7 +410,7 @@
407410
408411 sk_init();
409412 if (p_WSAEventSelect == NULL) {
410- fprintf(stderr, "Plink requires WinSock 2\n");
413+ fprintf(stderr, "TortoisePlink requires WinSock 2\n");
411414 return 1;
412415 }
413416
--- trunk/ext/build/TortoisePlink.patch (revision 29212)
+++ trunk/ext/build/TortoisePlink.patch (revision 29213)
@@ -1,6 +1,6 @@
11 Index: be_all_s.c
22 ===================================================================
3---- be_all_s.c (revision 28953)
3+--- be_all_s.c (revision 29211)
44 +++ be_all_s.c (working copy)
55 @@ -14,7 +14,7 @@
66 * have tiny little source modules containing nothing but
@@ -9,113 +9,83 @@
99 -const char *const appname = "PuTTY";
1010 +const char *const appname = "TortoisePlink";
1111
12- #ifdef TELNET_DEFAULT
13- const int be_default_protocol = PROT_TELNET;
14-Index: cmdline.c
12+ const int be_default_protocol = PROT_SSH;
13+
14+Index: console.c
1515 ===================================================================
16---- cmdline.c (revision 28953)
17-+++ cmdline.c (working copy)
18-@@ -583,13 +583,13 @@
19- fclose(fp);
20- conf_set_str(conf, CONF_remote_cmd, command->s);
21- conf_set_str(conf, CONF_remote_cmd2, "");
22-- conf_set_bool(conf, CONF_nopty, true); /* command => no terminal */
23-- strbuf_free(command);
24-+ conf_set_bool(conf, CONF_nopty, true); /* command => no terminal */
25-+ strbuf_free(command);
26- }
27-- if (!strcmp(p, "-P")) {
28-- RETURN(2);
29-- UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
30-- SAVEABLE(1); /* lower priority than -ssh,-telnet */
31-+ if ((!strcmp(p, "-P"))||(!strcmp(p, "-p"))) {
32-+ RETURN(2);
33-+ UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
34-+ SAVEABLE(1); /* lower priority than -ssh,-telnet */
35- conf_set_int(conf, CONF_port, atoi(value));
36- }
37- if (!strcmp(p, "-pw")) {
38-Index: version.h
39-===================================================================
40---- version.h (revision 28953)
41-+++ version.h (working copy)
42-@@ -1,6 +1,6 @@
43- /* Generated by automated build script */
44- #define RELEASE 0.74
45- #define TEXTVER "Release 0.74"
46--#define SSHVER "-Release-0.74"
47-+#define SSHVER "TortoisePlink-Release-0.74"
48- #define BINARY_VERSION 0,74,0,0
49- #define SOURCE_COMMIT "014d4fb151369f255b3debed7d15a154fd9036f5"
50-Index: windows/TPlink/LoginDialog.cpp
51-===================================================================
52---- windows/TPlink/LoginDialog.cpp (revision 28927)
53-+++ windows/TPlink/LoginDialog.cpp (working copy)
54-@@ -1,7 +1,7 @@
55- // TortoiseSVN - a Windows shell extension for easy version control
16+--- console.c (revision 29211)
17++++ console.c (working copy)
18+@@ -9,41 +9,37 @@
19+ #include "misc.h"
20+ #include "console.h"
5621
57-+// Copyright (C) 2003, 2013-2014, 2018, 2020 - TortoiseSVN
58- // Copyright (C) 2018-2019 - TortoiseGit
59--// Copyright (C) 2003, 2013-2014, 2018 - TortoiseSVN
22++#include "LoginDialog.h"
23++
24+ const char hk_absentmsg_common_fmt[] =
25+ "The server's host key is not cached. You have no guarantee\n"
26+ "that the server is the computer you think it is.\n"
27+ "The server's %s key fingerprint is:\n"
28+- "%s\n";
29+-const char hk_absentmsg_interactive_intro[] =
30+- "If you trust this host, enter \"y\" to add the key to\n"
31++ "%s\n"
32++ "%s\n\n"
33++ "If you trust this host, hit Yes to add the key to\n"
34+ "PuTTY's cache and carry on connecting.\n"
35+ "If you want to carry on connecting just once, without\n"
36+- "adding the key to the cache, enter \"n\".\n"
37+- "If you do not trust this host, press Return to abandon the\n"
38++ "adding the key to the cache, hit No.\n"
39++ "If you do not trust this host, hit Cancel to abandon the\n"
40+ "connection.\n";
41+-const char hk_absentmsg_interactive_prompt[] =
42+- "Store key in cache? (y/n, Return cancels connection, "
43+- "i for more info) ";
6044
61- // This program is free software; you can redistribute it and/or
62- // modify it under the terms of the GNU General Public License
63-@@ -24,8 +24,6 @@
45+ const char hk_wrongmsg_common_fmt[] =
46+ "WARNING - POTENTIAL SECURITY BREACH!\n"
47++ "\n"
48+ "The server's host key does not match the one PuTTY has\n"
49+ "cached. This means that either the server administrator\n"
50+ "has changed the host key, or you have actually connected\n"
51+ "to another computer pretending to be the server.\n"
52+ "The new %s key fingerprint is:\n"
53+- "%s\n";
54+-const char hk_wrongmsg_interactive_intro[] =
55++ "%s\n"
56++ "%s\n\n"
57+ "If you were expecting this change and trust the new key,\n"
58+- "enter \"y\" to update PuTTY's cache and continue connecting.\n"
59++ "hit Yes to update PuTTY's cache and continue connecting.\n"
60+ "If you want to carry on connecting but without updating\n"
61+- "the cache, enter \"n\".\n"
62+- "If you want to abandon the connection completely, press\n"
63+- "Return to cancel. Pressing Return is the ONLY guaranteed\n"
64+- "safe choice.\n";
65+-const char hk_wrongmsg_interactive_prompt[] =
66+- "Update cached key? (y/n, Return cancels connection, "
67+- "i for more info) ";
68++ "the cache, hit No.\n"
69++ "If you want to abandon the connection completely, hit\n"
70++ "Cancel. Hitting Cancel is the ONLY guaranteed safe choice.\n";
6471
65- #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
72+ const char weakcrypto_msg_common_fmt[] =
73+ "The first %s supported by the server is\n"
74+@@ -56,8 +52,8 @@
75+ "above the threshold, which we do not have stored:\n"
76+ "%s\n";
6677
67--#define MAX_LENGTH_PASSWORD 256
68--
69- HINSTANCE g_hmodThisDll;
70- HWND g_hwndMain;
78+-const char console_continue_prompt[] = "Continue with connection? (y/n) ";
79+-const char console_abandoned_msg[] = "Connection abandoned.\n";
80++//const char console_continue_prompt[] = "Continue with connection? (y/n) ";
81++//const char console_abandoned_msg[] = "Connection abandoned.\n";
7182
72-Index: windows/TPlink/LoginDialog.h
73-===================================================================
74---- windows/TPlink/LoginDialog.h (revision 28927)
75-+++ windows/TPlink/LoginDialog.h (working copy)
76-@@ -1,6 +1,6 @@
77- // TortoiseSVN - a Windows shell extension for easy version control
78-
79--// Copyright (C) 2003, 2013-2014 - TortoiseSVN
80-+// Copyright (C) 2003, 2013-2014, 2020 - TortoiseSVN
81-
82- // This program is free software; you can redistribute it and/or
83- // modify it under the terms of the GNU General Public License
84-@@ -19,6 +19,8 @@
85- #pragma once
86- #include <windows.h>
87-
88-+#define MAX_LENGTH_PASSWORD 256
89-+
90- #ifdef __cplusplus
91- extern "C" {
92- #endif
93-Index: windows/wincons.c
94-===================================================================
95---- windows/wincons.c (revision 28953)
96-+++ windows/wincons.c (working copy)
97-@@ -11,6 +11,8 @@
98- #include "storage.h"
99- #include "ssh.h"
100-
101-+#include "LoginDialog.h"
102-+
10383 bool console_batch_mode = false;
10484
105- /*
106-@@ -31,37 +33,16 @@
107- /*
108- * Various error message and/or fatal exit functions.
85+@@ -65,42 +61,36 @@
86+ * Error message and/or fatal exit functions, all based on
87+ * console_print_error_msg which the platform front end provides.
10988 */
110--void console_print_error_msg(const char *prefix, const char *msg)
111--{
112-- fputs(prefix, stderr);
113-- fputs(": ", stderr);
114-- fputs(msg, stderr);
115-- fputc('\n', stderr);
116-- fflush(stderr);
117--}
118--
11989 -void console_print_error_msg_fmt_v(
12090 - const char *prefix, const char *fmt, va_list ap)
12191 -{
@@ -134,108 +104,150 @@
134104 -
135105 void modalfatalbox(const char *fmt, ...)
136106 {
137- va_list ap;
138-+ char *stuff, morestuff[100];
139- va_start(ap, fmt);
107+- va_list ap;
108+- va_start(ap, fmt);
140109 - console_print_error_msg_fmt_v("FATAL ERROR", fmt, ap);
141-+ stuff = dupvprintf(fmt, ap);
142- va_end(ap);
143-+ sprintf(morestuff, "%.70s Fatal Error", appname);
144-+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
145-+ sfree(stuff);
110+- va_end(ap);
111++ va_list ap;
112++ char *stuff, morestuff[100];
113++ va_start(ap, fmt);
114++ stuff = dupvprintf(fmt, ap);
115++ va_end(ap);
116++ sprintf(morestuff, "%.70s Fatal Error", appname);
117++ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
118++ sfree(stuff);
146119 cleanup_exit(1);
147120 }
148121
149-@@ -68,14 +49,20 @@
150122 void nonfatal(const char *fmt, ...)
151123 {
152- va_list ap;
153-+ char *stuff, morestuff[100];
154- va_start(ap, fmt);
124+- va_list ap;
125+- va_start(ap, fmt);
155126 - console_print_error_msg_fmt_v("ERROR", fmt, ap);
156-+ stuff = dupvprintf(fmt, ap);
157- va_end(ap);
158-+ sprintf(morestuff, "%.70s Error", appname);
159-+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
160-+ sfree(stuff);
127+- va_end(ap);
128++ va_list ap;
129++ char *stuff, morestuff[100];
130++ va_start(ap, fmt);
131++ stuff = dupvprintf(fmt, ap);
132++ va_end(ap);
133++ sprintf(morestuff, "%.70s Error", appname);
134++ MessageBox(GetParentHwnd(), stuff, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
135++ sfree(stuff);
161136 }
162137
163138 void console_connection_fatal(Seat *seat, const char *msg)
164139 {
165140 - console_print_error_msg("FATAL ERROR", msg);
166-+ char morestuff[100];
167-+ sprintf(morestuff, "%.70s Fatal Error", appname);
168-+ MessageBox(GetParentHwnd(), msg, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
141++ char morestuff[100];
142++ sprintf(morestuff, "%.70s Fatal Error", appname);
143++ MessageBox(GetParentHwnd(), msg, morestuff, MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
169144 cleanup_exit(1);
170145 }
171146
172-@@ -89,8 +76,6 @@
147+Index: version.h
148+===================================================================
149+--- version.h (revision 29211)
150++++ version.h (working copy)
151+@@ -1,6 +1,6 @@
152+-/* Generated by automated build script */
153++
154+ #define RELEASE 0.75
155+ #define TEXTVER "Release 0.75"
156+-#define SSHVER "-Release-0.75"
157++#define SSHVER "TortoisePlink-Release-0.75"
158+ #define BINARY_VERSION 0,75,0,0
159+ #define SOURCE_COMMIT "c72200ff8851b0d95574b8a8a88a2780a243c66c"
160+Index: windows/wincons.c
161+===================================================================
162+--- windows/wincons.c (revision 29211)
163++++ windows/wincons.c (working copy)
164+@@ -11,6 +11,8 @@
165+ #include "ssh.h"
166+ #include "console.h"
167+
168++#include "LoginDialog.h"
169++
170+ void cleanup_exit(int code)
171+ {
172+ /*
173+@@ -23,15 +25,6 @@
174+ exit(code);
175+ }
176+
177+-void console_print_error_msg(const char *prefix, const char *msg)
178+-{
179+- fputs(prefix, stderr);
180+- fputs(": ", stderr);
181+- fputs(msg, stderr);
182+- fputc('\n', stderr);
183+- fflush(stderr);
184+-}
185+-
186+ int console_verify_ssh_host_key(
187+ Seat *seat, const char *host, int port, const char *keytype,
188+ char *keystr, const char *keydisp, char **fingerprints,
189+@@ -38,11 +31,8 @@
173190 void (*callback)(void *ctx, int result), void *ctx)
174191 {
175192 int ret;
176193 - HANDLE hin;
177194 - DWORD savemode, i;
195+- const char *common_fmt, *intro, *prompt;
178196
179- static const char absentmsg_batch[] =
180- "The server's host key is not cached in the registry. You\n"
181-@@ -105,13 +90,12 @@
182- "think it is.\n"
183- "The server's %s key fingerprint is:\n"
184- "%s\n"
185-- "If you trust this host, enter \"y\" to add the key to\n"
186-+ "If you trust this host, hit Yes to add the key to\n"
187- "PuTTY's cache and carry on connecting.\n"
188- "If you want to carry on connecting just once, without\n"
189-- "adding the key to the cache, enter \"n\".\n"
190-- "If you do not trust this host, press Return to abandon the\n"
191-- "connection.\n"
192-- "Store key in cache? (y/n) ";
193-+ "adding the key to the cache, hit No.\n"
194-+ "If you do not trust this host, hit Cancel to abandon the\n"
195-+ "connection.\n";
196-
197- static const char wrongmsg_batch[] =
198- "WARNING - POTENTIAL SECURITY BREACH!\n"
199-@@ -125,6 +109,7 @@
200- "Connection abandoned.\n";
201- static const char wrongmsg[] =
202- "WARNING - POTENTIAL SECURITY BREACH!\n"
203-+ "\n"
204- "The server's host key does not match the one PuTTY has\n"
205- "cached in the registry. This means that either the\n"
206- "server administrator has changed the host key, or you\n"
207-@@ -133,17 +118,15 @@
208- "The new %s key fingerprint is:\n"
209- "%s\n"
210- "If you were expecting this change and trust the new key,\n"
211-- "enter \"y\" to update PuTTY's cache and continue connecting.\n"
212-+ "hit Yes to update PuTTY's cache and continue connecting.\n"
213- "If you want to carry on connecting but without updating\n"
214-- "the cache, enter \"n\".\n"
215-- "If you want to abandon the connection completely, press\n"
216-- "Return to cancel. Pressing Return is the ONLY guaranteed\n"
217-- "safe choice.\n"
218-- "Update cached key? (y/n, Return cancels connection) ";
219-+ "the cache, hit No.\n"
220-+ "If you want to abandon the connection completely, hit\n"
221-+ "Cancel. Hitting Cancel is the ONLY guaranteed safe choice.\n";
222-
223- static const char abandoned[] = "Connection abandoned.\n";
224-
225197 - char line[32];
226198 + static const char mbtitle[] = "%s Security Alert";
227199
228200 /*
229201 * Verify the key against the registry.
230-@@ -154,39 +137,40 @@
202+@@ -53,64 +43,40 @@
231203 return 1;
232204
233205 if (ret == 2) { /* key was different */
234-- if (console_batch_mode) {
235-- fprintf(stderr, wrongmsg_batch, keytype, fingerprint);
206+- common_fmt = hk_wrongmsg_common_fmt;
207+- intro = hk_wrongmsg_interactive_intro;
208+- prompt = hk_wrongmsg_interactive_prompt;
209+- } else { /* key was absent */
210+- common_fmt = hk_absentmsg_common_fmt;
211+- intro = hk_absentmsg_interactive_intro;
212+- prompt = hk_absentmsg_interactive_prompt;
213+- }
214+-
215+- FingerprintType fptype_default =
216+- ssh2_pick_default_fingerprint(fingerprints);
217+-
218+- fprintf(stderr, common_fmt, keytype, fingerprints[fptype_default]);
219+- if (console_batch_mode) {
220+- fputs(console_abandoned_msg, stderr);
221+- return 0;
222+- }
223+-
224+- fputs(intro, stderr);
225+- fflush(stderr);
226+-
227+- while (true) {
228+- fputs(prompt, stderr);
229+- fflush(stderr);
230+-
231+- line[0] = '\0'; /* fail safe if ReadFile returns no data */
232+-
233+- hin = GetStdHandle(STD_INPUT_HANDLE);
234+- GetConsoleMode(hin, &savemode);
235+- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
236+- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
237+- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
238+- SetConsoleMode(hin, savemode);
239+-
240+- if (line[0] == 'i' || line[0] == 'I') {
241+- fprintf(stderr, "Full public key:\n%s\n", keydisp);
242+- if (fingerprints[SSH_FPTYPE_SHA256])
243+- fprintf(stderr, "SHA256 key fingerprint:\n%s\n",
244+- fingerprints[SSH_FPTYPE_SHA256]);
245+- if (fingerprints[SSH_FPTYPE_MD5])
246+- fprintf(stderr, "MD5 key fingerprint:\n%s\n",
247+- fingerprints[SSH_FPTYPE_MD5]);
236248 + int mbret;
237249 + char *message, *title;
238-+ message = dupprintf(wrongmsg, keytype, fingerprint);
250++ message = dupprintf(hk_wrongmsg_common_fmt, keytype, fingerprints[SSH_FPTYPE_SHA256], fingerprints[SSH_FPTYPE_MD5]);
239251 + title = dupprintf(mbtitle, appname);
240252 + mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
241253 + sfree(message);
@@ -245,82 +257,64 @@
245257 + return 1;
246258 + } else if (mbret == IDNO) {
247259 + return 1;
248-+ } else {
249- return 0;
260+ } else {
261+- break;
262++ return 0;
250263 }
251-- fprintf(stderr, wrongmsg, keytype, fingerprint);
252-- fflush(stderr);
253264 }
254- if (ret == 1) { /* key was absent */
255-- if (console_batch_mode) {
256-- fprintf(stderr, absentmsg_batch, keytype, fingerprint);
265+-
266+- /* In case of misplaced reflexes from another program, also recognise 'q'
267+- * as 'abandon connection rather than trust this key' */
268+- if (line[0] != '\0' && line[0] != '\r' && line[0] != '\n' &&
269+- line[0] != 'q' && line[0] != 'Q') {
270+- if (line[0] == 'y' || line[0] == 'Y')
271++ if (ret == 1) { /* key was absent */
257272 + int mbret;
258273 + char *message, *title;
259-+ message = dupprintf(absentmsg, keytype, fingerprint);
274++ message = dupprintf(hk_absentmsg_common_fmt, keytype, fingerprints[SSH_FPTYPE_SHA256], fingerprints[SSH_FPTYPE_MD5]);
260275 + title = dupprintf(mbtitle, appname);
261276 + mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
262277 + sfree(message);
263278 + sfree(title);
264279 + if (mbret == IDYES) {
265-+ store_host_key(host, port, keytype, keystr);
280+ store_host_key(host, port, keytype, keystr);
281+- return 1;
282+- } else {
283+- fputs(console_abandoned_msg, stderr);
284+- return 0;
266285 + return 1;
267286 + } else if (mbret == IDNO) {
268287 + return 1;
269288 + } else {
270- return 0;
271- }
272-- fprintf(stderr, absentmsg, keytype, fingerprint);
273-- fflush(stderr);
289++ return 0;
290++ }
274291 }
275--
276-- line[0] = '\0'; /* fail safe if ReadFile returns no data */
277--
278-- hin = GetStdHandle(STD_INPUT_HANDLE);
279-- GetConsoleMode(hin, &savemode);
280-- SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
281-- ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
282-- ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
283-- SetConsoleMode(hin, savemode);
284--
285-- if (line[0] != '\0' && line[0] != '\r' && line[0] != '\n') {
286-- if (line[0] == 'y' || line[0] == 'Y')
287-- store_host_key(host, port, keytype, keystr);
288-- return 1;
289-- } else {
290-- fprintf(stderr, abandoned);
291-- return 0;
292-- }
293292 + return 0;
294293 }
295294
296295 int console_confirm_weak_crypto_primitive(
297-@@ -193,9 +177,6 @@
296+@@ -117,32 +83,19 @@
298297 Seat *seat, const char *algtype, const char *algname,
299298 void (*callback)(void *ctx, int result), void *ctx)
300299 {
301300 - HANDLE hin;
302301 - DWORD savemode, i;
303--
304- static const char msg[] =
305- "The first %s supported by the server is\n"
306- "%s, which is below the configured warning threshold.\n"
307-@@ -206,27 +187,19 @@
308- "Connection abandoned.\n";
309- static const char abandoned[] = "Connection abandoned.\n";
310-
311-- char line[32];
312302 + int mbret;
313303 + char *message, *title;
314304 + static const char mbtitle[] = "%s Security Alert";
315305
306+- char line[32];
307++ message = dupprintf(weakcrypto_msg_common_fmt, algtype, algname);
308++ title = dupprintf(mbtitle, appname);
309+
310+- fprintf(stderr, weakcrypto_msg_common_fmt, algtype, algname);
311+-
316312 - if (console_batch_mode) {
317-- fprintf(stderr, msg_batch, algtype, algname);
313+- fputs(console_abandoned_msg, stderr);
318314 - return 0;
319315 - }
320-+ message = dupprintf(msg, algtype, algname);
321-+ title = dupprintf(mbtitle, appname);
322-
323-- fprintf(stderr, msg, algtype, algname);
316+-
317+- fputs(console_continue_prompt, stderr);
324318 - fflush(stderr);
325319 -
326320 - hin = GetStdHandle(STD_INPUT_HANDLE);
@@ -337,32 +331,37 @@
337331 + if (mbret == IDYES) {
338332 return 1;
339333 } else {
340-- fprintf(stderr, abandoned);
334+- fputs(console_abandoned_msg, stderr);
341335 return 0;
342336 }
343337 }
344-@@ -254,27 +227,20 @@
345- "Connection abandoned.\n";
346- static const char abandoned[] = "Connection abandoned.\n";
347-
348-- char line[32];
338+@@ -151,32 +104,20 @@
339+ Seat *seat, const char *algname, const char *betteralgs,
340+ void (*callback)(void *ctx, int result), void *ctx)
341+ {
342+- HANDLE hin;
343+- DWORD savemode, i;
349344 + int mbret;
350345 + char *message, *title;
351346 + static const char mbtitle[] = "%s Security Alert";
352347
353-- if (console_batch_mode) {
354-- fprintf(stderr, msg_batch, algname, betteralgs);
355-- return 0;
356-- }
357-+ message = dupprintf(msg, algname, betteralgs);
348+- char line[32];
349++ message = dupprintf(weakhk_msg_common_fmt, algname, betteralgs);
358350 + title = dupprintf(mbtitle, appname);
359351
360-- fprintf(stderr, msg, algname, betteralgs);
361-- fflush(stderr);
352+- fprintf(stderr, weakhk_msg_common_fmt, algname, betteralgs);
362353 + mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING | MB_YESNOCANCEL | MB_DEFBUTTON3);
363354 + sfree(message);
364355 + sfree(title);
365356
357+- if (console_batch_mode) {
358+- fputs(console_abandoned_msg, stderr);
359+- return 0;
360+- }
361+-
362+- fputs(console_continue_prompt, stderr);
363+- fflush(stderr);
364+-
366365 - hin = GetStdHandle(STD_INPUT_HANDLE);
367366 - GetConsoleMode(hin, &savemode);
368367 - SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
@@ -374,11 +373,11 @@
374373 + if (mbret == IDYES) {
375374 return 1;
376375 } else {
377-- fprintf(stderr, abandoned);
376+- fputs(console_abandoned_msg, stderr);
378377 return 0;
379378 }
380379 }
381-@@ -323,34 +289,28 @@
380+@@ -224,34 +165,28 @@
382381 "You can overwrite it with a new session log,\n"
383382 "append your session log to the end of it,\n"
384383 "or disable session logging for this session.\n"
@@ -426,7 +425,7 @@
426425 return 1;
427426 else
428427 return 0;
429-@@ -430,7 +390,6 @@
428+@@ -331,7 +266,6 @@
430429
431430 int console_get_userpass_input(prompts_t *p)
432431 {
@@ -434,7 +433,7 @@
434433 size_t curr_prompt;
435434
436435 /*
437-@@ -442,109 +401,16 @@
436+@@ -343,109 +277,16 @@
438437 prompt_set_result(p->prompts[i], "");
439438 }
440439
@@ -553,41 +552,33 @@
553552 return 1; /* success */
554553 Index: windows/winplink.c
555554 ===================================================================
556---- windows/winplink.c (revision 28953)
555+--- windows/winplink.c (revision 29211)
557556 +++ windows/winplink.c (working copy)
558-@@ -15,6 +15,10 @@
557+@@ -12,12 +12,22 @@
558+ #include "tree234.h"
559+ #include "winsecur.h"
559560
560- #define WM_AGENT_CALLBACK (WM_APP + 4)
561-
561++extern HWND GetParentHwnd();
562++
562563 +#include <commctrl.h>
563564 +#pragma comment(lib, "comctl32.lib")
564565 +#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
565566 +
566- struct agent_callback {
567- void (*callback)(void *, void *, int);
568- void *callback_ctx;
569-@@ -24,11 +28,15 @@
570-
571567 void cmdline_error(const char *fmt, ...)
572568 {
573-- va_list ap;
574-- va_start(ap, fmt);
569+ va_list ap;
570++ char *stuff, morestuff[100];
571+ va_start(ap, fmt);
575572 - console_print_error_msg_fmt_v("plink", fmt, ap);
576-- va_end(ap);
577-- exit(1);
578-+ va_list ap;
579-+ char *stuff, morestuff[100];
580-+ va_start(ap, fmt);
581-+ stuff = dupvprintf(fmt, ap);
582-+ va_end(ap);
583-+ sprintf(morestuff, "%.70s Command Line Error", appname);
584-+ MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
585-+ sfree(stuff);
586-+ exit(1);
573++ stuff = dupvprintf(fmt, ap);
574+ va_end(ap);
575++ sprintf(morestuff, "%.70s Command Line Error", appname);
576++ MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
577++ sfree(stuff);
578+ exit(1);
587579 }
588580
589- HANDLE inhandle, outhandle, errhandle;
590-@@ -124,69 +132,74 @@
581+@@ -112,74 +122,79 @@
591582 */
592583 static void usage(void)
593584 {
@@ -602,6 +593,8 @@
602593 - printf(" -load sessname Load settings from saved session\n");
603594 - printf(" -ssh -telnet -rlogin -raw -serial\n");
604595 - printf(" force use of a particular protocol\n");
596+- printf(" -ssh-connection\n");
597+- printf(" force use of the bare ssh-connection protocol\n");
605598 - printf(" -P port connect to specified port\n");
606599 - printf(" -l user connect with specified username\n");
607600 - printf(" -batch disable all interactive prompts\n");
@@ -620,7 +613,7 @@
620613 - printf(" -X -x enable / disable X11 forwarding\n");
621614 - printf(" -A -a enable / disable agent forwarding\n");
622615 - printf(" -t -T enable / disable pty allocation\n");
623-- printf(" -1 -2 force use of particular protocol version\n");
616+- printf(" -1 -2 force use of particular SSH protocol version\n");
624617 - printf(" -4 -6 force use of IPv4 or IPv6\n");
625618 - printf(" -C enable compression\n");
626619 - printf(" -i key private key file for user authentication\n");
@@ -628,7 +621,7 @@
628621 - printf(" -agent enable use of Pageant\n");
629622 - printf(" -noshare disable use of connection sharing\n");
630623 - printf(" -share enable use of connection sharing\n");
631-- printf(" -hostkey aa:bb:cc:...\n");
624+- printf(" -hostkey keyid\n");
632625 - printf(" manually specify a host key (may be repeated)\n");
633626 - printf(" -sanitise-stderr, -sanitise-stdout, "
634627 - "-no-sanitise-stderr, -no-sanitise-stdout\n");
@@ -644,65 +637,73 @@
644637 - printf(" -sshlog file\n");
645638 - printf(" -sshrawlog file\n");
646639 - printf(" log protocol details to a file\n");
640+- printf(" -logoverwrite\n");
641+- printf(" -logappend\n");
642+- printf(" control what happens when a log file already exists\n");
647643 - printf(" -shareexists\n");
648644 - printf(" test whether a connection-sharing upstream exists\n");
649645 + char buf[10000];
650646 + int j = 0;
651-+ j += sprintf(buf+j, "TortoisePlink: command-line connection utility (based on PuTTY Plink)\n");
652-+ j += sprintf(buf+j, "%s\n", ver);
653-+ j += sprintf(buf+j, "Usage: tortoiseplink [options] [user@]host [command]\n");
654-+ j += sprintf(buf+j, " (\"host\" can also be a PuTTY saved session name)\n");
655-+ j += sprintf(buf+j, "Options:\n");
656-+ j += sprintf(buf+j, " -V print version information and exit\n");
657-+ j += sprintf(buf+j, " -pgpfp print PGP key fingerprints and exit\n");
658-+ j += sprintf(buf+j, " -v show verbose messages\n");
659-+ j += sprintf(buf+j, " -load sessname Load settings from saved session\n");
660-+ j += sprintf(buf+j, " -ssh -telnet -rlogin -raw -serial\n");
661-+ j += sprintf(buf+j, " force use of a particular protocol\n");
662-+ j += sprintf(buf+j, " -P port connect to specified port\n");
663-+ j += sprintf(buf+j, " -l user connect with specified username\n");
664-+ j += sprintf(buf+j, " -batch disable all interactive prompts\n");
665-+ j += sprintf(buf+j, " -proxycmd command\n");
666-+ j += sprintf(buf+j, " use 'command' as local proxy\n");
667-+ j += sprintf(buf+j, " -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
668-+ j += sprintf(buf+j, " Specify the serial configuration (serial only)\n");
669-+ j += sprintf(buf+j, "The following options only apply to SSH connections:\n");
670-+ j += sprintf(buf+j, " -pw passw login with specified password\n");
671-+ j += sprintf(buf+j, " -D [listen-IP:]listen-port\n");
672-+ j += sprintf(buf+j, " Dynamic SOCKS-based port forwarding\n");
673-+ j += sprintf(buf+j, " -L [listen-IP:]listen-port:host:port\n");
674-+ j += sprintf(buf+j, " Forward local port to remote address\n");
675-+ j += sprintf(buf+j, " -R [listen-IP:]listen-port:host:port\n");
676-+ j += sprintf(buf+j, " Forward remote port to local address\n");
677-+ j += sprintf(buf+j, " -X -x enable / disable X11 forwarding\n");
678-+ j += sprintf(buf+j, " -A -a enable / disable agent forwarding\n");
679-+ j += sprintf(buf+j, " -t -T enable / disable pty allocation\n");
680-+ j += sprintf(buf+j, " -1 -2 force use of particular protocol version\n");
681-+ j += sprintf(buf+j, " -4 -6 force use of IPv4 or IPv6\n");
682-+ j += sprintf(buf+j, " -C enable compression\n");
683-+ j += sprintf(buf+j, " -i key private key file for user authentication\n");
684-+ j += sprintf(buf+j, " -noagent disable use of Pageant\n");
685-+ j += sprintf(buf+j, " -agent enable use of Pageant\n");
686-+ j += sprintf(buf+j, " -noshare disable use of connection sharing\n");
687-+ j += sprintf(buf+j, " -share enable use of connection sharing\n");
688-+ j += sprintf(buf+j, " -hostkey aa:bb:cc:...\n");
689-+ j += sprintf(buf+j, " manually specify a host key (may be repeated)\n");
690-+ j += sprintf(buf+j, " -sanitise-stderr, -sanitise-stdout,\n");
691-+ j += sprintf(buf+j, " -no-sanitise-stderr, -no-sanitise-stdout\n");
692-+ j += sprintf(buf+j, " do/don't strip control chars from standard\n");
693-+ j += sprintf(buf+j, " output/error\n");
694-+ j += sprintf(buf+j, " -no-antispoof omit anti-spoofing prompt after\n");
695-+ j += sprintf(buf+j, " authentication\n");
696-+ j += sprintf(buf+j, " -m file read remote command(s) from file\n");
697-+ j += sprintf(buf+j, " -s remote command is an SSH subsystem (SSH-2 only)\n");
698-+ j += sprintf(buf+j, " -N don't start a shell/command (SSH-2 only)\n");
699-+ j += sprintf(buf+j, " -nc host:port\n");
700-+ j += sprintf(buf+j, " open tunnel in place of session (SSH-2 only)\n");
701-+ j += sprintf(buf+j, " -sshlog file\n");
702-+ j += sprintf(buf+j, " -sshrawlog file\n");
703-+ j += sprintf(buf+j, " log protocol details to a file\n");
704-+ j += sprintf(buf+j, " -shareexists\n");
705-+ j += sprintf(buf+j, " test whether a connection-sharing upstream exists\n");
647++ j += sprintf(buf + j, "TortoisePlink: command-line connection utility (based on PuTTY Plink)\n");
648++ j += sprintf(buf + j, "%s\n", ver);
649++ j += sprintf(buf + j, "Usage: tortoiseplink [options] [user@]host [command]\n");
650++ j += sprintf(buf + j, " (\"host\" can also be a PuTTY saved session name)\n");
651++ j += sprintf(buf + j, "Options:\n");
652++ j += sprintf(buf + j, " -V print version information and exit\n");
653++ j += sprintf(buf + j, " -pgpfp print PGP key fingerprints and exit\n");
654++ j += sprintf(buf + j, " -v show verbose messages\n");
655++ j += sprintf(buf + j, " -load sessname Load settings from saved session\n");
656++ j += sprintf(buf + j, " -ssh -telnet -rlogin -raw -serial\n");
657++ j += sprintf(buf + j, " force use of a particular protocol\n");
658++ j += sprintf(buf + j, " -ssh-connection\n");
659++ j += sprintf(buf + j, " force use of the bare ssh-connection protocol\n");
660++ j += sprintf(buf + j, " -P port connect to specified port\n");
661++ j += sprintf(buf + j, " -l user connect with specified username\n");
662++ j += sprintf(buf + j, " -batch disable all interactive prompts (ignored)\n");
663++ j += sprintf(buf + j, " -proxycmd command\n");
664++ j += sprintf(buf + j, " use 'command' as local proxy\n");
665++ j += sprintf(buf + j, " -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
666++ j += sprintf(buf + j, " Specify the serial configuration (serial only)\n");
667++ j += sprintf(buf + j, "The following options only apply to SSH connections:\n");
668++ j += sprintf(buf + j, " -pw passw login with specified password\n");
669++ j += sprintf(buf + j, " -D [listen-IP:]listen-port\n");
670++ j += sprintf(buf + j, " Dynamic SOCKS-based port forwarding\n");
671++ j += sprintf(buf + j, " -L [listen-IP:]listen-port:host:port\n");
672++ j += sprintf(buf + j, " Forward local port to remote address\n");
673++ j += sprintf(buf + j, " -R [listen-IP:]listen-port:host:port\n");
674++ j += sprintf(buf + j, " Forward remote port to local address\n");
675++ j += sprintf(buf + j, " -X -x enable / disable X11 forwarding\n");
676++ j += sprintf(buf + j, " -A -a enable / disable agent forwarding\n");
677++ j += sprintf(buf + j, " -t -T enable / disable pty allocation\n");
678++ j += sprintf(buf + j, " -1 -2 force use of particular SSH protocol version\n");
679++ j += sprintf(buf + j, " -4 -6 force use of IPv4 or IPv6\n");
680++ j += sprintf(buf + j, " -C enable compression\n");
681++ j += sprintf(buf + j, " -i key private key file for user authentication\n");
682++ j += sprintf(buf + j, " -noagent disable use of Pageant\n");
683++ j += sprintf(buf + j, " -agent enable use of Pageant\n");
684++ j += sprintf(buf + j, " -noshare disable use of connection sharing\n");
685++ j += sprintf(buf + j, " -share enable use of connection sharing\n");
686++ j += sprintf(buf + j, " -hostkey keyid\n");
687++ j += sprintf(buf + j, " manually specify a host key (may be repeated)\n");
688++ j += sprintf(buf + j, " -sanitise-stderr, -sanitise-stdout,\n");
689++ j += sprintf(buf + j, " -no-sanitise-stderr, -no-sanitise-stdout\n");
690++ j += sprintf(buf + j, " do/don't strip control chars from standard\n");
691++ j += sprintf(buf + j, " output/error\n");
692++ j += sprintf(buf + j, " -no-antispoof omit anti-spoofing prompt after\n");
693++ j += sprintf(buf + j, " authentication\n");
694++ j += sprintf(buf + j, " -m file read remote command(s) from file\n");
695++ j += sprintf(buf + j, " -s remote command is an SSH subsystem (SSH-2 only)\n");
696++ j += sprintf(buf + j, " -N don't start a shell/command (SSH-2 only)\n");
697++ j += sprintf(buf + j, " -nc host:port\n");
698++ j += sprintf(buf + j, " open tunnel in place of session (SSH-2 only)\n");
699++ j += sprintf(buf + j, " -sshlog file\n");
700++ j += sprintf(buf + j, " -sshrawlog file\n");
701++ j += sprintf(buf + j, " log protocol details to a file\n");
702++ j += sprintf(buf + j, " -logoverwrite\n");
703++ j += sprintf(buf + j, " -logappend\n");
704++ j += sprintf(buf + j, " control what happens when a log file already exists\n");
705++ j += sprintf(buf + j, " -shareexists\n");
706++ j += sprintf(buf + j, " test whether a connection-sharing upstream exists\n");
706707 + MessageBox(NULL, buf, "TortoisePlink", MB_ICONINFORMATION);
707708 exit(1);
708709 }
@@ -709,9 +710,10 @@
709710
710711 static void version(void)
711712 {
713+- char *buildinfo_text = buildinfo("\n");
714+- printf("plink: %s\n%s\n", ver, buildinfo_text);
712715 + char buf[1000];
713- char *buildinfo_text = buildinfo("\n");
714-- printf("plink: %s\n%s\n", ver, buildinfo_text);
716++ char* buildinfo_text = buildinfo("\n");
715717 + sprintf(buf, "TortoisePlink: %s\n%s\n", ver, buildinfo_text);
716718 sfree(buildinfo_text);
717719 + MessageBox(NULL, buf, "TortoisePlink", MB_ICONINFORMATION);
@@ -718,20 +720,22 @@
718720 exit(0);
719721 }
720722
721-@@ -273,6 +286,7 @@
723+@@ -274,6 +289,7 @@
722724
723725 dll_hijacking_protection();
724726
725727 + InitCommonControls();
726- sklist = NULL;
727- skcount = sksize = 0;
728728 /*
729-@@ -295,31 +309,18 @@
729+ * Initialise port and protocol to sensible defaults. (These
730+ * will be overridden by more or less anything.)
731+@@ -286,24 +302,11 @@
732+ */
730733 conf = conf_new();
731734 do_defaults(NULL, conf);
732- loaded_session = false;
733-- default_protocol = conf_get_int(conf, CONF_protocol);
734-- default_port = conf_get_int(conf, CONF_port);
735+- settings_set_default_protocol(conf_get_int(conf, CONF_protocol));
736+- settings_set_default_port(conf_get_int(conf, CONF_port));
737++ settings_set_default_protocol(PROT_SSH);
738++ settings_set_default_port(22);
735739 errors = false;
736740 - {
737741 - /*
@@ -741,21 +745,19 @@
741745 - if (p) {
742746 - const struct BackendVtable *vt = backend_vt_from_name(p);
743747 - if (vt) {
744-- default_protocol = vt->protocol;
745-- default_port = vt->default_port;
746-- conf_set_int(conf, CONF_protocol, default_protocol);
747-- conf_set_int(conf, CONF_port, default_port);
748+- settings_set_default_protocol(vt->protocol);
749+- settings_set_default_port(vt->default_port);
750+- conf_set_int(conf, CONF_protocol, vt->protocol);
751+- conf_set_int(conf, CONF_port, vt->default_port);
748752 - }
749753 - }
750754 - }
751-+ conf_set_int(conf, CONF_protocol, default_protocol);
752-+ conf_set_int(conf, CONF_port, default_port);
753755 + conf_set_bool(conf, CONF_agentfwd, FALSE);
754756 + conf_set_bool(conf, CONF_x11_forward, FALSE);
755757 while (--argc) {
756-- char *p = *++argv;
757-+ char *p = *++argv;
758+ char *p = *++argv;
758759 int ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
760+@@ -310,7 +313,7 @@
759761 1, conf);
760762 if (ret == -2) {
761763 fprintf(stderr,
@@ -764,7 +766,7 @@
764766 errors = true;
765767 } else if (ret == 2) {
766768 --argc, ++argv;
767-@@ -326,7 +327,7 @@
769+@@ -317,7 +320,7 @@
768770 } else if (ret == 1) {
769771 continue;
770772 } else if (!strcmp(p, "-batch")) {
@@ -773,12 +775,9 @@
773775 } else if (!strcmp(p, "-s")) {
774776 /* Save status to write to conf later. */
775777 use_subsystem = true;
776-@@ -369,9 +370,9 @@
777- conf_set_bool(conf, CONF_nopty, true); /* command => no tty */
778-
778+@@ -362,7 +365,7 @@
779779 strbuf_free(cmdbuf);
780-- break; /* done with cmdline */
781-+ break; /* done with cmdline */
780+ break; /* done with cmdline */
782781 } else {
783782 - fprintf(stderr, "plink: unknown option \"%s\"\n", p);
784783 + fprintf(stderr, "TortoisePlink: unknown option \"%s\"\n", p);
@@ -785,14 +784,21 @@
785784 errors = true;
786785 }
787786 }
788-@@ -414,8 +415,8 @@
787+@@ -400,7 +403,7 @@
789788
789+ if (vt->flags & BACKEND_NEEDS_TERMINAL) {
790+ fprintf(stderr,
791+- "Plink doesn't support %s, which needs terminal emulation\n",
792++ "TortoisePlink doesn't support %s, which needs terminal emulation\n",
793+ vt->displayname);
794+ return 1;
795+ }
796+@@ -407,7 +410,7 @@
797+
790798 sk_init();
791799 if (p_WSAEventSelect == NULL) {
792800 - fprintf(stderr, "Plink requires WinSock 2\n");
793-- return 1;
794-+ fprintf(stderr, "TortoisePlink requires WinSock 2\n");
795-+ return 1;
801++ fprintf(stderr, "TortoisePlink requires WinSock 2\n");
802+ return 1;
796803 }
797804
798- /*
Show on old repository browser