Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jul 2020 10:07:49 +0000 (UTC)
From:      Alexey Dokuchaev <danfe@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r541400 - in head/security/distcache: . files
Message-ID:  <202007071007.067A7nLe038176@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: danfe
Date: Tue Jul  7 10:07:49 2020
New Revision: 541400
URL: https://svnweb.freebsd.org/changeset/ports/541400

Log:
  - Unbreak the build against contemporary versions of OpenSSL
  - Hoop up a simple test to our framework so we know it works
  
  PR:	236820

Added:
  head/security/distcache/files/patch-ssl_libnalssl_bss__nal.c   (contents, props changed)
Modified:
  head/security/distcache/Makefile
  head/security/distcache/files/patch-ssl__swamp__swamp.c
  head/security/distcache/files/patch-ssl__swamp__swamp.h
  head/security/distcache/files/patch-ssl__swamp__utils.c

Modified: head/security/distcache/Makefile
==============================================================================
--- head/security/distcache/Makefile	Tue Jul  7 10:06:16 2020	(r541399)
+++ head/security/distcache/Makefile	Tue Jul  7 10:07:49 2020	(r541400)
@@ -24,13 +24,11 @@ PORTDOCS=	ANNOUNCE BUGS CHANGES FAQ README
 
 OPTIONS_DEFINE=	DOCS
 
-.include <bsd.port.pre.mk>
+post-patch:
+	@${GREP} -q 'define SSLeay_version' /usr/include/openssl/crypto.h \
+	    && ${REINPLACE_CMD} -e 's,SSLeay_version,OpenSSL_version,' \
+		${WRKSRC}/ssl/configure || :
 
-.if ${SSL_DEFAULT} == base
-BROKEN_FreeBSD_12=	SSL/TLS libraries were missing or unusable
-BROKEN_FreeBSD_13=	SSL/TLS libraries were missing or unusable
-.endif
-
 post-install:
 	# INSTALL_TARGET=install-strip isn't working!  Brute force it
 	@${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/*.so
@@ -39,4 +37,7 @@ post-install-DOCS-on:
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
 	(cd ${WRKSRC} && ${INSTALL_DATA} ${PORTDOCS} ${STAGEDIR}${DOCSDIR})
 
-.include <bsd.port.post.mk>
+do-test:
+	@cd ${WRKSRC} && ${SH} devel/test.sh
+
+.include <bsd.port.mk>

Modified: head/security/distcache/files/patch-ssl__swamp__swamp.c
==============================================================================
--- head/security/distcache/files/patch-ssl__swamp__swamp.c	Tue Jul  7 10:06:16 2020	(r541399)
+++ head/security/distcache/files/patch-ssl__swamp__swamp.c	Tue Jul  7 10:07:49 2020	(r541400)
@@ -1,17 +1,45 @@
---- ssl/swamp/swamp.c.orig	2004-02-19 20:37:33 UTC
+--- ssl/swamp/swamp.c.orig	2004-04-30 12:58:00 UTC
 +++ ssl/swamp/swamp.c
-@@ -104,10 +104,14 @@ static SSL_CTX *ossl_setup_ssl_ctx(const
+@@ -105,10 +105,14 @@ static SSL_CTX *ossl_setup_ssl_ctx(const swamp_config 
  	switch(config->sslmeth) {
  	case SWAMP_SSLMETH_NORMAL:
  		sslmethod = SSLv23_client_method(); break;
-+#ifndef OPENSSL_NO_SSL2
++#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_NO_SSL2)
  	case SWAMP_SSLMETH_SSLv2:
  		sslmethod = SSLv2_client_method(); break;
 +#endif
-+#ifndef OPENSSL_NO_SSL3
++#ifndef OPENSSL_NO_SSL3_METHOD
  	case SWAMP_SSLMETH_SSLv3:
  		sslmethod = SSLv3_client_method(); break;
 +#endif
  	case SWAMP_SSLMETH_TLSv1:
  		sslmethod = TLSv1_client_method(); break;
  	default:
+@@ -151,7 +155,7 @@ static SSL_CTX *ossl_setup_ssl_ctx(const swamp_config 
+ 		fp = NULL;
+ 	}
+ 	if(x509) {
+-		if(!X509_STORE_add_cert(ctx->cert_store, x509))
++		if(!X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), x509))
+ 			return NULL;
+ 		/* Reference counts */
+ 		X509_free(x509);
+@@ -444,13 +448,16 @@ possible_reconnect:
+ 				}
+ 			}
+ 			if(ctx->config->output_sessions) {
++				const unsigned char *session_id;
++				unsigned int session_id_length;
+ 				temp_session = SSL_get1_session(item->ssl);
+ 				/* debug some stuff :-) */
+ 				SYS_fprintf(SYS_stderr, "session-id[conn:%i]:", loop);
+-				for(tmp = 0; tmp < (int)temp_session->session_id_length;
++				session_id = SSL_SESSION_get_id(temp_session, &session_id_length);
++				for(tmp = 0; tmp < session_id_length;
+ 						tmp++)
+ 					SYS_fprintf(SYS_stderr, "%02X",
+-						temp_session->session_id[tmp]);
++						session_id[tmp]);
+ 				SYS_fprintf(SYS_stderr, "\n");
+ 				SSL_SESSION_free(temp_session);
+ 			}

