[commit] r2099 - trunk/Tools/GMEplink/Windows
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Wed Nov 7 10:24:56 CST 2012
Author: ksmyth
Date: Wed Nov 7 10:24:56 2012
New Revision: 2099
Log:
Reverse Peters changes to Putty files, so the Putty files are back to stock 0.60
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 Fri Nov 2 11:49:44 2012 (r2098)
+++ trunk/Tools/GMEplink/Windows/WINCONS.C Wed Nov 7 10:24:56 2012 (r2099)
@@ -11,8 +11,6 @@
#include "storage.h"
#include "ssh.h"
-#include "LoginDialog.h"
-
int console_batch_mode = FALSE;
static void *console_logctx = NULL;
@@ -52,6 +50,8 @@
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";
- static const char mbtitle[] = "%s Security Alert";
+ char line[32];
/*
* Verify the key against the registry.
@@ -115,41 +115,37 @@
return 1;
if (ret == 2) { /* key was different */
- 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;
- }
- else
- return 0;
+ if (console_batch_mode) {
+ fprintf(stderr, wrongmsg_batch, keytype, fingerprint);
+ return 0;
}
-
+ fprintf(stderr, wrongmsg, keytype, fingerprint);
+ fflush(stderr);
+ }
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;
+ 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;
}
- return 1;
}
void update_specials_menu(void *frontend)
@@ -163,26 +159,42 @@
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";
- static const char mbtitle[] = "%s Security Alert";
+ char line[32];
- int mbret;
- char *message, *title;
+ if (console_batch_mode) {
+ fprintf(stderr, msg_batch, algtype, algname);
+ return 0;
+ }
- message = dupprintf(msg, algtype, algname);
- title = dupprintf(mbtitle, appname);
+ fprintf(stderr, msg, algtype, algname);
+ fflush(stderr);
- mbret = MessageBox(GetParentHwnd(), message, title, MB_ICONWARNING|MB_YESNO);
- sfree(message);
- sfree(title);
- if (mbret == IDYES)
- return 1;
- else
- return 0;
+ 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] == 'y' || line[0] == 'Y') {
+ return 1;
+ } else {
+ fprintf(stderr, abandoned);
+ return 0;
+ }
}
/*
@@ -294,6 +306,7 @@
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
+ HANDLE hin, hout;
size_t curr_prompt;
/*
@@ -308,12 +321,62 @@
if (console_batch_mode)
return 0;
+ hin = GetStdHandle(STD_INPUT_HANDLE);
+ hout = GetStdHandle(STD_OUTPUT_HANDLE);
+ if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE) {
+ fprintf(stderr, "Cannot get standard input/output handles\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];
- if (!DoLoginDialog(pr->result, pr->result_len-1, pr->prompt))
- return 0;
+ 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);
+ }
+
}
return 1; /* success */
Modified: trunk/Tools/GMEplink/Windows/WINMISC.C
==============================================================================
--- trunk/Tools/GMEplink/Windows/WINMISC.C Fri Nov 2 11:49:44 2012 (r2098)
+++ trunk/Tools/GMEplink/Windows/WINMISC.C Wed Nov 7 10:24:56 2012 (r2099)
@@ -67,7 +67,7 @@
BOOL init_winver(void)
{
- SecureZeroMemory(&osVersion, sizeof(osVersion));
+ ZeroMemory(&osVersion, sizeof(osVersion));
osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
return GetVersionEx ( (OSVERSIONINFO *) &osVersion);
}
Modified: trunk/Tools/GMEplink/Windows/winplink.c
==============================================================================
--- trunk/Tools/GMEplink/Windows/winplink.c Fri Nov 2 11:49:44 2012 (r2098)
+++ trunk/Tools/GMEplink/Windows/winplink.c Wed Nov 7 10:24:56 2012 (r2099)
@@ -12,8 +12,6 @@
#include "storage.h"
#include "tree234.h"
-#include "LoginDialog.h"
-
#define WM_AGENT_CALLBACK (WM_APP + 4)
struct agent_callback {
@@ -25,57 +23,55 @@
void fatalbox(char *p, ...)
{
- 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);
+ 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);
}
void modalfatalbox(char *p, ...)
{
- 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);
+ 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);
}
void connection_fatal(void *frontend, char *p, ...)
{
- 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);
+ 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);
}
void cmdline_error(char *p, ...)
{
- 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);
+ va_list ap;
+ fprintf(stderr, "plink: ");
+ va_start(ap, p);
+ vfprintf(stderr, p, ap);
+ va_end(ap);
+ fputc('\n', stderr);
+ exit(1);
}
HANDLE inhandle, outhandle, errhandle;
@@ -161,53 +157,49 @@
*/
static void usage(void)
{
- 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);
+ 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\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");
+ exit(1);
}
static void version(void)
{
- printf("GMEplink: %s\n", ver);
- exit(1);
+ printf("plink: %s\n", ver);
+ exit(1);
}
char *do_select(SOCKET skt, int startup)
@@ -279,7 +271,6 @@
}
}
-
int main(int argc, char **argv)
{
int sending;
@@ -291,7 +282,6 @@
int use_subsystem = 0;
long now, next;
- _set_printf_count_output(1);
sklist = NULL;
skcount = sksize = 0;
/*
@@ -744,8 +734,3 @@
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