Control: tags - patch

builds. Further testing is welcome.

Sebastian
>From f6afa6be81eae0b149ad18a0642c67e75b148c69 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <sebast...@breakpoint.cc>
Date: Thu, 27 Oct 2016 19:43:15 +0000
Subject: [PATCH] opendkim: port to openssl 1.1.0

In configure.ac AC_SEARCH_LIBS([SSL_library_init]) does not work as
expected because openssl 1.1.0 does not provide this function anymore.
Instead it is a macro pointing to another function so we need the
header file for this to work. Therefore it is replaced with
AC_LINK_IFELSE() where it is possible to add a header file.

OPENSSL_thread_stop() shouldn't be required. As of openssl 1.1.0 thread
managements is different and those function shouldn't be required
because openssl takes care of it. As per "NOTES" is is said, that it
might be requiired for staticaly linked code.

Signed-off-by: Sebastian Andrzej Siewior <sebast...@breakpoint.cc>
---
 configure.ac               | 40 +++++++++++++++++++++-------------------
 opendkim/opendkim-crypto.c |  8 ++++++++
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0370d43..0eec798 100644
--- a/configure.ac
+++ b/configure.ac
@@ -860,26 +860,28 @@ then
 	AC_SEARCH_LIBS([ERR_peek_error], [crypto], ,
 	               AC_MSG_ERROR([libcrypto not found]))
 
-	AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
-		[
-			if test x"$enable_shared" = x"yes"
-			then
-				AC_MSG_ERROR([Cannot build shared opendkim
-				              against static openssl libraries.
-				              Configure with --disable-shared
-				              to get this working or obtain a
-				              shared libssl library for
-				              opendkim to use.])
-			fi
 
-			# avoid caching issue - last result of SSL_library_init
-			# shouldn't be cached for this next check
-			unset ac_cv_search_SSL_library_init
-			LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
-			AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
-			               AC_MSG_ERROR([libssl not found]), [-ldl])
-		]
-	)
+	AC_LINK_IFELSE(
+		       [AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
+					[[SSL_library_init();]])],
+					[od_have_ossl="yes";],
+					[od_have_ossl="no";])
+	if test x"$od_have_ossl" = x"no"
+	then
+		if test x"$enable_shared" = x"yes"
+		then
+			AC_MSG_ERROR([Cannot build shared opendkim
+			              against static openssl libraries.
+			              Configure with --disable-shared
+			              to get this working or obtain a
+			              shared libssl library for
+			              opendkim to use.])
+		fi
+
+		LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
+		AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
+		               AC_MSG_ERROR([libssl not found]), [-ldl])
+	fi
 
 	AC_CHECK_DECL([SHA256_DIGEST_LENGTH],
                       AC_DEFINE([HAVE_SHA256], 1,
diff --git a/opendkim/opendkim-crypto.c b/opendkim/opendkim-crypto.c
index d78426d..ba82789 100644
--- a/opendkim/opendkim-crypto.c
+++ b/opendkim/opendkim-crypto.c
@@ -222,7 +222,11 @@ dkimf_crypto_free_id(void *ptr)
 	{
 		assert(pthread_setspecific(id_key, ptr) == 0);
 
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+		OPENSSL_thread_stop();
+#else
 		ERR_remove_state(0);
+#endif
 
 		free(ptr);
 
@@ -392,11 +396,15 @@ dkimf_crypto_free(void)
 {
 	if (crypto_init_done)
 	{
+#if OPENSSL_VERSION_NUMBER >= 0x10100000
+		OPENSSL_thread_stop();
+#else
 		CRYPTO_cleanup_all_ex_data();
 		CONF_modules_free();
 		EVP_cleanup();
 		ERR_free_strings();
 		ERR_remove_state(0);
+#endif
 
 		if (nmutexes > 0)
 		{
-- 
2.10.1

Reply via email to