Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql@* libpq: fix compatibility with openssl 3.2 #155699

Merged
merged 14 commits into from
Nov 28, 2023
Merged
108 changes: 101 additions & 7 deletions Formula/lib/libpq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ class Libpq < Formula
url "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.bz2"
sha256 "ce3c4d85d19b0121fe0d3f8ef1fa601f71989e86f8a66f7dc3ad546dd5564fec"
license "PostgreSQL"
revision 1

livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i)
end

bottle do
sha256 arm64_sonoma: "49ad6314bad02cc469d16edb472898ac17d0d2d5bc4033391b3d0933db1ab5a3"
sha256 arm64_ventura: "d368cb57bb4f04df6f6ace665a11bc34a2fe9cc39b8d8c337de61b3f937148d0"
sha256 arm64_monterey: "7c96fa78808730ababf21f2c8dd938c9d56b50ea1c6f2362695a3a73ed17d921"
sha256 sonoma: "2ac1c0e20d1e3974e81d7cdc9c6d24bbdcf6e050dd3a60e2ed89f15922f21c4e"
sha256 ventura: "2a43fdee20b343e1c437d8c8cabeb17e0a46ca28c9478ac94d0fca96ae11e5b4"
sha256 monterey: "a80489ca19e00aa6920a9f9e2e30b7378df089a11f8b1dcb86276a9756384255"
sha256 x86_64_linux: "4d099a83019b774f9884bbae34d3c84ac981035c349bcfab661afe879d389280"
sha256 arm64_sonoma: "f0fe09ec0a29c249f03bfaebf204856813c33ab9b57c9dae0674a0291dfcb950"
sha256 arm64_ventura: "d2e232c76f49c91c88d03f39a6fbd98df616399d1302c55198a698f31a7efbc8"
sha256 arm64_monterey: "6661fd55501ecc6680eede20312d20fb591b6df8a7211d0220b5419c173bb1fc"
sha256 sonoma: "742fd801eb1bd4528ccd00c095ef74ace4013641d55f0f88db50045754572e97"
sha256 ventura: "bba9c418969284bfdb7e4630c96ab1f5494250ff8ac542fd926e2c9c113b1849"
sha256 monterey: "d2fb2d1b5b17bba9b15dc6127770dfb865df83d885b143668c9a167ccb80c4ce"
sha256 x86_64_linux: "8493dd42f4d3edbc5f3e7b1ec7fbb2ff5efc4c61a20c28b5bf2662b0321a8376"
end

keg_only "conflicts with postgres formula"
Expand All @@ -35,6 +36,11 @@ class Libpq < Formula
depends_on "readline"
end

# Fix compatibility with OpenSSL 3.2
# Remove once merged
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
patch :DATA

def install
system "./configure", "--disable-debug",
"--prefix=#{prefix}",
Expand Down Expand Up @@ -87,3 +93,91 @@ def install
assert_equal "Connection to database attempted and failed", shell_output("./libpqtest")
end
end

__END__
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index e9c86d08df..49dca0cda9 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -844,11 +844,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
-
static BIO_METHOD *my_bio_methods = NULL;

static int
@@ -858,7 +853,7 @@ my_sock_read(BIO *h, char *buf, int size)

