8000 Merge pull request #155699 from Homebrew/postgreses-patch-for-openssl… · Homebrew/homebrew-core@8960b2f · GitHub
[go: up one dir, main page]

Skip to content

Commit 8960b2f

Browse files
authored
Merge pull request #155699 from Homebrew/postgreses-patch-for-openssl@3.2
postgresql@* libpq: fix compatibility with openssl 3.2
2 parents 52b86f1 + c6e1cea commit 8960b2f

File tree

7 files changed

+702
-49
lines changed

7 files changed

+702
-49
lines changed

Formula/lib/libpq.rb

Lines changed: 101 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ class Libpq < Formula
44
url "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.bz2"
55
sha256 "ce3c4d85d19b0121fe0d3f8ef1fa601f71989e86f8a66f7dc3ad546dd5564fec"
66
license "PostgreSQL"
7+
revision 1
78

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

1314
bottle do
14-
sha256 arm64_sonoma: "49ad6314bad02cc469d16edb472898ac17d0d2d5bc4033391b3d0933db1ab5a3"
15-
sha256 arm64_ventura: "d368cb57bb4f04df6f6ace665a11bc34a2fe9cc39b8d8c337de61b3f937148d0"
16-
sha256 arm64_monterey: "7c96fa78808730ababf21f2c8dd938c9d56b50ea1c6f2362695a3a73ed17d921"
17-
sha256 sonoma: "2ac1c0e20d1e3974e81d7cdc9c6d24bbdcf6e050dd3a60e2ed89f15922f21c4e"
18-
sha256 ventura: "2a43fdee20b343e1c437d8c8cabeb17e0a46ca28c9478ac94d0fca96ae11e5b4"
19-
sha256 monterey: "a80489ca19e00aa6920a9f9e2e30b7378df089a11f8b1dcb86276a9756384255"
20-
sha256 x86_64_linux: "4d099a83019b774f9884bbae34d3c84ac981035c349bcfab661afe879d389280"
15+
sha256 arm64_sonoma: "f0fe09ec0a29c249f03bfaebf204856813c33ab9b57c9dae0674a0291dfcb950"
16+
sha256 arm64_ventura: "d2e232c76f49c91c88d03f39a6fbd98df616399d1302c55198a698f31a7efbc8"
17+
sha256 arm64_monterey: "6661fd55501ecc6680eede20312d20fb591b6df8a7211d0220b5419c173bb1fc"
18+
sha256 sonoma: "742fd801eb1bd4528ccd00c095ef74ace4013641d55f0f88db50045754572e97"
19+
sha256 ventura: "bba9c418969284bfdb7e4630c96ab1f5494250ff8ac542fd926e2c9c113b1849"
20+
sha256 monterey: "d2fb2d1b5b17bba9b15dc6127770dfb865df83d885b143668c9a167ccb80c4ce"
21+
sha256 x86_64_linux: "8493dd42f4d3edbc5f3e7b1ec7fbb2ff5efc4c61a20c28b5bf2662b0321a8376"
2122
end
2223

2324
keg_only "conflicts with postgres formula"
@@ -35,6 +36,11 @@ class Libpq < Formula
3536
depends_on "readline"
3637
end
3738

