libesmtp: fix build

This commit is contained in:
Danny Rawlins 2019-12-08 23:37:17 +11:00
parent a93ca5bc55
commit 6e21b8a579
3 changed files with 81 additions and 5 deletions

View File

@ -1,5 +1,6 @@
untrusted comment: verify with /etc/ports/opt.pub
RWSE3ohX2g5d/dlgZC7CWvihgYOAS0ZkWOurLTEyGxIPKvkDmerJZylZlI3wk5D9w/NKnbyVrQeiVmNQUPSEjg7MbklvfkLFKwU=
SHA256 (Pkgfile) = c32d8c9719d10179a6b8c060f7469a368d7f92fe0e46a47961fbeb8fafe588d7
RWSE3ohX2g5d/YsEq4r2AzxRQGREoGHhJWIBSF4LJkCzCbGx6RvtFFwjUXg2ysEd1OaY2SrGTtZwsgl3xUpj+X7ympcy0R8uDgQ=
SHA256 (Pkgfile) = 776b88d88ed7817c40857f50d9b6dcbab8850269696ddd43d7a36c9ac3db9221
SHA256 (.footprint) = 0ab43d99a738ede6695a94f8caa028e955111e634353e7d7741cc08aad8d3b68
SHA256 (libesmtp-1.0.6.tar.bz2) = d0a61a5c52d99fa7ce7d00ed0a07e341dbda67101dbed1ab0cdae3f37db4eb0b
SHA256 (libesmtp-1.0.6-openssl-1.1-api-compatibility.patch) = d10161f8b01c7865dcb948f8e65e61b8596752856953a605632d2c09dd41494c

View File

@ -1,17 +1,20 @@
# Description: A library for posting electronic mail
# URL: http://brianstafford.info/libesmtp
# Maintainer: Thomas Penteker, tek at serverop dot de
# Packager: Tilman Sauerbeck, tilman at crux dot nu
# Depends on: openssl
name=libesmtp
version=1.0.6
release=1
source=(http://pkgs.fedoraproject.org/repo/pkgs/$name/$name-$version.tar.bz2/bf3915e627fd8f35524a8fdfeed979c8/$name-$version.tar.bz2)
release=2
source=(https://pkgs.fedoraproject.org/repo/pkgs/$name/$name-$version.tar.bz2/bf3915e627fd8f35524a8fdfeed979c8/$name-$version.tar.bz2
libesmtp-1.0.6-openssl-1.1-api-compatibility.patch)
build() {
cd $name-$version
patch -p1 -i $SRC/libesmtp-1.0.6-openssl-1.1-api-compatibility.patch
autoreconf -i
./configure \
--prefix=/usr \
--with-openssl=/usr \

View File

@ -0,0 +1,72 @@
diff --git a/configure.ac b/configure.ac
index 556f220..2c0693d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,7 +303,7 @@ if test x$with_openssl != xno ; then
)
fi
if test x$with_openssl != xno ; then
- AC_CHECK_LIB(ssl, SSL_library_init, [
+ AC_CHECK_LIB(ssl, SSL_new, [
with_openssl=yes
LIBS="-lssl -lcrypto $LIBS"
], [
diff --git a/smtp-tls.c b/smtp-tls.c
index 9a66806..cfc6589 100644
--- a/smtp-tls.c
+++ b/smtp-tls.c
@@ -57,6 +57,7 @@ static void *ctx_password_cb_arg;
#ifdef USE_PTHREADS
#include <pthread.h>
static pthread_mutex_t starttls_mutex = PTHREAD_MUTEX_INITIALIZER;
+#if OPENSSL_VERSION_NUMBER < 0x10100000
static pthread_mutex_t *openssl_mutex;
static void
@@ -70,6 +71,7 @@ openssl_mutexcb (int mode, int n,
pthread_mutex_unlock (&openssl_mutex[n]);
}
#endif
+#endif
static int
starttls_init (void)
@@ -77,6 +79,10 @@ starttls_init (void)
if (tls_init)
return 1;
+#if OPENSSL_VERSION_NUMBER < 0x10100000
+ /* starting from OpenSSL 1.1.0, OpenSSL uses a new threading API and does its own locking */
+ /* also initialization has been reworked and is done automatically */
+ /* so there's not much to do here any more */
#ifdef USE_PTHREADS
/* Set up mutexes for the OpenSSL library */
if (openssl_mutex == NULL)
@@ -94,9 +100,10 @@ starttls_init (void)
CRYPTO_set_locking_callback (openssl_mutexcb);
}
#endif
- tls_init = 1;
SSL_load_error_strings ();
SSL_library_init ();
+#endif
+ tls_init = 1;
return 1;
}
@@ -201,7 +208,15 @@ starttls_create_ctx (smtp_session_t session)
3207. Servers typically support SSL as well as TLS because some
versions of Netscape do not support TLS. I am assuming that all
currently deployed servers correctly support TLS. */
+#if OPENSSL_VERSION_NUMBER < 0x10100000
ctx = SSL_CTX_new (TLSv1_client_method ());
+#else
+ ctx = SSL_CTX_new (TLS_client_method ());
+ if (!SSL_CTX_set_min_proto_version(ctx, TLS1_VERSION)) {
+ /* FIXME: set an error code AND free the allocated ctx */
+ return NULL;
+ }
+#endif
/* Load our keys and certificates. To avoid messing with configuration
variables etc, use fixed paths for the certificate store. These are