From 99ca66df415be42c55505c0cf62bd876c21dcec0 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Sat, 8 Aug 2015 04:41:00 +0200
Subject: [PATCH] WIP NO_CRYPT

---
 gnu/lib/Makefile          |  4 +++-
 lib/Makefile              |  6 +++++-
 lib/libfetch/common.c     |  1 +
 lib/libldns/Makefile      |  6 ++++++
 lib/libldns/ldns/common.h |  1 -
 lib/libldns/ldns/config.h | 10 +++++-----
 lib/libradius/radlib.c    |  9 +++++++--
 lib/libtelnet/Makefile    |  2 +-
 lib/pam_module/Makefile   |  6 +++++-
 9 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile
index f107780..26b9095 100644
--- a/gnu/lib/Makefile
+++ b/gnu/lib/Makefile
@@ -7,10 +7,12 @@ SUBDIR= gcc50
 SUBDIR+= gcc47
 .endif
 
+.if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
 SUBDIR+= libcryptsetup
+SUBDIR+= libluks
+.endif
 SUBDIR+= libdevmapper
 SUBDIR+= libdialog
-SUBDIR+= libluks
 SUBDIR+= liblvm
 
 SUBDIR_ORDERED=
diff --git a/lib/Makefile b/lib/Makefile
index 367553e..a13d34b 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -81,7 +81,7 @@ SUBDIR=	${SUBDIR_ORDERED} \
 	${_libsmdb} \
 	${_libsmutil} \
 	libstand \
-	libtcplay \
+	${_libtcplay} \
 	libtelnet \
 	libusb \
 	libu4bhid \
@@ -92,6 +92,10 @@ SUBDIR=	${SUBDIR_ORDERED} \
 	libz \
 	pam_module
 
+.if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
+_libtcplay=	libtcplay
+.endif
+
 .if !defined(NO_LIBC_R)
 _libc_r=	libc_r
 .endif
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 4d63eda..47224bc 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -887,6 +887,7 @@ fetch_ssl(conn_t *conn, const struct url *URL, int verbose)
 	return (0);
 #else
 	(void)conn;
+	(void)URL;
 	(void)verbose;
 	fprintf(stderr, "SSL support disabled\n");
 	return (-1);
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index 25def32..ee2e16c 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -48,6 +48,12 @@ INCS+=		buffer.h \
 
 CFLAGS+= 	-I${.CURDIR} -I${LDNS}
 
+.if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
+CFLAGS+=	-DLDNS_BUILD_CONFIG_HAVE_SSL=1 \
+		-DHAVE_OPENSSL_ERR_H=1 -DHAVE_OPENSSL_RAND_H=1 \
+		-DHAVE_OPENSSL_SSH_H=1 -DHAVE_SSL=1 -DUSE_ECDSA=1
+.endif
+
 WARNS?=		2
 
 .include <bsd.lib.mk>
diff --git a/lib/libldns/ldns/common.h b/lib/libldns/ldns/common.h
index 0767bc6..18f9b02 100644
--- a/lib/libldns/ldns/common.h
+++ b/lib/libldns/ldns/common.h
@@ -19,7 +19,6 @@
  * The build configuration that is used in the distributed headers,
  * as detected and determined by the auto configure script.
  */
-#define LDNS_BUILD_CONFIG_HAVE_SSL         1
 #define LDNS_BUILD_CONFIG_HAVE_INTTYPES_H  1
 #define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT 1
 #define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED 1
diff --git a/lib/libldns/ldns/config.h b/lib/libldns/ldns/config.h
index ec8bb7b..8839555 100644
--- a/lib/libldns/ldns/config.h
+++ b/lib/libldns/ldns/config.h
@@ -155,13 +155,13 @@
 /* #undef HAVE_NET_IF_H */
 
 /* Define to 1 if you have the <openssl/err.h> header file. */
-#define HAVE_OPENSSL_ERR_H 1
+/* #undef HAVE_OPENSSL_ERR_H */
 
 /* Define to 1 if you have the <openssl/rand.h> header file. */
-#define HAVE_OPENSSL_RAND_H 1
+/* #undef HAVE_OPENSSL_RAND_H */
 
 /* Define to 1 if you have the <openssl/ssl.h> header file. */
-#define HAVE_OPENSSL_SSL_H 1
+/* #undef HAVE_OPENSSL_SSL_H */
 
 /* Define to 1 if you have the <pcap.h> header file. */
 /* #undef HAVE_PCAP_H */
@@ -183,7 +183,7 @@
 #define HAVE_SNPRINTF 1
 
 /* Define if you have the SSL libraries installed. */
-#define HAVE_SSL /**/
+/* #undef HAVE_SSL */
 
 /* Define to 1 if you have the <stdarg.h> header file. */
 #define HAVE_STDARG_H 1
@@ -298,7 +298,7 @@
 #define SYSCONFDIR sysconfdir
 
 /* Define this to enable ECDSA support. */
-#define USE_ECDSA 1
+/* #undef USE_ECDSA */
 
 /* Define this to enable GOST support. */
 /* #undef USE_GOST */
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index 7a82373..280b5a1 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -152,10 +152,10 @@ insert_request_authenticator(struct rad_handle *h, int resp)
 	MD5Final(&h->out[POS_AUTH], &ctx);
 }
 
+#ifdef WITH_SSL
 static void
 insert_message_authenticator(struct rad_handle *h, int resp)
 {
-#ifdef WITH_SSL
 	u_char md[EVP_MAX_MD_SIZE];
 	u_int md_len;
 	const struct rad_server *srvp;
@@ -177,8 +177,13 @@ insert_message_authenticator(struct rad_handle *h, int resp)
 		HMAC_cleanup(&ctx);
 		memcpy(&h->out[h->authentic_pos + 2], md, md_len);
 	}
-#endif
 }
+#else
+static void
+insert_message_authenticator(__unused struct rad_handle *h, __unused int resp)
+{
+}
+#endif
 
 /*
  * Return true if the current response is valid for a request to the
diff --git a/lib/libtelnet/Makefile b/lib/libtelnet/Makefile
index 3256a7d..156043d 100644
--- a/lib/libtelnet/Makefile
+++ b/lib/libtelnet/Makefile
@@ -10,7 +10,7 @@ SRCS=		genget.c getent.c misc.c
 
 WARNS?=		2
 
-.if !defined(NO_OPENSSL)
+.if !defined(NO_CRYPT) && !defined(NO_OPENSSL)
 SRCS+=		encrypt.c auth.c enc_des.c sra.c pk.c
 CFLAGS+=	-DENCRYPTION -DAUTHENTICATION -DSRA
 .endif
diff --git a/lib/pam_module/Makefile b/lib/pam_module/Makefile
index b5196f9..12b8d9a 100644
--- a/lib/pam_module/Makefile
+++ b/lib/pam_module/Makefile
@@ -19,8 +19,12 @@ SUBDIR=	pam_chroot \
 	pam_rootok \
 	pam_securetty \
 	pam_self \
-	pam_ssh \
+	${_pam_ssh} \
 	pam_tacplus \
 	pam_unix
 
+.if !defined(NO_CRYPT) && !defined(NO_OPENSSH)
+_pam_ssh=	pam_ssh
+.endif
+
 .include <bsd.subdir.mk>
-- 
2.4.5

