Blame SOURCES/bind-9.14-config-pkcs11.patch

b7523e
From e6ab9c67f0a14adc23c1067e03a106da1b1651b7 Mon Sep 17 00:00:00 2001
b7523e
From: Petr Mensik <pemensik@redhat.com>
b7523e
Date: Fri, 18 Oct 2019 21:30:52 +0200
b7523e
Subject: [PATCH] Move USE_PKCS11 and USE_OPENSSL out of config.h
b7523e
b7523e
Building two variants with the same common code requires to unset
b7523e
USE_PKCS11 on part of build. That is not possible with config.h value.
b7523e
Move it as normal define to CDEFINES.
b7523e
---
b7523e
 bin/confgen/Makefile.in |  2 +-
b7523e
 configure.ac            |  8 ++++++--
b7523e
 lib/dns/dst_internal.h  | 12 +++++++++---
b7523e
 3 files changed, 16 insertions(+), 6 deletions(-)
b7523e
b7523e
diff --git a/bin/confgen/Makefile.in b/bin/confgen/Makefile.in
b7523e
index 1b7512d..c126bf3 100644
b7523e
--- a/bin/confgen/Makefile.in
b7523e
+++ b/bin/confgen/Makefile.in
b7523e
@@ -22,7 +22,7 @@ VERSION=@BIND9_VERSION@
b7523e
 CINCLUDES = -I${srcdir}/include ${ISC_INCLUDES} ${ISCCC_INCLUDES} \
b7523e
 	${ISCCFG_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES}
b7523e
 
b7523e
-CDEFINES =
b7523e
+CDEFINES = @USE_PKCS11@
b7523e
 CWARNINGS =
b7523e
 
b7523e
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
b7523e
diff --git a/configure.ac b/configure.ac
b7523e
index f5483fe..08a7d8a 100644
b7523e
--- a/configure.ac
b7523e
+++ b/configure.ac
b7523e
@@ -935,10 +935,14 @@ AC_SUBST([PKCS11_TEST])
b7523e
 AC_SUBST([PKCS11_TOOLS])
b7523e
 AC_SUBST([PKCS11_MANS])
b7523e
 
b7523e
+USE_PKCS11='-DUSE_PKCS11=0'
b7523e
+USE_OPENSSL='-DUSE_OPENSSL=0'
b7523e
 AC_SUBST([CRYPTO])
b7523e
 AS_CASE([$CRYPTO],
b7523e
-	[pkcs11],[AC_DEFINE([USE_PKCS11], [1], [define if PKCS11 is used for Public-Key Cryptography])],
b7523e
-	[AC_DEFINE([USE_OPENSSL], [1], [define if OpenSSL is used for Public-Key Cryptography])])
b7523e
+	[pkcs11],[USE_PKCS11='-DUSE_PKCS11=1'],
b7523e
+	[USE_OPENSSL='-DUSE_OPENSSL=1'])
b7523e
+AC_SUBST(USE_PKCS11)
b7523e
+AC_SUBST(USE_OPENSSL)
b7523e
 
b7523e
 # preparation for automake
b7523e
 # AM_CONDITIONAL([PKCS11_TOOLS], [test "$with_native_pkcs11" = "yes"])
b7523e
diff --git a/lib/dns/dst_internal.h b/lib/dns/dst_internal.h
b7523e
index 2c3b4a3..55e9dc4 100644
b7523e
--- a/lib/dns/dst_internal.h
b7523e
+++ b/lib/dns/dst_internal.h
b7523e
@@ -38,6 +38,13 @@
b7523e
 #include <isc/stdtime.h>
b7523e
 #include <isc/types.h>
b7523e
 
b7523e
+#ifndef USE_PKCS11
b7523e
+#define USE_PKCS11 0
b7523e
+#endif
b7523e
+#ifndef USE_OPENSSL
b7523e
+#define USE_OPENSSL (! USE_PKCS11)
b7523e
+#endif
b7523e
+
b7523e
 #if USE_PKCS11
b7523e
 #include <pk11/pk11.h>
b7523e
 #include <pk11/site.h>
b7523e
@@ -116,11 +123,10 @@ struct dst_key {
b7523e
 		void *generic;
b7523e
 		dns_gss_ctx_id_t gssctx;
b7523e
 		DH *dh;
b7523e
-#if USE_OPENSSL
b7523e
-		EVP_PKEY *pkey;
b7523e
-#endif /* if USE_OPENSSL */
b7523e
 #if USE_PKCS11
b7523e
 		pk11_object_t *pkey;
b7523e
+#else
b7523e
+		EVP_PKEY *pkey;
b7523e
 #endif /* if USE_PKCS11 */
b7523e
 		dst_hmac_key_t *hmac_key;
b7523e
 	} keydata; /*%< pointer to key in crypto pkg fmt */
b7523e
-- 
b7523e
2.26.2
b7523e