Modified: head/security/distcache/files/patch-ssl__swamp__swamp.h
==============================================================================
--- head/security/distcache/files/patch-ssl__swamp__swamp.h	Tue Jul  7 10:06:16 2020	(r541399)
+++ head/security/distcache/files/patch-ssl__swamp__swamp.h	Tue Jul  7 10:07:49 2020	(r541400)
@@ -1,12 +1,15 @@
---- ssl/swamp/swamp.h.orig	2004-02-17 20:29:34 UTC
+--- ssl/swamp/swamp.h.orig	2004-04-30 12:58:00 UTC
 +++ ssl/swamp/swamp.h
-@@ -161,7 +161,9 @@ char *util_parse_escaped_string(const ch
+@@ -162,8 +162,12 @@ char *util_parse_escaped_string(const char *str_toconv
  
  typedef enum st_swamp_sslmeth {
  	SWAMP_SSLMETH_NORMAL,	/* SSLv23_client_method() */
-+#ifndef OPENSSL_NO_SSL2
++#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_NO_SSL2)
  	SWAMP_SSLMETH_SSLv2,	/* SSLv2_client_method() */
 +#endif
++#ifndef OPENSSL_NO_SSL3_METHOD
  	SWAMP_SSLMETH_SSLv3,	/* SSLv3_client_method() */
++#endif
  	SWAMP_SSLMETH_TLSv1	/* TLSv1_client_method() */
  } swamp_sslmeth;
+ 

Modified: head/security/distcache/files/patch-ssl__swamp__utils.c
==============================================================================
--- head/security/distcache/files/patch-ssl__swamp__utils.c	Tue Jul  7 10:06:16 2020	(r541399)
+++ head/security/distcache/files/patch-ssl__swamp__utils.c	Tue Jul  7 10:07:49 2020	(r541400)
@@ -1,10 +1,10 @@
---- ssl/swamp/utils.c.orig	2004-02-17 20:29:34 UTC
+--- ssl/swamp/utils.c.orig	2004-04-30 12:58:00 UTC
 +++ ssl/swamp/utils.c
-@@ -269,10 +269,14 @@ int util_parse_sslmeth(const char *str_t
+@@ -267,10 +267,14 @@ int util_parse_sslmeth(const char *str_toconvert, swam
  {
  	if(!strcmp(str_toconvert, "normal"))
  		*val = SWAMP_SSLMETH_NORMAL;
-+#ifndef OPENSSL_NO_SSL2
++#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_NO_SSL2)
  	else if(!strcmp(str_toconvert, "sslv2"))
  		*val = SWAMP_SSLMETH_SSLv2;
 +#endif

Added: head/security/distcache/files/patch-ssl_libnalssl_bss__nal.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/security/distcache/files/patch-ssl_libnalssl_bss__nal.c	Tue Jul  7 10:07:49 2020	(r541400)
@@ -0,0 +1,105 @@
+--- ssl/libnalssl/bss_nal.c.orig	2004-05-27 20:54:48 UTC
++++ ssl/libnalssl/bss_nal.c
+@@ -41,26 +41,30 @@ static long NAL_bio_ctrl(BIO *, int, long, void *);
+ static int NAL_bio_new(BIO *);
+ static int NAL_bio_free(BIO *);
+ 
+-static BIO_METHOD NAL_bio_meth = {
+-	BIO_TYPE_BIO,
+-	"NAL_CONNECTION",
+-	NAL_bio_write,
+-	NAL_bio_read,
+-	NAL_bio_puts,
+-	NULL, /* bgets */
+-	NAL_bio_ctrl,
+-	NAL_bio_new,
+-	NAL_bio_free,
+-	NULL /* callback_ctrl */
+-};
++static BIO_METHOD *NAL_bio_meth = NULL;
+ 
++static BIO_METHOD *create_NAL_bio_meth(void)
++{
++	BIO_METHOD *bm = BIO_meth_new(BIO_get_new_index(), "NAL_CONNECTION");
++	BIO_meth_set_write(bm, NAL_bio_write);
++	BIO_meth_set_read(bm, NAL_bio_read);
++	BIO_meth_set_puts(bm, NAL_bio_puts);
++	BIO_meth_set_ctrl(bm, NAL_bio_ctrl);
++	BIO_meth_set_create(bm, NAL_bio_new);
++	BIO_meth_set_destroy(bm, NAL_bio_free);
++	return bm;
++}
++
+ BIO *BIO_new_NAL_CONNECTION(NAL_CONNECTION *c)
+ {
+-	BIO *b = BIO_new(&NAL_bio_meth);
++	if (NAL_bio_meth == NULL)
++		NAL_bio_meth = create_NAL_bio_meth();
++
++	BIO *b = BIO_new(NAL_bio_meth);
+ 	if(!b) return NULL;
+-	b->ptr = c;
+-	b->init = 1;
+-	b->shutdown = 1;
++	BIO_set_data(b, c);
++	BIO_set_init(b, 1);
++	BIO_set_shutdown(b, 1);
+ 	return b;
+ }
+ 
+@@ -69,10 +73,10 @@ static int NAL_bio_new(BIO *b)
+ #ifdef NAL_BIO_DEBUG
+ 	SYS_fprintf(SYS_stdout, "NAL_BIO_DEBUG: NAL_bio_new()\n");
+ #endif
+-	b->init = 0;
+-	b->num = -1;
+-	b->ptr = NULL;
+-	b->flags = 0;
++	BIO_set_init(b, 0);
++	// XXX: b->num = -1;
++	BIO_set_data(b, NULL);
++	BIO_set_flags(b, 0);
+ 	return 1;
+ }
+ 
+@@ -81,8 +85,8 @@ static int NAL_bio_free(BIO *b)
+ #ifdef NAL_BIO_DEBUG
+ 	SYS_fprintf(SYS_stdout, "NAL_BIO_DEBUG: NAL_bio_free()\n");
+ #endif
+-	if(b->shutdown && b->init && b->ptr) {
+-		NAL_CONNECTION *c = b->ptr;
++	if(BIO_get_shutdown(b) && BIO_get_init(b) && BIO_get_data(b)) {
++		NAL_CONNECTION *c = BIO_get_data(b);
+ 		NAL_CONNECTION_free(c);
+ 	}
+ 	return 1;
+@@ -91,7 +95,7 @@ static int NAL_bio_free(BIO *b)
+ static int NAL_bio_write(BIO *b, const char *ptr, int len)
+ {
+ 	unsigned int res;
+-	NAL_CONNECTION *c = (NAL_CONNECTION *)b->ptr;
++	NAL_CONNECTION *c = (NAL_CONNECTION *)BIO_get_data(b);
+ 	NAL_BUFFER *buf = NAL_CONNECTION_get_send(c);
+ #ifdef NAL_BIO_DEBUG
+ 	SYS_fprintf(SYS_stdout, "NAL_BIO_DEBUG: NAL_bio_write(%d)\n", len);
+@@ -109,7 +113,7 @@ static int NAL_bio_write(BIO *b, const char *ptr, int 
+ static int NAL_bio_read(BIO *b, char *ptr, int len)
+ {
+ 	unsigned int res;
+-	NAL_CONNECTION *c = (NAL_CONNECTION *)b->ptr;
++	NAL_CONNECTION *c = (NAL_CONNECTION *)BIO_get_data(b);
+ 	NAL_BUFFER *buf = NAL_CONNECTION_get_read(c);
+ #ifdef NAL_BIO_DEBUG
+ 	SYS_fprintf(SYS_stdout, "NAL_BIO_DEBUG: NAL_bio_read(%d)\n", len);
+@@ -150,9 +154,9 @@ static long NAL_bio_ctrl(BIO *b, int cmd, long num, vo
+ 		return 1;
+ 	/* Commands */
+ 	case BIO_CTRL_GET_CLOSE:
+-		return b->shutdown;
++		return BIO_get_shutdown(b);
+ 	case BIO_CTRL_SET_CLOSE:
+-		b->shutdown = (int)num;
++		BIO_set_shutdown(b, (int)num);
+ 		return 1;
+ 	default:
+ #ifdef NAL_BIO_DEBUG



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007071007.067A7nLe038176>