summaryrefslogtreecommitdiffstats
path: root/apps/s_client.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-08-03 21:16:43 +0200
committerRichard Levitte <levitte@openssl.org>2016-09-15 23:24:06 +0200
commit0d3b65832c6fa94c1d1cfa2f99335f323e3227c1 (patch)
treee3a7995f3ff12d8f0c8f300439a31d77eedcf00e /apps/s_client.c
parent6f0ac0e2f27d9240516edb9a23b7863e7ad02898 (diff)
VSI submission: redirect terminal input through socket
This is needed, because on VMS, select() can only be used on sockets. being able to use select() on all kinds of file descriptors is unique to Unix. So, the solution for VMS is to create a layer that translates input from standard input to socket communication. Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'apps/s_client.c')
-rw-r--r--apps/s_client.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/apps/s_client.c b/apps/s_client.c
index 9c83d64742..8d07cc4d73 100644
--- a/apps/s_client.c
+++ b/apps/s_client.c
@@ -43,6 +43,9 @@
#ifndef OPENSSL_NO_SOCK
+#ifdef OPENSSL_SYS_VMS
+# include "vms_term_sock.h"
+#endif
/*
* With IPv6, it looks like Digital has mixed up the proper order of
* recursive header file inclusion, resulting in the compiler complaining
@@ -858,6 +861,10 @@ int s_client_main(int argc, char **argv)
int c_nbio = 0, c_msg = 0, c_ign_eof = 0, c_brief = 0;
int c_tlsextdebug = 0, c_status_req = 0;
BIO *bio_c_msg = NULL;
+#if defined(OPENSSL_SYS_VMS)
+ int stdin_sock;
+ TerminalSocket(TERM_SOCK_CREATE, &stdin_sock);
+#endif
FD_ZERO(&readfds);
FD_ZERO(&writefds);
@@ -1821,8 +1828,14 @@ int s_client_main(int argc, char **argv)
SSL_set_connect_state(con);
/* ok, lets connect */
+#if defined(OPENSSL_SYS_VMS)
+ if (stdin_sock > SSL_get_fd(con))
+ width = stdin_sock + 1;
+ else
+ width = SSL_get_fd(con) + 1;
+#else
width = SSL_get_fd(con) + 1;
-
+#endif
read_tty = 1;
write_tty = 0;
tty_on = 0;
@@ -2149,10 +2162,15 @@ int s_client_main(int argc, char **argv)
* and EOF satisfies that. To avoid a CPU-hogging loop,
* set the flag so we exit.
*/
+#if defined(OPENSSL_SYS_VMS)
+ if (read_tty && !at_eof)
+ openssl_fdset(stdin_sock, &readfds);
+#else
if (read_tty && !at_eof)
openssl_fdset(fileno(stdin), &readfds);
if (write_tty)
openssl_fdset(fileno(stdout), &writefds);
+#endif
}
if (read_ssl)
openssl_fdset(SSL_get_fd(con), &readfds);
@@ -2278,7 +2296,7 @@ int s_client_main(int argc, char **argv)
goto shut;
}
}
-#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_VMS)
/* Assume Windows/DOS/BeOS can always write */
else if (!ssl_pending && write_tty)
#else
@@ -2371,13 +2389,25 @@ int s_client_main(int argc, char **argv)
#if defined(OPENSSL_SYS_MSDOS)
else if (has_stdin_waiting())
#else
- else if (FD_ISSET(fileno(stdin), &readfds))
+
+#if defined(OPENSSL_SYS_VMS)
+ else if (FD_ISSET(stdin_sock,&readfds))
+#else
+ else if (FD_ISSET(fileno(stdin),&readfds))
+#endif
+
#endif
{
if (crlf) {
int j, lf_num;
i = raw_read_stdin(cbuf, BUFSIZZ / 2);
+ #if defined(OPENSSL_SYS_VMS)
+ i = recv(stdin_sock, cbuf, BUFSIZZ/2, 0);
+ #else
+ i = raw_read_stdin(cbuf, BUFSIZZ/2);
+ #endif
+
lf_num = 0;
/* both loops are skipped when i <= 0 */
for (j = 0; j < i; j++)
@@ -2393,8 +2423,13 @@ int s_client_main(int argc, char **argv)
}
assert(lf_num == 0);
} else
- i = raw_read_stdin(cbuf, BUFSIZZ);
-
+ {
+ #if defined(OPENSSL_SYS_VMS)
+ i = recv(stdin_sock, cbuf, BUFSIZZ, 0);
+ #else
+ i = raw_read_stdin(cbuf, BUFSIZZ);
+ #endif
+ }
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS)
if (i == 0)
at_eof = 1;
@@ -2479,6 +2514,9 @@ int s_client_main(int argc, char **argv)
bio_c_out = NULL;
BIO_free(bio_c_msg);
bio_c_msg = NULL;
+#if defined(OPENSSL_SYS_VMS)
+ TerminalSocket(TERM_SOCK_DELETE, &stdin_sock);
+#endif
return (ret);
}