]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Define OPENSSL_API_COMPAT
authorPeter Eisentraut <peter@eisentraut.org>
Sun, 19 Jul 2020 10:14:42 +0000 (12:14 +0200)
committerMichael Paquier <michael@paquier.xyz>
Sat, 24 Jun 2023 11:29:42 +0000 (20:29 +0900)
This avoids deprecation warnings from newer OpenSSL versions (3.0.0 in
particular).

This has been originally applied as 4d3db13 for v14 and newer versions,
but not on the older branches out of caution, and this commit closes the
gap to remove all these deprecation warnings in all the branches still
supported.

OPENSSL_API_COMPAT's value is set based on the oldest version of OpenSSL
supported on a branch: 1.0.1 for Postgres 13 and 0.9.8 for Postgres 11
and 12.

Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/FEF81714-D479-4512-839B-C769D2605F8A@yesql.se
Discussion: https://postgr.es/m/ZJJmOH+hIOSoesux@paquier.xyz
Backpatch-through: 11

configure
configure.in
src/include/pg_config.h.in
src/include/pg_config.h.win32
src/tools/msvc/Solution.pm

index 1577cf7ad37462b0fcd58fc92dc4e324dfd77e9f..dae02c86874edf665eb3ff478446311e9bf26dc5 100755 (executable)
--- a/configure
+++ b/configure
 fi
 
 if test "$with_openssl" = yes ; then
-    if test "$PORTNAME" != "win32"; then
+    # Minimum required OpenSSL version is 0.9.8
+
+$as_echo "#define OPENSSL_API_COMPAT 0x00908000L" >>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 :
index 0b44e2119f010b699b9be9db11cbc9aea39fc16f..29de083fe88750d018578f5ae55ac1bbc460a73c 100644 (file)
@@ -1269,6 +1269,9 @@ fi
 
 if test "$with_openssl" = yes ; then
   dnl Order matters!
+  # Minimum required OpenSSL version is 0.9.8
+  AC_DEFINE(OPENSSL_API_COMPAT, [0x00908000L],
+            [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])])
index 912132dbc5b76bca466729784eedcdf67ac99cc6..157b504ea6a7568ed1d0747e367e206d2d3fc94c 100644 (file)
 /* 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
 
index 9510b982160725bbe142c11a3ebb05aadc35175e..7fa151f41b498f72b371837dea6545a2aaabedda 100644 (file)
 /* Define bytes to use libc memset(). */
 #define MEMSET_LOOP_LIMIT 1024
 
+/* Define to the OpenSSL API version in use. This avoids deprecation warnings
+   from newer OpenSSL versions. */
+#define OPENSSL_API_COMPAT 0x00908000L
+
 /* Define to the address where bug reports for this package should be sent. */
 #define PACKAGE_BUGREPORT "pgsql-bugs@postgresql.org"
 
index 984d63f5d770e5f066ed282a9d96fe1fb323c1e1..c823655ed9a1f7faabc4e23c87dd5fe5830a16b9 100644 (file)
@@ -151,6 +151,8 @@ sub GenerateFiles
 {
        my $self = shift;
        my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
+       my $openssl_api_compat;
+       my $ac_define_openssl_api_compat_found = 0;
 
        # Parse configure.in to get version numbers
        open(my $c, '<', "configure.in")
@@ -167,10 +169,15 @@ sub GenerateFiles
                        $self->{numver} = sprintf("%d%04d", $1, $2 ? $2 : 0);
                        $self->{majorver} = sprintf("%d", $1);
                }
+               elsif (/\bAC_DEFINE\(OPENSSL_API_COMPAT, \[([0-9xL]+)\]/)
+               {
+                       $ac_define_openssl_api_compat_found = 1;
+                       $openssl_api_compat = $1;
+               }
        }
        close($c);
        confess "Unable to parse configure.in for all variables!"
-         if ($self->{strver} eq '' || $self->{numver} eq '');
+         if ($self->{strver} eq '' || $self->{numver} eq '' || $ac_define_openssl_api_compat_found == 0);
 
        if (IsNewer("src/include/pg_config_os.h", "src/include/port/win32.h"))
        {
@@ -254,6 +261,7 @@ sub GenerateFiles
                if ($self->{options}->{openssl})
                {
                        print $o "#define USE_OPENSSL 1\n";
+                       print $o "#define OPENSSL_API_COMPAT $openssl_api_compat\n";
 
                        my ($digit1, $digit2, $digit3) = $self->GetOpenSSLVersion();