diff options
author | Randall S. Becker <rsbecker@nexbridge.com> | 2020-09-06 16:37:47 -0500 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-09-12 20:32:11 +0200 |
commit | 08073700cc50bcd0df5c0ee68c100e300a320d03 (patch) | |
tree | 33e0641543cc32390ba73c49901183de01fdb9db /crypto/rand | |
parent | f0c62c53286b3a79cc059354a6d3425b35bb1d50 (diff) |
NonStop port updates for 3.0.0.
HPE NonStop Port Changes for 3.0.0 Includes unthreaded, PUT, and SPT for OSS.
The port changes include wrapping where necessary for FLOSS and
appropriate configuration changes to support that. Two tests
are excluded as being inappropriate for the platform.
The changes are:
* Added /usr/local/include to nonstop-nsx_spt_floss to load floss.h
* Added SPT Floss variant for NonStop
* Wrapped FLOSS definitions in OPENSSL_TANDEM_FLOSS to allow selective enablement.
* SPT build configuration for NonStop
* Skip tests not relevant for NonStop
* PUT configuration changes required for NonStop platforms
* Configurations/50-nonstop.conf: updates for TNS/X platform.
* FLOSS instrumentation for HPE NonStop TNS/X and TNS/E platforms.
* Configurations/50-nonstop.conf: modifications for non-PUT TNS/E platform b
* Fix use of DELAY in ssltestlib.c for HPNS.
* Fixed commit merge issues and added floss to http_server.c
CLA: Permission is granted by the author to the OpenSSL team to use these modifications.
Fixes #5087.
Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/12800)
Diffstat (limited to 'crypto/rand')
-rw-r--r-- | crypto/rand/rand_egd.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/crypto/rand/rand_egd.c b/crypto/rand/rand_egd.c index cd87531943..c6dcd87f04 100644 --- a/crypto/rand/rand_egd.c +++ b/crypto/rand/rand_egd.c @@ -54,6 +54,60 @@ struct sockaddr_un { # include <string.h> # include <errno.h> +# if defined(OPENSSL_SYSNAME_TANDEM) +/* + * HPNS: + * + * Our current MQ 5.3 EGD requies compatability-mode sockets + * This code forces the mode to compatibility if required + * and then restores the mode. + * + * Needs review: + * + * The better long-term solution is to either run two EGD's each in one of + * the two modes or revise the EGD code to listen on two different sockets + * (each in one of the two modes). + */ +_variable +int hpns_socket(int family, + int type, + int protocol, + char* transport) +{ + int socket_rc; + char current_transport[20]; + +# define AF_UNIX_PORTABILITY "$ZAFN2" +# define AF_UNIX_COMPATIBILITY "$ZPLS" + + if (!_arg_present(transport) || transport != NULL || transport[0] == '\0') + return socket(family, type, protocol); + + socket_transport_name_get(AF_UNIX, current_transport, 20); + + if (strcmp(current_transport,transport) == 0) + return socket(family, type, protocol); + + /* set the requested socket transport */ + if (socket_transport_name_set(AF_UNIX, transport)) + return -1; + + socket_rc = socket(family,type,protocol); + + /* set mode back to what it was */ + if (socket_transport_name_set(AF_UNIX, current_transport)) + return -1; + + return socket_rc; +} + +/*#define socket(a,b,c,...) hpns_socket(a,b,c,__VA_ARGS__) */ + +static int hpns_connect_attempt = 0; + +# endif /* defined(OPENSSL_SYS_HPNS) */ + + int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) { FILE *fp = NULL; @@ -71,7 +125,11 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) return -1; strcpy(addr.sun_path, path); i = offsetof(struct sockaddr_un, sun_path) + strlen(path); +#if defined(OPENSSL_SYSNAME_TANDEM) + fd = hpns_socket(AF_UNIX, SOCK_STREAM, 0, AF_UNIX_COMPATIBILITY); +#else fd = socket(AF_UNIX, SOCK_STREAM, 0); +#endif if (fd == -1 || (fp = fdopen(fd, "r+")) == NULL) return -1; setbuf(fp, NULL); @@ -100,6 +158,18 @@ int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes) /* No error, try again */ break; default: +# if defined(OPENSSL_SYSNAME_TANDEM) + if (hpns_connect_attempt == 0) { + /* try the other kind of AF_UNIX socket */ + close(fd); + fd = hpns_socket(AF_UNIX, SOCK_STREAM, 0, AF_UNIX_PORTABILITY); + if (fd == -1) + return -1; + ++hpns_connect_attempt; + break; /* try the connect again */ + } +# endif + ret = -1; goto err; } |