a2a915
From 9fcd066217e8b6f52b601bdd8a0cb6455f98b88c Mon Sep 17 00:00:00 2001
a2a915
From: Petr Mensik <pemensik@redhat.com>
a2a915
Date: Thu, 7 Mar 2019 14:33:28 +0100
a2a915
Subject: [PATCH] Do not replace random generator on single thread
a2a915
a2a915
DHCP builds fails to initialize dst library entropy generator. It does
a2a915
not require it for anything. Instead of initializing it, skip replacing
a2a915
custom random generator in single thread builds. Should use OpenSSL
a2a915
default random generator in case of SSL.
a2a915
a2a915
Related: rhbz#1685940
a2a915
---
a2a915
 lib/dns/openssl_link.c | 8 +++++++-
a2a915
 1 file changed, 7 insertions(+), 1 deletion(-)
a2a915
a2a915
diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c
a2a915
index ec6dc7f..ca3ffbc 100644
a2a915
--- a/lib/dns/openssl_link.c
a2a915
+++ b/lib/dns/openssl_link.c
a2a915
@@ -31,6 +31,7 @@
a2a915
 #include <isc/mem.h>
a2a915
 #include <isc/mutex.h>
a2a915
 #include <isc/mutexblock.h>
a2a915
+#include <isc/platform.h>
a2a915
 #include <isc/string.h>
a2a915
 #include <isc/thread.h>
a2a915
 #include <isc/util.h>
a2a915
@@ -220,6 +221,7 @@ dst__openssl_init(const char *engine) {
a2a915
 	ERR_load_crypto_strings();
a2a915
 #endif
a2a915
 
a2a915
+#ifdef ISC_PLATFORM_USETHREADS
a2a915
 	rm = mem_alloc(sizeof(RAND_METHOD) FILELINE);
a2a915
 	if (rm == NULL) {
a2a915
 		result = ISC_R_NOMEMORY;
a2a915
@@ -231,6 +233,7 @@ dst__openssl_init(const char *engine) {
a2a915
 	rm->add = entropy_add;
a2a915
 	rm->pseudorand = entropy_getpseudo;
a2a915
 	rm->status = entropy_status;
a2a915
+#endif
a2a915
 
a2a915
 #if !defined(OPENSSL_NO_ENGINE)
a2a915
 #if !defined(CONF_MFLAGS_DEFAULT_SECTION)
a2a915
@@ -264,6 +267,7 @@ dst__openssl_init(const char *engine) {
a2a915
 		}
a2a915
 	}
a2a915
 
a2a915
+#ifdef ISC_PLATFORM_USETHREADS
a2a915
 	re = ENGINE_get_default_RAND();
a2a915
 	if (re == NULL) {
a2a915
 		re = ENGINE_new();
a2a915
@@ -276,6 +280,7 @@ dst__openssl_init(const char *engine) {
a2a915
 		ENGINE_free(re);
a2a915
 	} else
a2a915
 		ENGINE_finish(re);
a2a915
+#endif
a2a915
 #else
a2a915
 	RAND_set_rand_method(rm);
a2a915
 #endif /* !defined(OPENSSL_NO_ENGINE) */
a2a915
@@ -286,7 +291,8 @@ dst__openssl_init(const char *engine) {
a2a915
 	if (e != NULL)
a2a915
 		ENGINE_free(e);
a2a915
 	e = NULL;
a2a915
-	mem_free(rm FILELINE);
a2a915
+	if (rm != NULL)
a2a915
+		mem_free(rm FILELINE);
a2a915
 	rm = NULL;
a2a915
 #endif
a2a915
  cleanup_mutexinit:
a2a915
-- 
a2a915
2.20.1
a2a915