From 593fb87cb40384e339931d4e1d2f985d3e19e7b4 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Mon, 5 May 2025 12:40:56 +0900 Subject: [PATCH] Fix portability to OpenBSD. - va_list is defined stdarg.h[0] - pthread_t is defined in pthread.h / sys/types.h[1] On OpenBSD sys/types.h doesn't suffice, so include pthread.h. - LibreSSL has removed HMAC_CTX_init(), and has support for HMAC_CTX_new since 2018. I've talked to Theo Buehler of LibreSSL and he said that he'd prefer to simply remove the LIBRESSL_VERSION_NUMBER, but if desired by upstream the LIBRESSL_VERSION_NUMBER should be 0x2070100fL. - WIFEXITED is defined in sys/wait.h[2] Author: Martijn van Duren (pgpool@list.imperialat.at) Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2025-May/004583.html Backpatch-through: v4.2 --- src/include/utils/fe_ports.h | 3 ++- src/include/watchdog/wd_utils.h | 3 ++- src/utils/ssl_utils.c | 6 +++--- src/watchdog/wd_escalation.c | 4 +--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/include/utils/fe_ports.h b/src/include/utils/fe_ports.h index 1eb6797ea..5a5811e5c 100644 --- a/src/include/utils/fe_ports.h +++ b/src/include/utils/fe_ports.h @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2024 PgPool Global Development Group + * Copyright (c) 2003-2025 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -28,6 +28,7 @@ #error "This file is not expected to be compiled for pgpool utilities only" #endif +#include #include #ifndef FE_PORTS #define FE_PORTS diff --git a/src/include/watchdog/wd_utils.h b/src/include/watchdog/wd_utils.h index 414376a16..757e4a5a8 100644 --- a/src/include/watchdog/wd_utils.h +++ b/src/include/watchdog/wd_utils.h @@ -6,7 +6,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2022 PgPool Global Development Group + * Copyright (c) 2003-2025 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -26,6 +26,7 @@ #define WD_UTILS_H #include +#include #include "parser/pg_list.h" #define WD_NG (0) diff --git a/src/utils/ssl_utils.c b/src/utils/ssl_utils.c index eff2dde95..d560dafe7 100644 --- a/src/utils/ssl_utils.c +++ b/src/utils/ssl_utils.c @@ -6,7 +6,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2018 PgPool Global Development Group + * Copyright (c) 2003-2025 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -221,7 +221,7 @@ calculate_hmac_sha256(const char *data, int len, char *buf) unsigned int res_len = WD_AUTH_HASH_LEN; HMAC_CTX *ctx = NULL; -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER)) +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) ctx = HMAC_CTX_new(); HMAC_CTX_reset(ctx); #else @@ -233,7 +233,7 @@ calculate_hmac_sha256(const char *data, int len, char *buf) HMAC_Init_ex(ctx, key, strlen(key), EVP_sha256(), NULL); HMAC_Update(ctx, (unsigned char *) data, len); HMAC_Final(ctx, (unsigned char *) str, &res_len); -#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER)) +#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) HMAC_CTX_reset(ctx); HMAC_CTX_free(ctx); #else diff --git a/src/watchdog/wd_escalation.c b/src/watchdog/wd_escalation.c index b0d01ecb6..147f7a3fb 100644 --- a/src/watchdog/wd_escalation.c +++ b/src/watchdog/wd_escalation.c @@ -5,7 +5,7 @@ * pgpool: a language independent connection pool server for PostgreSQL * written by Tatsuo Ishii * - * Copyright (c) 2003-2020 PgPool Global Development Group + * Copyright (c) 2003-2025 PgPool Global Development Group * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby @@ -27,9 +27,7 @@ #include #include -#ifdef __FreeBSD__ #include -#endif #include "utils/pool_signal.h" #include "utils/elog.h" -- 2.39.5