From 612e42bb6073707924187c044ffd71ecff2607bd Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 16 Jul 2020 10:55:55 +0200 Subject: [PATCH v2] Define OPENSSL_API_COMPAT This avoids deprecation warnings from newer OpenSSL versions (3.0.0 in particular). Discussion: https://www.postgresql.org/message-id/flat/FEF81714-D479-4512-839B-C769D2605F8A%40yesql.se --- configure | 5 ++++- configure.in | 2 ++ src/include/pg_config.h.in | 4 ++++ src/tools/msvc/Solution.pm | 10 +++++++++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 2feff37fe3..00f863fd2d 100755 --- a/configure +++ b/configure @@ -12083,7 +12083,10 @@ fi fi if test "$with_openssl" = yes ; then - if test "$PORTNAME" != "win32"; then + +$as_echo "#define OPENSSL_API_COMPAT 10001" >>confdefs.h + + if test "$PORTNAME" != "win32"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CRYPTO_new_ex_data in -lcrypto" >&5 $as_echo_n "checking for CRYPTO_new_ex_data in -lcrypto... " >&6; } if ${ac_cv_lib_crypto_CRYPTO_new_ex_data+:} false; then : diff --git a/configure.in b/configure.in index 0188c6ff07..c06fec4726 100644 --- a/configure.in +++ b/configure.in @@ -1204,6 +1204,8 @@ fi if test "$with_openssl" = yes ; then dnl Order matters! + AC_DEFINE(OPENSSL_API_COMPAT, [10001], + [Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.]) if test "$PORTNAME" != "win32"; then AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]) AC_CHECK_LIB(ssl, SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]) diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index c199cd46d2..73aa618166 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -749,6 +749,10 @@ /* Define bytes to use libc memset(). */ #undef MEMSET_LOOP_LIMIT +/* Define to the OpenSSL API version in use. This avoids deprecation warnings + from newer OpenSSL versions. */ +#undef OPENSSL_API_COMPAT + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index a13ca6e02e..ba61544911 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -152,6 +152,8 @@ sub GenerateFiles my $package_bugreport; my $package_url; my ($majorver, $minorver); + my $ac_define_openssl_api_compat_found = 0; + my $openssl_api_compat; # Parse configure.in to get version numbers open(my $c, '<', "configure.in") @@ -176,10 +178,15 @@ sub GenerateFiles $majorver = sprintf("%d", $1); $minorver = sprintf("%d", $2 ? $2 : 0); } + elsif (/\bAC_DEFINE\(OPENSSL_API_COMPAT, \[(\d+)\]/) + { + $ac_define_openssl_api_compat_found = 1; + $openssl_api_compat = $1; + } } close($c); confess "Unable to parse configure.in for all variables!" - unless $ac_init_found; + unless $ac_init_found && $ac_define_openssl_api_compat_found; if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h")) { @@ -433,6 +440,7 @@ sub GenerateFiles LOCALE_T_IN_XLOCALE => undef, MAXIMUM_ALIGNOF => 8, MEMSET_LOOP_LIMIT => 1024, + OPENSSL_API_COMPAT => $openssl_api_compat, PACKAGE_BUGREPORT => qq{"$package_bugreport"}, PACKAGE_NAME => qq{"$package_name"}, PACKAGE_STRING => qq{"$package_name $package_version"}, -- 2.27.0