Fix portability to OpenBSD.
authorTatsuo Ishii <ishii@postgresql.org>
Mon, 5 May 2025 03:40:56 +0000 (12:40 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Mon, 5 May 2025 03:40:56 +0000 (12:40 +0900)
- 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
src/include/watchdog/wd_utils.h
src/utils/ssl_utils.c
src/watchdog/wd_escalation.c

index 1eb6797ea67e4e553868facdb5c175c25a730969..5a5811e5c1f9ecaa4d4898a701198829c67b83d1 100644 (file)
@@ -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 <stdarg.h>
 #include <stdlib.h>
 #ifndef FE_PORTS
 #define FE_PORTS
index 414376a16def75089af64e57db57bcbbd19f03d7..757e4a5a8c04f9bedccc4e42f71f1c2c0c6d759d 100644 (file)
@@ -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 <ifaddrs.h>
+#include <pthread.h>
 #include "parser/pg_list.h"
 
 #define WD_NG (0)
index eff2dde952689ca4fcdd3169745b63ce8379ce17..d560dafe700e93a90c99276a98379cf8be7b3824 100644 (file)
@@ -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
index b0d01ecb6f8ae1ddda9ac818a391c2ba6f62422c..147f7a3fb58750867ad3b20268ff1201a624e767 100644 (file)
@@ -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 <unistd.h>
 #include <errno.h>
 
-#ifdef __FreeBSD__
 #include <sys/wait.h>
-#endif
 
 #include "utils/pool_signal.h"
 #include "utils/elog.h"