contrib/sslinfo needs a fix too to make hamerkop happy.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 7 Nov 2021 16:33:53 +0000 (11:33 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 7 Nov 2021 16:33:53 +0000 (11:33 -0500)
Re-ordering the #include's is a bit problematic here because
libpq/libpq-be.h needs to include <openssl/ssl.h>.  Instead,
let's #undef the unwanted macro after all the #includes.
This is definitely uglier than the other way, but it should
work despite possible future header rearrangements.

(A look at the openssl headers indicates that X509_NAME is the
only conflicting symbol that we use.)

In passing, remove a related but long-incorrect comment in
pg_backup_archiver.h.

Discussion: https://postgr.es/m/1051867.1635720347@sss.pgh.pa.us

contrib/sslinfo/sslinfo.c
src/bin/pg_dump/pg_backup_archiver.h

index 30cae0bb985ee46ea79ce7c9e53aadd5c6e96aef..5fd46b9874138d407bc97cbff627153b4a336162 100644 (file)
 #include "miscadmin.h"
 #include "utils/builtins.h"
 
+/*
+ * On Windows, <wincrypt.h> includes a #define for X509_NAME, which breaks our
+ * ability to use OpenSSL's version of that symbol if <wincrypt.h> is pulled
+ * in after <openssl/ssl.h> ... and, at least on some builds, it is.  We
+ * can't reliably fix that by re-ordering #includes, because libpq/libpq-be.h
+ * #includes <openssl/ssl.h>.  Instead, just zap the #define again here.
+ */
+#ifdef X509_NAME
+#undef X509_NAME
+#endif
+
 PG_MODULE_MAGIC;
 
 static Datum X509_NAME_field_to_text(X509_NAME *name, text *fieldName);
index 91060944f1fabdb866ee10cd95b1aca5fb22e54c..540d4f6a83300e2bf2a3febd3cb8e2b7adcc3f28 100644 (file)
 
 #define LOBBUFSIZE 16384
 
-/*
- * Note: zlib.h must be included *after* libpq-fe.h, because the latter may
- * include ssl.h, which has a naming conflict with zlib.h.
- */
 #ifdef HAVE_LIBZ
 #include <zlib.h>
 #define GZCLOSE(fh) gzclose(fh)