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