win32 openssl CLI: preserve original echo state
Mirror the patch to ui_openssl.c, also fix the broken conditional that made it not actually turn off echo in the first place. ok guenther@
This commit is contained in:
parent
c1a162d83b
commit
ddeb740426
@ -133,6 +133,7 @@
|
|||||||
/* Define globals. They are protected by a lock */
|
/* Define globals. They are protected by a lock */
|
||||||
static void (*savsig[NX509_SIG])(int );
|
static void (*savsig[NX509_SIG])(int );
|
||||||
|
|
||||||
|
DWORD console_mode;
|
||||||
static FILE *tty_in, *tty_out;
|
static FILE *tty_in, *tty_out;
|
||||||
static int is_a_tty;
|
static int is_a_tty;
|
||||||
|
|
||||||
@ -300,28 +301,27 @@ open_console(UI *ui)
|
|||||||
tty_in = stdin;
|
tty_in = stdin;
|
||||||
tty_out = stderr;
|
tty_out = stderr;
|
||||||
|
|
||||||
return 1;
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
|
return GetConsoleMode(handle, &console_mode);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
noecho_console(UI *ui)
|
noecho_console(UI *ui)
|
||||||
{
|
{
|
||||||
DWORD mode = 0;
|
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (handle != INVALID_HANDLE_VALUE && handle != handle) {
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
return GetConsoleMode(handle, &mode) && SetConsoleMode(handle, mode & (~ENABLE_ECHO_INPUT));
|
return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
echo_console(UI *ui)
|
echo_console(UI *ui)
|
||||||
{
|
{
|
||||||
DWORD mode = 0;
|
|
||||||
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
HANDLE handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
if (handle != INVALID_HANDLE_VALUE && handle != handle) {
|
if (handle != INVALID_HANDLE_VALUE)
|
||||||
return GetConsoleMode(handle, &mode) && SetConsoleMode(handle, mode | ENABLE_ECHO_INPUT);
|
return SetConsoleMode(handle, console_mode);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user