Skip to content

Commit 902276f

Browse files
committed
Fix handling of OpenSSL's SSL_clear_options
This function is supported down to OpenSSL 0.9.8, which is the oldest version supported since 593d4e4 (from Postgres 10 onwards), and is used since e3bdb2d (from 11 onwards). It is defined as a macro from OpenSSL 0.9.8 to 1.0.2, and as a function in 1.1.0 and newer versions. However, the configure check present is only adapted for functions. So, even if the code would be able to compile, configure fails to detect the macro, causing it to be ignored when compiling the code with OpenSSL from 0.9.8 to 1.0.2. The code needs a configure check as per a364dfa, which has fixed a compilation issue with a past version of LibreSSL in NetBSD 5.1. On HEAD, just remove the configure check as the last release of NetBSD 5 is from 2014 (and we have no more buildfarm members for it). In 11 and 12, improve the configure logic so as both macros and functions are correctly detected. This makes NetBSD 5 still work on already-released branches, but not for 13 onwards. The patch for HEAD is from me, and Daniel has written the version to use for the back-branches. Author: Michael Paquier, Daniel Gustaffson Reviewed-by: Tom Lane Discussion: https://postgr.es/m/20191205083252.GE5064@paquier.xyz Discussion: https://postgr.es/m/98F7F99E-1129-41D8-B86B-FE3B1E286881@yesql.se Backpatch-through: 11
1 parent 0e5baa0 commit 902276f

File tree

2 files changed

+53
-2
lines changed

2 files changed

+53
-2
lines changed

configure

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12130,7 +12130,7 @@ else
1213012130
fi
1213112131

1213212132
fi
12133-
for ac_func in SSL_clear_options SSL_get_current_compression X509_get_signature_nid
12133+
for ac_func in SSL_get_current_compression X509_get_signature_nid
1213412134
do :
1213512135
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1213612136
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -12173,6 +12173,43 @@ _ACEOF
1217312173
fi
1217412174
done
1217512175

12176+
# SSL_clear_options is a macro in OpenSSL from 0.9.8 to 1.0.2, and
12177+
# a function from 1.1.0 onwards so we cannot use AC_CHECK_FUNCS.
12178+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_clear_options" >&5
12179+
$as_echo_n "checking for SSL_clear_options... " >&6; }
12180+
if ${ac_cv_func_ssl_clear_options+:} false; then :
12181+
$as_echo_n "(cached) " >&6
12182+
else
12183+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12184+
/* end confdefs.h. */
12185+
12186+
#include <openssl/ssl.h>
12187+
#include <openssl/bio.h>
12188+
SSL *ssl;
12189+
12190+
int
12191+
main ()
12192+
{
12193+
return SSL_clear_options(ssl, 0);
12194+
;
12195+
return 0;
12196+
}
12197+
_ACEOF
12198+
if ac_fn_c_try_link "$LINENO"; then :
12199+
ac_cv_func_ssl_clear_options=yes
12200+
else
12201+
ac_cv_func_ssl_clear_options=no
12202+
fi
12203+
rm -f core conftest.err conftest.$ac_objext \
12204+
conftest$ac_exeext conftest.$ac_ext
12205+
fi
12206+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_ssl_clear_options" >&5
12207+
$as_echo "$ac_cv_func_ssl_clear_options" >&6; }
12208+
if test $ac_cv_func_ssl_clear_options = yes ; then
12209+
12210+
$as_echo "#define HAVE_SSL_CLEAR_OPTIONS 1" >>confdefs.h
12211+
12212+
fi
1217612213
fi
1217712214

1217812215
if test "$with_pam" = yes ; then

configure.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ if test "$with_openssl" = yes ; then
12091209
AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
12101210
AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
12111211
fi
1212-
AC_CHECK_FUNCS([SSL_clear_options SSL_get_current_compression X509_get_signature_nid])
1212+
AC_CHECK_FUNCS([SSL_get_current_compression X509_get_signature_nid])
12131213
# Functions introduced in OpenSSL 1.1.0. We used to check for
12141214
# OPENSSL_VERSION_NUMBER, but that didn't work with 1.1.0, because LibreSSL
12151215
# defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
@@ -1220,6 +1220,20 @@ if test "$with_openssl" = yes ; then
12201220
# thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
12211221
# function was removed.
12221222
AC_CHECK_FUNCS([CRYPTO_lock])
1223+
# SSL_clear_options is a macro in OpenSSL from 0.9.8 to 1.0.2, and
1224+
# a function from 1.1.0 onwards so we cannot use AC_CHECK_FUNCS.
1225+
AC_CACHE_CHECK([for SSL_clear_options], ac_cv_func_ssl_clear_options,
1226+
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
1227+
#include <openssl/ssl.h>
1228+
#include <openssl/bio.h>
1229+
SSL *ssl;
1230+
],
1231+
[return SSL_clear_options(ssl, 0);])],
1232+
[ac_cv_func_ssl_clear_options=yes],
1233+
[ac_cv_func_ssl_clear_options=no])])
1234+
if test $ac_cv_func_ssl_clear_options = yes ; then
1235+
AC_DEFINE(HAVE_SSL_CLEAR_OPTIONS, 1, [Define to 1 if you have SSL_clear_options()])
1236+
fi
12231237
fi
12241238

12251239
if test "$with_pam" = yes ; then

0 commit comments

Comments
 (0)