if (buf != NULL)
{
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -878,7 +873,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res = 0;

- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -954,7 +949,7 @@ my_SSL_set_fd(Port *port, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, port);
+ BIO_set_app_data(bio, port);

BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(port->ssl, bio, bio);
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 390c888c96..b730352b86 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -1830,11 +1830,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
-
static BIO_METHOD *my_bio_methods;

static int
@@ -1842,7 +1837,7 @@ my_sock_read(BIO *h, char *buf, int size)
{
int res;

- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1872,7 +1867,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res;

- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1963,7 +1958,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, conn);
+ BIO_set_app_data(bio, conn);

SSL_set_bio(conn->ssl, bio, bio);
BIO_set_fd(bio, fd, BIO_NOCLOSE);
107 changes: 100 additions & 7 deletions Formula/p/postgresql@11.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ class PostgresqlAT11 < Formula
url "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2"
sha256 "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"
license "PostgreSQL"
revision 1

bottle do
sha256 arm64_sonoma: "3a8e0f24e7e667923d8a7621dd7739b2124b49e85a1e287b4751ba9b046bc5ab"
sha256 arm64_ventura: "a181708cda06eede952b82c103a81f0d8b103b543330827625b965e091ec2323"
sha256 arm64_monterey: "0748465c7dd9909b5ef03dfe47e428901245bc3059c56473ec700a3fea89f3c4"
sha256 sonoma: "c99a7b5f10cab76e5ea4b7c0e86c220c7ce544cb30c08ae7cc784366aabc15e8"
sha256 ventura: "c9d738f5575ae0931c9cfa545ce40af81b710c5d9201a420a9a1c8c684a4d0b7"
sha256 monterey: "1014b72d07473cf85b9267efc08a1573a584bb32f98a4057119b716e336b4fe6"
sha256 x86_64_linux: "e55ea45e7f80336d72859cb1076f49e2a0ee4748560d46dd7c40d3d79ddfcde7"
sha256 arm64_sonoma: "2a56ef05e144bbb7fa75581220ec03c19b26409385e8e04607c490a315de53cc"
sha256 arm64_ventura: "ea9b6c5caf216c1f670aeac7af0af4aa294096fa9ce3645b87b689f4776de55f"
sha256 arm64_monterey: "44ad100d072df24959e8c8cbf111a6995beb9542bab9e200cab0ff2703d1594e"
sha256 sonoma: "952beb2f8aa1c1c9c4df4d64ab29951cc3b3fa15d2855f2f97d9d6e78c34579e"
sha256 ventura: "05eac68a15e43c5acfa7bcb90dfda69a24651a69b540bab0b8df543d015242e3"
sha256 monterey: "01c2aadb78c4dbc52e6ff83c92d1ea134c4945c59ad97b1a57741a0dd6222c32"
sha256 x86_64_linux: "15384b5b5a2f147ab820f73c24802d6812338cc8949aae864bcbad51af6e1cf3"
end

keg_only :versioned_formula
Expand All @@ -36,6 +37,10 @@ class PostgresqlAT11 < Formula
depends_on "util-linux"
end

# Fix compatibility with OpenSSL 3.2
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
patch :DATA

def install
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@3"].opt_include} -I#{Formula["readline"].opt_include}"
Expand Down Expand Up @@ -133,3 +138,91 @@ def caveats
assert_equal opt_lib.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
end
end

__END__
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index e307bfea82..255f5d61b7 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -663,11 +663,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
-
static BIO_METHOD *my_bio_methods = NULL;

static int
@@ -677,7 +672,7 @@ my_sock_read(BIO *h, char *buf, int size)

if (buf != NULL)
{
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -697,7 +692,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res = 0;

- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -773,7 +768,7 @@ my_SSL_set_fd(Port *port, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, port);
+ BIO_set_app_data(bio, port);

BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(port->ssl, bio, bio);
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 55e231e849..bf091c0ec5 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -1491,11 +1491,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
-
static BIO_METHOD *my_bio_methods;

static int
@@ -1503,7 +1498,7 @@ my_sock_read(BIO *h, char *buf, int size)
{
int res;

- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1533,7 +1528,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res;

- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -1624,7 +1619,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, conn);
+ BIO_set_app_data(bio, conn);

SSL_set_bio(conn->ssl, bio, bio);
BIO_set_fd(bio, fd, BIO_NOCLOSE);
107 changes: 100 additions & 7 deletions Formula/p/postgresql@12.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ class PostgresqlAT12 < Formula
url "https://ftp.postgresql.org/pub/source/v12.17/postgresql-12.17.tar.bz2"
sha256 "93e8e1b23981d5f03c6c5763f77b28184c1ce4db7194fa466e2edb65d9c1c5f6"
license "PostgreSQL"
revision 1

livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(12(?:\.\d+)+)/?["' >]}i)
end

bottle do
sha256 arm64_sonoma: "abfbac825998787cf946bbae4694fc10969271a6947b1c60cba810f2b871e55e"
sha256 arm64_ventura: "97a10f3fb50ea3efce33d2f5b19fce1a86a4b91d9241797d935f2b0506da7165"
sha256 arm64_monterey: "92e8177be63bdabf2b06d2809826421506d5d372dde82ba4cf62d1d78a75cfbb"
sha256 sonoma: "251ee2de436d106f96af23cc900b5c17cbbc1caf872681bacbb099e66b589607"
sha256 ventura: "0500800bf9fd10ac0961fcf70b18ea891e965959187a2417cbdbdeb9c4a75d5f"
sha256 monterey: "fafbbdf60cf69f62c82d6ee7d777631a4c2aa86317831c417b127eb3968ff458"
sha256 x86_64_linux: "32ada351e37ab4fc52ffbefa2e46d5041b288d1bd4a932b00a1f29bdcf75d0e2"
sha256 arm64_sonoma: "9c5284f3271131f8294a8c4b15349be934d6edc6042f210bcaf773654f440398"
sha256 arm64_ventura: "2458797e276a53096709630ec249ed8b39d98543599e6f2d3ec295c57f3409b3"
sha256 arm64_monterey: "ab8d3b5d1ab5d978a34c4d1482a33d4dc247675ae932163083909e43fb1a2e93"
sha256 sonoma: "204b96b4c02fb3bb5d1257cb72c3a107098654662f5e0490a617c0b9bf850da5"
sha256 ventura: "e20f2bc7fb09fefdd06dba17fe28b2ac8d8f3eee14414f341415e821bb69ed28"
sha256 monterey: "236accf62979760df54300598ca2c6aa0a44645e0e34db92abfdd998bfe5626f"
sha256 x86_64_linux: "bf43a82ed8cc9423b2793a66e7a6ef27d40cd546420895b886203bc0cf38fec3"
end

keg_only :versioned_formula
Expand Down Expand Up @@ -45,6 +46,11 @@ class PostgresqlAT12 < Formula
depends_on "util-linux"
end

# Fix compatibility with OpenSSL 3.2
# Remove once merged
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
patch :DATA

def install
ENV.delete "PKG_CONFIG_LIBDIR" if MacOS.version == :catalina
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
Expand Down Expand Up @@ -183,3 +189,90 @@ def caveats
assert_equal (opt_include/"postgresql/server").to_s, shell_output("#{bin}/pg_config --includedir-server").chomp
end
end

__END__
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index b0a1f7258a..43c0d100d8 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -699,10 +699,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif

static BIO_METHOD *my_bio_methods = NULL;

@@ -713,7 +709,7 @@ my_sock_read(BIO *h, char *buf, int size)

if (buf != NULL)
{
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -733,7 +729,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res = 0;

- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -809,7 +805,7 @@ my_SSL_set_fd(Port *port, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, port);
+ BIO_set_app_data(bio, port);

BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(port->ssl, bio, bio);
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 5948a37983..3e085f8e88 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -1491,11 +1491,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
* to retry; do we need to adopt their logic for that?
*/

-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
-
static BIO_METHOD *my_bio_methods;

static int
@@ -1503,7 +1498,7 @@ my_sock_read(BIO *h, char *buf, int size)
{
int res;

- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1533,7 +1528,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res;

- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1624,7 +1619,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, conn);
+ BIO_set_app_data(bio, conn);

SSL_set_bio(conn->ssl, bio, bio);
BIO_set_fd(bio, fd, BIO_NOCLOSE);
Loading
Loading