[commit] r2101 - trunk/Tools/GMEplink/Windows

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Nov 7 10:27:31 CST 2012


Author: ksmyth
Date: Wed Nov  7 10:27:31 2012
New Revision: 2101

Log:
Revert "Reverse Peters changes to Putty files, so the Putty files are back to stock 0.60"

This reverts commit ec72f05244470de871b339b660bb581896811040.

Conflicts:

	Tools/GMEplink/Windows/WINCONS.C
	Tools/GMEplink/Windows/winplink.c

Modified:
   trunk/Tools/GMEplink/Windows/WINCONS.C
   trunk/Tools/GMEplink/Windows/WINMISC.C
   trunk/Tools/GMEplink/Windows/winplink.c

Modified: trunk/Tools/GMEplink/Windows/WINCONS.C
==============================================================================
--- trunk/Tools/GMEplink/Windows/WINCONS.C	Wed Nov  7 10:26:59 2012	(r2100)
+++ trunk/Tools/GMEplink/Windows/WINCONS.C	Wed Nov  7 10:27:31 2012	(r2101)
@@ -11,6 +11,8 @@
 #include "storage.h"
 #include "ssh.h"
 
+#include "LoginDialog.h"
+
 int console_batch_mode = FALSE;
 
 static void *console_logctx = NULL;
@@ -50,8 +52,6 @@
                         void (*callback)(void *ctx, int result), void *ctx)
 {
     int ret;
-    HANDLE hin;
-    DWORD savemode, i;
 
     static const char absentmsg_batch[] =
 	"The server's host key is not cached in the registry. You\n"
@@ -104,7 +104,7 @@
 
     static const char abandoned[] = "Connection abandoned.\n";
 
-    char line[32];
+	static const char mbtitle[] = "%s Security Alert";
 
     /*
      * Verify the key against the registry.
@@ -115,37 +115,41 @@
 	return 1;
 
     if (ret == 2) {		       /* key was different */
-	if (console_batch_mode) {
-	    fprintf(stderr, wrongmsg_batch, keytype, fingerprint);
-            return 0;
+	int mbret;
+	char *message, *title;
+
+	message = dupprintf(wrongmsg, appname, keytype, fingerprint, appname);
+	title = dupprintf(mbtitle, appname);
+
+	mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING|MB_YESNO);
+	sfree(message);
+	sfree(title);
+	if (mbret == IDYES) {
+		store_host_key(host, port, keytype, keystr);
+		return 1;
 	}
-	fprintf(stderr, wrongmsg, keytype, fingerprint);
-	fflush(stderr);
-    }
-    if (ret == 1) {		       /* key was absent */
-	if (console_batch_mode) {
-	    fprintf(stderr, absentmsg_batch, keytype, fingerprint);
-            return 0;
+	else
+		return 0;
 	}
-	fprintf(stderr, absentmsg, keytype, fingerprint);
-	fflush(stderr);
-    }
-
-    hin = GetStdHandle(STD_INPUT_HANDLE);
-    GetConsoleMode(hin, &savemode);
-    SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
-			 ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
-    ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
-    SetConsoleMode(hin, savemode);
 
-    if (line[0] != '\0' && line[0] != '\r' && line[0] != '\n') {
-	if (line[0] == 'y' || line[0] == 'Y')
-	    store_host_key(host, port, keytype, keystr);
-        return 1;
-    } else {
-	fprintf(stderr, abandoned);
-        return 0;
+    if (ret == 1) {		       /* key was absent */
+	int mbret;
+	char *message, *title;
+	message = dupprintf(absentmsg, keytype, fingerprint, appname);
+	title = dupprintf(mbtitle, appname);
+	mbret = MessageBox(GetParentHwnd(), message, title,
+		MB_ICONWARNING | MB_YESNO);
+	sfree(message);
+	sfree(title);
+	if (mbret == IDYES)
+	{
+		store_host_key(host, port, keytype, keystr);
+		return 1;
+	}
+	else
+		return 0;
     }
+	return 1;
 }
 
 void update_specials_menu(void *frontend)
