aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrent Cook <busterb@gmail.com>2015-12-05 22:14:42 -0600
committerBrent Cook <bcook@openbsd.org>2015-12-06 16:49:01 -0600
commitafcc027da77f2285eda4c018348a3794c667581d (patch)
tree8eee108720ac9624f4b06a1dc718a9acaeba8e36
parent75ef5bb160fb261da1950abfd3d22f54011458e1 (diff)
downloadportable-afcc027da77f2285eda4c018348a3794c667581d.tar.gz
portable-afcc027da77f2285eda4c018348a3794c667581d.tar.bz2
portable-afcc027da77f2285eda4c018348a3794c667581d.zip
only set the console mode if stdin is a console (not a pipe)
This allows piping commands and running from a cygwin console.
-rw-r--r--crypto/compat/ui_openssl_win.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/crypto/compat/ui_openssl_win.c b/crypto/compat/ui_openssl_win.c
index 13e93bc..aaab60b 100644
--- a/crypto/compat/ui_openssl_win.c
+++ b/crypto/compat/ui_openssl_win.c
@@ -301,27 +301,39 @@ open_console(UI *ui)
301 tty_in = stdin; 301 tty_in = stdin;
302 tty_out = stderr; 302 tty_out = stderr;
303 303
304 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); 304 HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
305 if (handle != INVALID_HANDLE_VALUE) 305 if (handle != INVALID_HANDLE_VALUE) {
306 return GetConsoleMode(handle, &console_mode); 306 if (GetFileType(handle) == FILE_TYPE_CHAR)
307 return GetConsoleMode(handle, &console_mode);
308 else
309 return 1;
310 }
307 return 0; 311 return 0;
308} 312}
309 313
310static int 314static int
311noecho_console(UI *ui) 315noecho_console(UI *ui)
312{ 316{
313 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); 317 HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
314 if (handle != INVALID_HANDLE_VALUE) 318 if (handle != INVALID_HANDLE_VALUE) {
315 return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT); 319 if (GetFileType(handle) == FILE_TYPE_CHAR)
320 return SetConsoleMode(handle, console_mode & ~ENABLE_ECHO_INPUT);
321 else
322 return 1;
323 }
316 return 0; 324 return 0;
317} 325}
318 326
319static int 327static int
320echo_console(UI *ui) 328echo_console(UI *ui)
321{ 329{
322 HANDLE handle = GetStdHandle(STD_INPUT_HANDLE); 330 HANDLE handle = (HANDLE)_get_osfhandle(STDIN_FILENO);
323 if (handle != INVALID_HANDLE_VALUE) 331 if (handle != INVALID_HANDLE_VALUE) {
324 return SetConsoleMode(handle, console_mode); 332 if (GetFileType(handle) == FILE_TYPE_CHAR)
333 return SetConsoleMode(handle, console_mode);
334 else
335 return 1;
336 }
325 return 0; 337 return 0;
326} 338}
327 339