X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwincons.c;h=d7b95704174fb11a14a5e1e934d1d076bcf4e7cf;hb=1de7240eb88fa24a8532ded116b4ec72dd213008;hp=b0ca5f2e262f0bc54ffac5c28967c396a1ccd84b;hpb=f7713d452d37e9b314af48bb295d418b185989b7;p=PuTTY.git diff --git a/windows/wincons.c b/windows/wincons.c index b0ca5f2e..d7b95704 100644 --- a/windows/wincons.c +++ b/windows/wincons.c @@ -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); }