@@ -159,42 +163,26 @@
 int askalg(void *frontend, const char *algtype, const char *algname,
 	   void (*callback)(void *ctx, int result), void *ctx)
 {
-    HANDLE hin;
-    DWORD savemode, i;
-
     static const char msg[] =
 	"The first %s supported by the server is\n"
 	"%s, which is below the configured warning threshold.\n"
 	"Continue with connection? (y/n) ";
-    static const char msg_batch[] =
-	"The first %s supported by the server is\n"
-	"%s, which is below the configured warning threshold.\n"
-	"Connection abandoned.\n";
-    static const char abandoned[] = "Connection abandoned.\n";
 
-    char line[32];
-
-    if (console_batch_mode) {
-	fprintf(stderr, msg_batch, algtype, algname);
-	return 0;
-    }
+	static const char mbtitle[] = "%s Security Alert";
 
-    fprintf(stderr, msg, algtype, algname);
-    fflush(stderr);
+	int mbret;
+	char *message, *title;
 
-    hin = GetStdHandle(STD_INPUT_HANDLE);
-    GetConsoleMode(hin, &savemode);
-    SetConsoleMode(hin, (savemode | ENABLE_ECHO_INPUT |
-			 ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT));
-    ReadFile(hin, line, sizeof(line) - 1, &i, NULL);
-    SetConsoleMode(hin, savemode);
+	message = dupprintf(msg, algtype, algname);
+	title = dupprintf(mbtitle, appname);
 
-    if (line[0] == 'y' || line[0] == 'Y') {
-	return 1;
-    } else {
-	fprintf(stderr, abandoned);
-	return 0;
-    }
+	mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING|MB_YESNO);
+	sfree(message);
+	sfree(title);
+	if (mbret == IDYES)
+		return 1;
+	else
+		return 0;
 }
 
 /*
@@ -306,7 +294,6 @@
 
 int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
 {
-    HANDLE hin, hout;
     size_t curr_prompt;
 
     /*
@@ -334,66 +321,12 @@
 	}
     }
 
-    /*
-     * And if we have anything to print, we need standard output.
-     */
-    if ((p->name_reqd && p->name) || p->instruction || p->n_prompts) {
-	hout = GetStdHandle(STD_OUTPUT_HANDLE);
-	if (hout == INVALID_HANDLE_VALUE) {
-	    fprintf(stderr, "Cannot get standard output handle\n");
-	    cleanup_exit(1);
-	}
-    }
-
-    /*
-     * Preamble.
-     */
-    /* We only print the `name' caption if we have to... */
-    if (p->name_reqd && p->name) {
-	size_t l = strlen(p->name);
-	console_data_untrusted(hout, p->name, l);
-	if (p->name[l-1] != '\n')
-	    console_data_untrusted(hout, "\n", 1);
-    }
-    /* ...but we always print any `instruction'. */
-    if (p->instruction) {
-	size_t l = strlen(p->instruction);
-	console_data_untrusted(hout, p->instruction, l);
-	if (p->instruction[l-1] != '\n')
-	    console_data_untrusted(hout, "\n", 1);
-    }
 
     for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
-
-	DWORD savemode, newmode, i = 0;
+		
 	prompt_t *pr = p->prompts[curr_prompt];
-	BOOL r;
-
-	GetConsoleMode(hin, &savemode);
-	newmode = savemode | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT;
-	if (!pr->echo)
-	    newmode &= ~ENABLE_ECHO_INPUT;
-	else
-	    newmode |= ENABLE_ECHO_INPUT;
-	SetConsoleMode(hin, newmode);
-
-	console_data_untrusted(hout, pr->prompt, strlen(pr->prompt));
-
-	r = ReadFile(hin, pr->result, pr->result_len - 1, &i, NULL);
-
-	SetConsoleMode(hin, savemode);
-
-	if ((int) i > pr->result_len)
-	    i = pr->result_len - 1;
-	else
-	    i = i - 2;
-	pr->result[i] = '\0';
-
-	if (!pr->echo) {
-	    DWORD dummy;
-	    WriteFile(hout, "\r\n", 2, &dummy, NULL);
-	}
-
+	if (!DoLoginDialog(pr->result, pr->result_len-1, pr->prompt))
+	return 0;
     }
 
     return 1; /* success */

Modified: trunk/Tools/GMEplink/Windows/WINMISC.C
==============================================================================
--- trunk/Tools/GMEplink/Windows/WINMISC.C	Wed Nov  7 10:26:59 2012	(r2100)
+++ trunk/Tools/GMEplink/Windows/WINMISC.C	Wed Nov  7 10:27:31 2012	(r2101)
@@ -100,7 +100,7 @@
 
 BOOL init_winver(void)
 {
-    ZeroMemory(&osVersion, sizeof(osVersion));
+    SecureZeroMemory(&osVersion, sizeof(osVersion));
     osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
     return GetVersionEx ( (OSVERSIONINFO *) &osVersion);
 }

Modified: trunk/Tools/GMEplink/Windows/winplink.c
==============================================================================
--- trunk/Tools/GMEplink/Windows/winplink.c	Wed Nov  7 10:26:59 2012	(r2100)
+++ trunk/Tools/GMEplink/Windows/winplink.c	Wed Nov  7 10:27:31 2012	(r2101)
@@ -12,6 +12,8 @@
 #include "storage.h"
 #include "tree234.h"
 
