int console_batch_mode = FALSE;
+/*
+ * Clean up and exit.
+ */
+void cleanup_exit(int code)
+{
+ /*
+ * Clean up.
+ */
+ sk_cleanup();
+ WSACleanup();
+
+ if (cfg.protocol == PROT_SSH) {
+ random_save_seed();
+#ifdef MSCRYPTOAPI
+ crypto_wrapup();
+#endif
+ }
+
+ exit(code);
+}
+
void verify_ssh_host_key(char *host, int port, char *keytype,
char *keystr, char *fingerprint)
{
if (ret == 2) { /* key was different */
if (console_batch_mode) {
fprintf(stderr, wrongmsg_batch, fingerprint);
- exit(1);
+ cleanup_exit(1);
}
fprintf(stderr, wrongmsg, fingerprint);
fflush(stderr);
if (ret == 1) { /* key was absent */
if (console_batch_mode) {
fprintf(stderr, absentmsg_batch, fingerprint);
- exit(1);
+ cleanup_exit(1);
}
fprintf(stderr, absentmsg, fingerprint);
fflush(stderr);
store_host_key(host, port, keytype, keystr);
} else {
fprintf(stderr, abandoned);
- exit(0);
+ cleanup_exit(0);
}
}
(cs == 0) ? "" :
(cs == 1) ? "client-to-server " : "server-to-client ",
ciphername);
- exit(1);
+ cleanup_exit(1);
}
fprintf(stderr, msg,
return;
} else {
fprintf(stderr, abandoned);
- exit(0);
+ cleanup_exit(0);
}
}
hout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE) {
fprintf(stderr, "Cannot get standard input/output handles\n");
- exit(1);
+ cleanup_exit(1);
}
GetConsoleMode(hin, &savemode);