39+
# Fix compatibility with OpenSSL 3.2
40+
# Remove once merged
41+
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
42+
patch :DATA
43+
3844
def install
3945
system "./configure", "--disable-debug",
4046
"--prefix=#{prefix}",
@@ -87,3 +93,91 @@ def install
8793
assert_equal "Connection to database attempted and failed", shell_output("./libpqtest")
8894
end
8995
end
96+
97+
__END__
98+
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
99+
index e9c86d08df..49dca0cda9 100644
100+
--- a/src/backend/libpq/be-secure-openssl.c
101+
+++ b/src/backend/libpq/be-secure-openssl.c
102+
@@ -844,11 +844,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
103+
* to retry; do we need to adopt their logic for that?
104+
*/
105+
106+
-#ifndef HAVE_BIO_GET_DATA
107+
-#define BIO_get_data(bio) (bio->ptr)
108+
-#define BIO_set_data(bio, data) (bio->ptr = data)
109+
-#endif
110+
-
111+
static BIO_METHOD *my_bio_methods = NULL;
112+
113+
static int
114+
@@ -858,7 +853,7 @@ my_sock_read(BIO *h, char *buf, int size)
115+
116+
if (buf != NULL)
117+
{
118+
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
119+
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
120+
BIO_clear_retry_flags(h);
121+
if (res <= 0)
122+
{
123+
@@ -878,7 +873,7 @@ my_sock_write(BIO *h, const char *buf, int size)
124+
{
125+
int res = 0;
126+
127+
- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
128+
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
129+
BIO_clear_retry_flags(h);
130+
if (res <= 0)
131+
{
132+
@@ -954,7 +949,7 @@ my_SSL_set_fd(Port *port, int fd)
133+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
134+
goto err;
135+
}
136+
- BIO_set_data(bio, port);
137+
+ BIO_set_app_data(bio, port);
138+
139+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
140+
SSL_set_bio(port->ssl, bio, bio);
141+
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
142+
index 390c888c96..b730352b86 100644
143+
--- a/src/interfaces/libpq/fe-secure-openssl.c
144+
+++ b/src/interfaces/libpq/fe-secure-openssl.c
145+
@@ -1830,11 +1830,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
146+
* to retry; do we need to adopt their logic for that?
147+
*/
148+
149+
-#ifndef HAVE_BIO_GET_DATA
150+
-#define BIO_get_data(bio) (bio->ptr)
151+
-#define BIO_set_data(bio, data) (bio->ptr = data)
152+
-#endif
153+
-
154+
static BIO_METHOD *my_bio_methods;
155+
156+
static int
157+
@@ -1842,7 +1837,7 @@ my_sock_read(BIO *h, char *buf, int size)
158+
{
159+
int res;
160+
161+
- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
162+
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
163+
BIO_clear_retry_flags(h);
164+
if (res < 0)
165+
{
166+
@@ -1872,7 +1867,7 @@ my_sock_write(BIO *h, const char *buf, int size)
167+
{
168+
int res;
169+
170+
- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
171+
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
172+
BIO_clear_retry_flags(h);
173+
if (res < 0)
174+
{
175+
@@ -1963,7 +1958,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
176+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
177+
goto err;
178+
}
179+
- BIO_set_data(bio, conn);
180+
+ BIO_set_app_data(bio, conn);
181+
182+
SSL_set_bio(conn->ssl, bio, bio);
183+
BIO_set_fd(bio, fd, BIO_NOCLOSE);

Formula/p/postgresql@11.rb

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ class PostgresqlAT11 < Formula
44
url "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2"
55
sha256 "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"
66
license "PostgreSQL"
7+
revision 1
78

89
bottle do
9-
sha256 arm64_sonoma: "3a8e0f24e7e667923d8a7621dd7739b2124b49e85a1e287b4751ba9b046bc5ab"
10-
sha256 arm64_ventura: "a181708cda06eede952b82c103a81f0d8b103b543330827625b965e091ec2323"
11-
sha256 arm64_monterey: "0748465c7dd9909b5ef03dfe47e428901245bc3059c56473ec700a3fea89f3c4"
12-
sha256 sonoma: "c99a7b5f10cab76e5ea4b7c0e86c220c7ce544cb30c08ae7cc784366aabc15e8"
13-
sha256 ventura: "c9d738f5575ae0931c9cfa545ce40af81b710c5d9201a420a9a1c8c684a4d0b7"
14-
sha256 monterey: "1014b72d07473cf85b9267efc08a1573a584bb32f98a4057119b716e336b4fe6"
15-
sha256 x86_64_linux: "e55ea45e7f80336d72859cb1076f49e2a0ee4748560d46dd7c40d3d79ddfcde7"
10+
sha256 arm64_sonoma: "2a56ef05e144bbb7fa75581220ec03c19b26409385e8e04607c490a315de53cc"
11+
sha256 arm64_ventura: "ea9b6c5caf216c1f670aeac7af0af4aa294096fa9ce3645b87b689f4776de55f"
12+
sha256 arm64_monterey: "44ad100d072df24959e8c8cbf111a6995beb9542bab9e200cab0ff2703d1594e"
13+
sha256 sonoma: "952beb2f8aa1c1c9c4df4d64ab29951cc3b3fa15d2855f2f97d9d6e78c34579e"
14+
sha256 ventura: "05eac68a15e43c5acfa7bcb90dfda69a24651a69b540bab0b8df543d015242e3"
15+
sha256 monterey: "01c2aadb78c4dbc52e6ff83c92d1ea134c4945c59ad97b1a57741a0dd6222c32"
16+
sha256 x86_64_linux: "15384b5b5a2f147ab820f73c24802d6812338cc8949aae864bcbad51af6e1cf3"
1617
end
1718

1819
keg_only :versioned_formula
@@ -36,6 +37,10 @@ class PostgresqlAT11 < Formula
3637
depends_on "util-linux"
3738
end
3839

40+
# Fix compatibility with OpenSSL 3.2
41+
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
42+
patch :DATA
43+
3944
def install
4045
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
4146
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@3"].opt_include} -I#{Formula["readline"].opt_include}"
@@ -133,3 +138,91 @@ def caveats
133138
assert_equal opt_lib.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
134139
end
135140
end
141+
142+
__END__
143+
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
144+
index e307bfea82..255f5d61b7 100644
145+
--- a/src/backend/libpq/be-secure-openssl.c
146+
+++ b/src/backend/libpq/be-secure-openssl.c
147+
@@ -663,11 +663,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
148+
* to retry; do we need to adopt their logic for that?
149+
*/
150+
151+
-#ifndef HAVE_BIO_GET_DATA
152+
-#define BIO_get_data(bio) (bio->ptr)
153+
-#define BIO_set_data(bio, data) (bio->ptr = data)
154+
-#endif
155+
-
156+
static BIO_METHOD *my_bio_m F987 ethods = NULL;
157+
158+
static int
159+
@@ -677,7 +672,7 @@ my_sock_read(BIO *h, char *buf, int size)
160+
161+
if (buf != NULL)
162+
{
163+
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
164+
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
165+
BIO_clear_retry_flags(h);
166+
if (res <= 0)
167+
{
168+
@@ -697,7 +692,7 @@ my_sock_write(BIO *h, const char *buf, int size)
169+
{
170+
int res = 0;
171+
172+
- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
173+
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
174+
BIO_clear_retry_flags(h);
175+
if (res <= 0)
176+
{
177+
@@ -773,7 +768,7 @@ my_SSL_set_fd(Port *port, int fd)
178+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
179+
goto err;
180+
}
181+
- BIO_set_data(bio, port);
182+
+ BIO_set_app_data(bio, port);
183+
184+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
185+
SSL_set_bio(port->ssl, bio, bio);
186+
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
187+
index 55e231e849..bf091c0ec5 100644
188+
--- a/src/interfaces/libpq/fe-secure-openssl.c
189+
+++ b/src/interfaces/libpq/fe-secure-openssl.c
190+
@@ -1491,11 +1491,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
191+
* to retry; do we need to adopt their logic for that?
192+
*/
193+
194+
-#ifndef HAVE_BIO_GET_DATA
195+
-#define BIO_get_data(bio) (bio->ptr)
196+
-#define BIO_set_data(bio, data) (bio->ptr = data)
197+
-#endif
198+
-
199+
static BIO_METHOD *my_bio_methods;
200+
201+
static int
202+
@@ -1503,7 +1498,7 @@ my_sock_read(BIO *h, char *buf, int size)
203+
{
204+
int res;
205+
206+
- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
207+
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
208+
BIO_clear_retry_flags(h);
209+
if (res < 0)
210+
{
211+
@@ -1533,7 +1528,7 @@ my_sock_write(BIO *h, const char *buf, int size)
212+
{
213+
int res;
214+
215+
- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
216+
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
217+
BIO_clear_retry_flags(h);
218+
if (res <= 0)
219+
{
220+
@@ -1624,7 +1619,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
221+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
222+
goto err;
223+
}
224+
- BIO_set_data(bio, conn);
225+
+ BIO_set_app_data(bio, conn);
226+
227+
SSL_set_bio(conn->ssl, bio, bio);
228+
BIO_set_fd(bio, fd, BIO_NOCLOSE);

Formula/p/postgresql@12.rb

Lines changed: 100 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ class PostgresqlAT12 < Formula
44
url "https://ftp.postgresql.org/pub/source/v12.17/postgresql-12.17.tar.bz2"
55
sha256 "93e8e1b23981d5f03c6c5763f77b28184c1ce4db7194fa466e2edb65d9c1c5f6"
66
license "PostgreSQL"
7+
revision 1
78

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

1314
bottle do
14-
sha256 arm64_sonoma: "abfbac825998787cf946bbae4694fc10969271a6947b1c60cba810f2b871e55e"
15-
sha256 arm64_ventura: "97a10f3fb50ea3efce33d2f5b19fce1a86a4b91d9241797d935f2b0506da7165"
16-
sha256 arm64_monterey: "92e8177be63bdabf2b06d2809826421506d5d372dde82ba4cf62d1d78a75cfbb"
17-
sha256 sonoma: "251ee2de436d106f96af23cc900b5c17cbbc1caf872681bacbb099e66b589607"
18-
sha256 ventura: "0500800bf9fd10ac0961fcf70b18ea891e965959187a2417cbdbdeb9c4a75d5f"
19-
sha256 monterey: "fafbbdf60cf69f62c82d6ee7d777631a4c2aa86317831c417b127eb3968ff458"
20-
sha256 x86_64_linux: "32ada351e37ab4fc52ffbefa2e46d5041b288d1bd4a932b00a1f29bdcf75d0e2"
15+
sha256 arm64_sonoma: "9c5284f3271131f8294a8c4b15349be934d6edc6042f210bcaf773654f440398"
16+
sha256 arm64_ventura: "2458797e276a53096709630ec249ed8b39d98543599e6f2d3ec295c57f3409b3"
17+
sha256 arm64_monterey: "ab8d3b5d1ab5d978a34c4d1482a33d4dc247675ae932163083909e43fb1a2e93"
18+
sha256 sonoma: "204b96b4c02fb3bb5d1257cb72c3a107098654662f5e0490a617c0b9bf850da5"
19+
sha256 ventura: "e20f2bc7fb09fefdd06dba17fe28b2ac8d8f3eee14414f341415e821bb69ed28"
20+
sha256 monterey: "236accf62979760df54300598ca2c6aa0a44645e0e34db92abfdd998bfe5626f"
21+
sha256 x86_64_linux: "bf43a82ed8cc9423b2793a66e7a6ef27d40cd546420895b886203bc0cf38fec3"
2122
end
2223

2324
keg_only :versioned_formula
@@ -45,6 +46,11 @@ class PostgresqlAT12 < Formula
4546
depends_on "util-linux"
4647
end
4748

49+
# Fix compatibility with OpenSSL 3.2
50+
# Remove once merged
51+
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
52+
patch :DATA
53+
4854
def install
4955
ENV.delete "PKG_CONFIG_LIBDIR" if MacOS.version == :catalina
5056
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
@@ -183,3 +189,90 @@ def caveats
183189
assert_equal (opt_include/"postgresql/server").to_s, shell_output("#{bin}/pg_config --includedir-server").chomp
184190
end
185191
end
192+
193+
__END__
194+
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
195+
index b0a1f7258a..43c0d100d8 100644
196+
--- a/src/backend/libpq/be-secure-openssl.c
197+
+++ b/src/backend/libpq/be-secure-openssl.c
198+
@@ -699,10 +699,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
199+
* to retry; do we need to adopt their logic for that?
200+
*/
201+
202+
-#ifndef HAVE_BIO_GET_DATA
203+
-#define BIO_get_data(bio) (bio->ptr)
204+
-#define BIO_set_data(bio, data) (bio->ptr = data)
205+
-#endif
206+
207+
static BIO_METHOD *my_bio_methods = NULL;
208+
209+
@@ -713,7 +709,7 @@ my_sock_read(BIO *h, char *buf, int size)
210+
211+
if (buf != NULL)
212+
{
213+
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
214+
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
215+
BIO_clear_retry_flags(h);
216+
if (res <= 0)
217+
{
218+
@@ -733,7 +729,7 @@ my_sock_write(BIO *h, const char *buf, int size)
219+
{
220+
int res = 0;
221+
222+
- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
223+
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
224+
BIO_clear_retry_flags(h);
225+
if (res <= 0)
226+
{
227+
@@ -809,7 +805,7 @@ my_SSL_set_fd(Port *port, int fd)
228+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
229+
goto err;
230+
}
231+
- BIO_set_data(bio, port);
232+
+ BIO_set_app_data(bio, port);
233+
234+
BIO_set_fd(bio, fd, BIO_NOCLOSE);
235+
SSL_set_bio(port->ssl, bio, bio);
236+
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
237+
index 5948a37983..3e085f8e88 100644
238+
--- a/src/interfaces/libpq/fe-secure-openssl.c
239+
+++ b/src/interfaces/libpq/fe-secure-openssl.c
240+
@@ -1491,11 +1491,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
241+
* to retry; do we need to adopt their logic for that?
242+
*/
243+
244+
-#ifndef HAVE_BIO_GET_DATA
245+
-#define BIO_get_data(bio) (bio->ptr)
246+
-#define BIO_set_data(bio, data) (bio->ptr = data)
247+
-#endif
248+
-
249+
static BIO_METHOD *my_bio_methods;
250+
251+
static int
252+
@@ -1503,7 +1498,7 @@ my_sock_read(BIO *h, char *buf, int size)
253+
{
254+
int res;
255+
256+
- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
257+
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
258+
BIO_clear_retry_flags(h);
259+
if (res < 0)
260+
{
261+
@@ -1533,7 +1528,7 @@ my_sock_write(BIO *h, const char *buf, int size)
262+
{
263+
int res;
264+
265+
- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
266+
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
267+
BIO_clear_retry_flags(h);
268+
if (res < 0)
269+
{
270+
@@ -1624,7 +1619,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
271+
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
272+
goto err;
273+
}
274+
- BIO_set_data(bio, conn);
275+
+ BIO_set_app_data(bio, conn);
276+
277+
SSL_set_bio(conn->ssl, bio, bio);
278+
BIO_set_fd(bio, fd, BIO_NOCLOSE);

0 commit comments

Comments
 (0)
0