+#include "LoginDialog.h"
+
 #define WM_AGENT_CALLBACK (WM_APP + 4)
 
 struct agent_callback {
@@ -23,55 +25,57 @@
 
 void fatalbox(char *p, ...)
 {
-    va_list ap;
-    fprintf(stderr, "FATAL ERROR: ");
-    va_start(ap, p);
-    vfprintf(stderr, p, ap);
-    va_end(ap);
-    fputc('\n', stderr);
-    if (logctx) {
-        log_free(logctx);
-        logctx = NULL;
-    }
-    cleanup_exit(1);
+	va_list ap;
+	char *stuff, morestuff[100];
+
+	va_start(ap, p);
+	stuff = dupvprintf(p, ap);
+	va_end(ap);
+	sprintf(morestuff, "%.70s Fatal Error", appname);
+	MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
+	sfree(stuff);
+	cleanup_exit(1);
 }
 void modalfatalbox(char *p, ...)
 {
-    va_list ap;
-    fprintf(stderr, "FATAL ERROR: ");
-    va_start(ap, p);
-    vfprintf(stderr, p, ap);
-    va_end(ap);
-    fputc('\n', stderr);
-    if (logctx) {
-        log_free(logctx);
-        logctx = NULL;
-    }
-    cleanup_exit(1);
+	va_list ap;
+	char *stuff, morestuff[100];
+
+	va_start(ap, p);
+	stuff = dupvprintf(p, ap);
+	va_end(ap);
+	sprintf(morestuff, "%.70s Fatal Error", appname);
+	MessageBox(GetParentHwnd(), stuff, morestuff,
+		MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
+	sfree(stuff);
+	cleanup_exit(1);
 }
 void connection_fatal(void *frontend, char *p, ...)
 {
-    va_list ap;
-    fprintf(stderr, "FATAL ERROR: ");
-    va_start(ap, p);
-    vfprintf(stderr, p, ap);
-    va_end(ap);
-    fputc('\n', stderr);
-    if (logctx) {
-        log_free(logctx);
-        logctx = NULL;
-    }
-    cleanup_exit(1);
+	va_list ap;
+	char *stuff, morestuff[100];
+
+	va_start(ap, p);
+	stuff = dupvprintf(p, ap);
+	va_end(ap);
+	sprintf(morestuff, "%.70s Fatal Error", appname);
+	MessageBox(GetParentHwnd(), stuff, morestuff,
+		MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
+	sfree(stuff);
+	cleanup_exit(1);
 }
 void cmdline_error(char *p, ...)
 {
-    va_list ap;
-    fprintf(stderr, "plink: ");
-    va_start(ap, p);
-    vfprintf(stderr, p, ap);
-    va_end(ap);
-    fputc('\n', stderr);
-    exit(1);
+	va_list ap;
+	char *stuff, morestuff[100];
+
+	va_start(ap, p);
+	stuff = dupvprintf(p, ap);
+	va_end(ap);
+	sprintf(morestuff, "%.70s Command Line Error", appname);
+	MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
+	sfree(stuff);
+	exit(1);
 }
 
 HANDLE inhandle, outhandle, errhandle;
@@ -157,51 +161,53 @@
  */
 static void usage(void)
 {
-    printf("PuTTY Link: command-line connection utility\n");
-    printf("%s\n", ver);
-    printf("Usage: plink [options] [user@]host [command]\n");
-    printf("       (\"host\" can also be a PuTTY saved session name)\n");
-    printf("Options:\n");
-    printf("  -V        print version information and exit\n");
-    printf("  -pgpfp    print PGP key fingerprints and exit\n");
-    printf("  -v        show verbose messages\n");
-    printf("  -load sessname  Load settings from saved session\n");
-    printf("  -ssh -telnet -rlogin -raw -serial\n");
-    printf("            force use of a particular protocol\n");
-    printf("  -P port   connect to specified port\n");
-    printf("  -l user   connect with specified username\n");
-    printf("  -batch    disable all interactive prompts\n");
-    printf("The following options only apply to SSH connections:\n");
-    printf("  -pw passw login with specified password\n");
-    printf("  -D [listen-IP:]listen-port\n");
-    printf("            Dynamic SOCKS-based port forwarding\n");
-    printf("  -L [listen-IP:]listen-port:host:port\n");
-    printf("            Forward local port to remote address\n");
-    printf("  -R [listen-IP:]listen-port:host:port\n");
-    printf("            Forward remote port to local address\n");
-    printf("  -X -x     enable / disable X11 forwarding\n");
-    printf("  -A -a     enable / disable agent forwarding\n");
-    printf("  -t -T     enable / disable pty allocation\n");
-    printf("  -1 -2     force use of particular protocol version\n");
-    printf("  -4 -6     force use of IPv4 or IPv6\n");
-    printf("  -C        enable compression\n");
-    printf("  -i key    private key file for authentication\n");
-    printf("  -noagent  disable use of Pageant\n");
-    printf("  -agent    enable use of Pageant\n");
-    printf("  -m file   read remote command(s) from file\n");
-    printf("  -s        remote command is an SSH subsystem (SSH-2 only)\n");
-    printf("  -N        don't start a shell/command (SSH-2 only)\n");
-    printf("  -nc host:port\n");
-    printf("            open tunnel in place of session (SSH-2 only)\n");
-    printf("  -sercfg configuration-string (e.g. 19200,8,n,1,X)\n");
-    printf("            Specify the serial configuration (serial only)\n");
-    exit(1);
+	char buf[10000];
+	int j = 0;
+
+	j += sprintf(buf+j, "GMEplink: command-line connection utility\n");
+    j += sprintf(buf+j, "%s\n", ver);
+    j += sprintf(buf+j, "Usage: plink [options] [user@]host [command]\n");
+    j += sprintf(buf+j, "       (\"host\" can also be a PuTTY saved session name)\n");
+    j += sprintf(buf+j, "Options:\n");
+    j += sprintf(buf+j, "  -V        print version information and exit\n");
+    j += sprintf(buf+j, "  -pgpfp    print PGP key fingerprints and exit\n");
+    j += sprintf(buf+j, "  -v        show verbose messages\n");
+    j += sprintf(buf+j, "  -load sessname  Load settings from saved session\n");
+    j += sprintf(buf+j, "  -ssh -telnet -rlogin -raw\n");
+    j += sprintf(buf+j, "            force use of a particular protocol\n");
+    j += sprintf(buf+j, "  -P port   connect to specified port\n");
+    j += sprintf(buf+j, "  -l user   connect with specified username\n");
+    j += sprintf(buf+j, "  -batch    disable all interactive prompts\n");
+    j += sprintf(buf+j, "The following options only apply to SSH connections:\n");
+    j += sprintf(buf+j, "  -pw passw login with specified password\n");
+    j += sprintf(buf+j, "  -D [listen-IP:]listen-port\n");
+    j += sprintf(buf+j, "            Dynamic SOCKS-based port forwarding\n");
+    j += sprintf(buf+j, "  -L [listen-IP:]listen-port:host:port\n");
+    j += sprintf(buf+j, "            Forward local port to remote address\n");
+    j += sprintf(buf+j, "  -R [listen-IP:]listen-port:host:port\n");
+    j += sprintf(buf+j, "            Forward remote port to local address\n");
+    j += sprintf(buf+j, "  -X -x     enable / disable X11 forwarding\n");
+    j += sprintf(buf+j, "  -A -a     enable / disable agent forwarding\n");
+    j += sprintf(buf+j, "  -t -T     enable / disable pty allocation\n");
+    j += sprintf(buf+j, "  -1 -2     force use of particular protocol version\n");
+    j += sprintf(buf+j, "  -4 -6     force use of IPv4 or IPv6\n");
+    j += sprintf(buf+j, "  -C        enable compression\n");
+    j += sprintf(buf+j, "  -i key    private key file for authentication\n");
+    j += sprintf(buf+j, "  -noagent  disable use of Pageant\n");
+    j += sprintf(buf+j, "  -agent    enable use of Pageant\n");
+    j += sprintf(buf+j, "  -m file   read remote command(s) from file\n");
+    j += sprintf(buf+j, "  -s        remote command is an SSH subsystem (SSH-2 only)\n");
+    j += sprintf(buf+j, "  -N        don't start a shell/command (SSH-2 only)\n");
+    j += sprintf(buf+j, "  -nc host:port\n");
+    j += sprintf(buf+j, "            open tunnel in place of session (SSH-2 only)\n");
+	MessageBox(NULL, buf, "GMEplink", MB_ICONINFORMATION);
+	exit(1);
 }
 
 static void version(void)
 {
-    printf("plink: %s\n", ver);
-    exit(1);
+	printf("GMEplink: %s\n", ver);
+	exit(1);
 }
 
 char *do_select(SOCKET skt, int startup)
@@ -273,6 +279,7 @@
     }
 }
 
+
 int main(int argc, char **argv)
 {
     int sending;
@@ -285,6 +292,7 @@
     int use_subsystem = 0;
     long now, next;
 
+	_set_printf_count_output(1);
     sklist = NULL;
     skcount = sksize = 0;
     /*
@@ -723,3 +731,8 @@
     cleanup_exit(exitcode);
     return 0;			       /* placate compiler warning */
 }
+
+int WinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow)
+{
+	main(__argc,__argv);
+}


More information about the gme-commit mailing list