See the attached patch which applies over openssl-1.0.1e and selects the
use of existing support for the Windows API
WaitForSingleObject(..STD_INPUT_HANDLE..) to trigger a read of stdin. That
logic is hidden currently because OPENSSL_SYS_MSDOS is defined whenever
OPENSSL_SYS_WINDOWS is defined. By enabling that existing Windows logic,
data on stdin triggers a read without the requirement of a physical
keyboard event.
---------- Forwarded message ----------
From: Jeff Trawick <[email protected]>
Date: Fri, Oct 4, 2013 at 9:44 AM
Subject: Re: redirected input to s_client on Windows: Any trick to avoid
the keypress?
To: [email protected]
On Fri, Oct 4, 2013 at 9:17 AM, Salz, Rich <[email protected]> wrote:
> When you run it interactively, does it work right away or do you need to
> hit TWO returns?
>
It works right away.
The keypresses trigger the read of stdin (since the
WaitForSingleObject(stdin) is bypassed due to the OPENSSL_SYS_MSDOS issue),
so there's no problem in interactive mode.
> ****
>
> ** **
>
> ** **
>
> -- ****
>
> Principal Security Engineer****
>
> Akamai Technology****
>
> Cambridge, MA****
>
--
Born in Roswell... married an alien...
http://emptyhammock.com/
--
Born in Roswell... married an alien...
http://emptyhammock.com/
--- /c/Users/Trawick/s_client.c 2013-10-07 07:16:51 -0400
+++ apps/s_client.c 2013-10-07 07:12:35 -0400
@@ -178,6 +178,13 @@
#include <fcntl.h>
#endif
+/* Use Windows API with STD_INPUT_HANDLE when checking for input?
+ Don't look at OPENSSL_SYS_MSDOS for this, since it is always defined if
+ OPENSSL_SYS_WINDOWS is defined */
+#if defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_WINCE) &&
defined(STD_INPUT_HANDLE)
+#define OPENSSL_USE_STD_INPUT_HANDLE
+#endif
+
#undef PROG
#define PROG s_client_main
@@ -1604,10 +1611,10 @@
tv.tv_usec = 0;
i=select(width,(void *)&readfds,(void
*)&writefds,
NULL,&tv);
-#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
- if(!i && (!_kbhit() || !read_tty) )
continue;
-#else
+#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
if(!i && (!((_kbhit()) ||
(WAIT_OBJECT_0 == WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0))) ||
!read_tty) ) continue;
+#else
+ if(!i && (!_kbhit() || !read_tty) )
continue;
#endif
} else i=select(width,(void *)&readfds,(void
*)&writefds,
NULL,timeoutp);
@@ -1812,10 +1819,10 @@
}
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
-#if defined(OPENSSL_SYS_WINCE) || defined(OPENSSL_SYS_MSDOS)
- else if (_kbhit())
-#else
+#if defined(OPENSSL_USE_STD_INPUT_HANDLE)
else if ((_kbhit()) || (WAIT_OBJECT_0 ==
WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 0)))
+#else
+ else if (_kbhit())
#endif
#elif defined (OPENSSL_SYS_NETWARE)
else if (_kbhit())