X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwincons.c;h=d7b95704174fb11a14a5e1e934d1d076bcf4e7cf;hb=1de7240eb88fa24a8532ded116b4ec72dd213008;hp=9824a5a5b7c82320f654e8800217d3dbf2e44c54;hpb=da66c0656a6622a23cfdd8316e66681e487b87f1;p=PuTTY.git diff --git a/windows/wincons.c b/windows/wincons.c index 9824a5a5..d7b95704 100644 --- a/windows/wincons.c +++ b/windows/wincons.c @@ -41,12 +41,12 @@ void notify_remote_exit(void *frontend) { } -void timer_change_notify(long next) +void timer_change_notify(unsigned long next) { } -int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype, - char *keystr, char *fingerprint, +int verify_ssh_host_key(void *frontend, char *host, int port, + const char *keytype, char *keystr, char *fingerprint, void (*callback)(void *ctx, int result), void *ctx) { int ret; @@ -197,6 +197,53 @@ int askalg(void *frontend, const char *algtype, const char *algname, } } +int askhk(void *frontend, const char *algname, const char *betteralgs, + void (*callback)(void *ctx, int result), void *ctx) +{ + HANDLE hin; + DWORD savemode, i; + + static const char msg[] = + "The first host key type we have stored for this server\n" + "is %s, which is below the configured warning threshold.\n" + "The server also provides the following types of host key\n" + "above the threshold, which we do not have stored:\n" + "%s\n" + "Continue with connection? (y/n) "; + static const char msg_batch[] = + "The first host key type we have stored for this server\n" + "is %s, which is below the configured warning threshold.\n" + "The server also provides the following types of host key\n" + "above the threshold, which we do not have stored:\n" + "%s\n" + "Connection abandoned.\n"; + static const char abandoned[] = "Connection abandoned.\n"; + + char line[32]; + + if (console_batch_mode) { + fprintf(stderr, msg_batch, algname, betteralgs); + return 0; + } + + fprintf(stderr, msg, algname, betteralgs); + 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] == 'y' || line[0] == 'Y') { + return 1; + } else { + fprintf(stderr, abandoned); + return 0; + } +} + /* * Ask whether to wipe a session log file before writing to it. * Returns 2 for wipe, 1 for append, 0 for cancel (don't log). @@ -281,9 +328,11 @@ void pgp_fingerprints(void) "one. See the manual for more information.\n" "(Note: these fingerprints have nothing to do with SSH!)\n" "\n" - "PuTTY Master Key (RSA), 1024-bit:\n" + "PuTTY Master Key as of 2015 (RSA, 4096-bit):\n" + " " PGP_MASTER_KEY_FP "\n\n" + "Original PuTTY Master Key (RSA, 1024-bit):\n" " " PGP_RSA_MASTER_KEY_FP "\n" - "PuTTY Master Key (DSA), 1024-bit:\n" + "Original PuTTY Master Key (DSA, 1024-bit):\n" " " PGP_DSA_MASTER_KEY_FP "\n", stdout); } @@ -304,7 +353,8 @@ static void console_data_untrusted(HANDLE hout, const char *data, int len) WriteFile(hout, data, len, &dummy, NULL); } -int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) +int console_get_userpass_input(prompts_t *p, + const unsigned char *in, int inlen) { HANDLE hin, hout; size_t curr_prompt;