Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Mar 2020 21:10:09 +0000 (UTC)
From:      Olli Hauer <ohauer@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r529921 - in head/mail/spamd: . files
Message-ID:  <202003302110.02ULA9Vu007751@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ohauer
Date: Mon Mar 30 21:10:08 2020
New Revision: 529921
URL: https://svnweb.freebsd.org/changeset/ports/529921

Log:
  - fix build against openssl 1.x
  - do not add /etc/service entries during install
  - add helper script to add /etc/services entries
  - remove unused pkg-deinstall
  - portlint
  
  PR:		235496
  Submitted by:	Maxime Soule
  Reported by:	many

Added:
  head/mail/spamd/files/add-spamd-to-etc-service   (contents, props changed)
  head/mail/spamd/files/patch-spamd_sync.c   (contents, props changed)
Deleted:
  head/mail/spamd/pkg-deinstall
Modified:
  head/mail/spamd/Makefile
  head/mail/spamd/files/pkg-install.in
  head/mail/spamd/files/pkg-message.in

Modified: head/mail/spamd/Makefile
==============================================================================
--- head/mail/spamd/Makefile	Mon Mar 30 21:06:11 2020	(r529920)
+++ head/mail/spamd/Makefile	Mon Mar 30 21:10:08 2020	(r529921)
@@ -3,7 +3,7 @@
 
 PORTNAME=	spamd
 PORTVERSION=	4.9.1
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	mail
 MASTER_SITES=	SF/freebsdspamd/spamd
 
@@ -12,18 +12,17 @@ COMMENT=	Traps spammers with a very slow smtp-login an
 
 LICENSE=	BSD2CLAUSE
 
-BROKEN_SSL=	openssl
-
-USE_RC_SUBR?=	obspamd obspamlogd
 USES=		ssl
+USE_RC_SUBR?=	obspamd obspamlogd
 
 USERS=		_spamd
 GROUPS=		_spamd
 
 PORTDOCS=	ipfw-spamd.txt spamdb.txt
 
-PLIST_FILES=	%%ETCDIR%%/spamd.conf.sample \
+PLIST_FILES=	etc/spamd/spamd.conf.sample \
 		libexec/spamlogd \
+		sbin/add-spamd-to-etc-service \
 		sbin/spamd-setup \
 		sbin/spamdb \
 		man/man5/spamd.conf.5.gz \
@@ -58,11 +57,6 @@ LDFLAGS+=	-L${OPENSSLLIB}
 
 .include <bsd.port.pre.mk>
 
-.if ${SSL_DEFAULT} == base
-BROKEN_FreeBSD_12=	error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
-BROKEN_FreeBSD_13=	error: variable has incomplete type 'HMAC_CTX' (aka 'struct hmac_ctx_st')
-.endif
-
 do-install:
 .if !defined(CPANEL)
 	${INSTALL_PROGRAM} ${WRKSRC}/spamd/spamd ${STAGEDIR}${PREFIX}/libexec
@@ -82,5 +76,7 @@ do-install:
 
 	@${MKDIR} ${STAGEDIR}${DOCSDIR}
 	${INSTALL_DATA} ${PORTDOCS:S|^|${WRKSRC}/doc/|} ${STAGEDIR}${DOCSDIR}/
+
+	${INSTALL_SCRIPT} ${FILESDIR}/add-spamd-to-etc-service ${STAGEDIR}${PREFIX}/sbin/
 
 .include <bsd.port.post.mk>

Added: head/mail/spamd/files/add-spamd-to-etc-service
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/spamd/files/add-spamd-to-etc-service	Mon Mar 30 21:10:08 2020	(r529921)
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# ex:ts=4:sw=4:noet
+#-*- mode: makefile; tab-width: 4; -*-
+#
+# $FreeBSD$
+
+ETC_SERVICES="/etc/services"
+
+
+check_service() {
+	local SERVICE PORT PROTO COMMENT
+
+	SERVICE=$1
+	PORT=$2
+	PROTO=$3
+	COMMENT=$4
+
+	# check
+	OK=no
+	HAS_SERVICE=no
+	COUNT=1
+	for i in $(grep ^${SERVICE} ${ETC_SERVICES}); do
+		if [ ${COUNT} -eq 1 ] && [ x"${i}" = x"${SERVICE}" ]; then
+			HAS_SERVICE=yes
+			echo " already in ${ETC_SERVICES}: ${SERVICE}"
+
+		elif [ ${COUNT} -eq 2 ] && [ "${HAS_SERVICE}" = "yes" ] && \
+			[ x"${i}" = x"${PORT}/${PROTO}" ]; then
+			OK=yes
+			break
+		fi
+		COUNT=$(( ${COUNT} + 1 ))
+	done
+	# add an entry for SERVICE to /etc/services
+	if [ "${OK}" = "no" ]; then
+		echo "==> add entry \"${SERVICE} ${PORT}/${PROTO}\""
+		(
+			grep -v -e "^${SERVICE}.*${PORT}/${PROTO}" ${ETC_SERVICES}
+			echo "${SERVICE}	${PORT}/${PROTO}   # ${COMMENT}"
+		) >> ${ETC_SERVICES}.new
+		mv ${ETC_SERVICES}.new ${ETC_SERVICES}
+	fi
+}
+
+# always add service entries
+echo "Checking ${ETC_SERVICES} for missing spamd service entries"
+[ ! -f ${ETC_SERVICES} ] && echo "==> cannot find ${ETC_SERVICES} ... => exit" &&  exit 1
+check_service spamd 8025 tcp "spamd(8)"
+check_service spamd-sync 8025 udp "spamd(8) synchronisation"
+check_service spamd-cfg 8026 tcp "spamd(8) configuration"
+

Added: head/mail/spamd/files/patch-spamd_sync.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/spamd/files/patch-spamd_sync.c	Mon Mar 30 21:10:08 2020	(r529921)
@@ -0,0 +1,164 @@
+# PR: 235496
+# patch id: 201721
+#
+--- spamd/sync.c.orig	2010-04-24 10:33:47 UTC
++++ spamd/sync.c
+@@ -53,6 +53,22 @@ extern char   *SHA1_File(const char *, char *);
+ 
+ #include <openssl/hmac.h>
+ 
++#if OPENSSL_VERSION_NUMBER >= 0x10100000L
++# define spamd_hmac_ctx HMAC_CTX *
++# define spamd_hmac_ctx_init(ctx) ctx = HMAC_CTX_new()
++# define spamd_hmac_sha1_init(ctx, key, keylen) HMAC_Init_ex(ctx, key, keylen, EVP_sha1(), NULL)
++# define spamd_hmac_update(ctx, data, datalen) HMAC_Update(ctx, data, datalen)
++# define spamd_hmac_final(ctx, data, datalen) HMAC_Final(ctx, data, datalen)
++# define spamd_hmac_cleanup(ctx) HMAC_CTX_free(ctx)
++#else
++# define spamd_hmac_ctx HMAC_CTX
++# define spamd_hmac_ctx_init(ctx) HMAC_CTX_init(&(ctx))
++# define spamd_hmac_sha1_init(ctx, key, keylen) HMAC_Init_ex(&(ctx), key, keylen, EVP_sha1(), NULL)
++# define spamd_hmac_update(ctx, data, datalen) HMAC_Update(&(ctx), data, datalen)
++# define spamd_hmac_final(ctx, data, datalen) HMAC_Final(&(ctx), data, datalen)
++# define spamd_hmac_cleanup(ctx) HMAC_cleanup(&(ctx))
++#endif
++
+ #include "sdl.h"
+ #include "grey.h"
+ #include "sync.h"
+@@ -439,7 +455,7 @@ sync_update(time_t now, char *helo, char *ip, char *fr
+ 	u_int16_t sglen, fromlen, tolen, helolen, padlen;
+ 	char pad[SPAM_ALIGNBYTES];
+ 	int i = 0;
+-	HMAC_CTX ctx;
++	spamd_hmac_ctx ctx;
+ 	u_int hmac_len;
+ 
+ 	if (debug)
+@@ -455,8 +471,8 @@ sync_update(time_t now, char *helo, char *ip, char *fr
+ 	tolen = strlen(to) + 1;
+ 	helolen = strlen(helo) + 1;
+ 
+-	HMAC_CTX_init(&ctx);
+-	HMAC_Init(&ctx, sync_key, strlen(sync_key), EVP_sha1());
++	spamd_hmac_ctx_init(ctx);
++	spamd_hmac_sha1_init(ctx, sync_key, strlen(sync_key));
+ 
+ 	sglen = sizeof(sg) + fromlen + tolen + helolen;
+ 	padlen = SPAM_ALIGN(sglen) - sglen;
+@@ -468,7 +484,7 @@ sync_update(time_t now, char *helo, char *ip, char *fr
+ 	hdr.sh_length = htons(sizeof(hdr) + sglen + padlen + sizeof(end));
+ 	iov[i].iov_base = &hdr;
+ 	iov[i].iov_len = sizeof(hdr);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	/* Add single SPAM sync greylisting entry */
+@@ -481,27 +497,27 @@ sync_update(time_t now, char *helo, char *ip, char *fr
+ 	sg.sg_helo_length = htons(helolen);
+ 	iov[i].iov_base = &sg;
+ 	iov[i].iov_len = sizeof(sg);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	iov[i].iov_base = from;
+ 	iov[i].iov_len = fromlen;
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	iov[i].iov_base = to;
+ 	iov[i].iov_len = tolen;
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	iov[i].iov_base = helo;
+ 	iov[i].iov_len = helolen;
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	iov[i].iov_base = pad;
+ 	iov[i].iov_len = padlen;
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	/* Add end marker */
+@@ -509,14 +525,14 @@ sync_update(time_t now, char *helo, char *ip, char *fr
+ 	end.st_length = htons(sizeof(end));
+ 	iov[i].iov_base = &end;
+ 	iov[i].iov_len = sizeof(end);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+-	HMAC_Final(&ctx, hdr.sh_hmac, &hmac_len);
++	spamd_hmac_final(ctx, hdr.sh_hmac, &hmac_len);
+ 
+ 	/* Send message to the target hosts */
+ 	sync_send(iov, i);
+-	HMAC_CTX_cleanup(&ctx);
++	spamd_hmac_cleanup(ctx);
+ }
+ 
+ void
+@@ -527,7 +543,7 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16
+ 	struct spam_synctlv_addr sd;
+ 	struct spam_synctlv_hdr end;
+ 	int i = 0;
+-	HMAC_CTX ctx;
++	spamd_hmac_ctx ctx;
+ 	u_int hmac_len;
+ 
+ 	if (debug)
+@@ -537,8 +553,8 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16
+ 	bzero(&hdr, sizeof(hdr));
+ 	bzero(&sd, sizeof(sd));
+ 
+-	HMAC_CTX_init(&ctx);
+-	HMAC_Init(&ctx, sync_key, strlen(sync_key), EVP_sha1());
++	spamd_hmac_ctx_init(ctx);
++	spamd_hmac_sha1_init(ctx, sync_key, strlen(sync_key));
+ 
+ 	/* Add SPAM sync packet header */
+ 	hdr.sh_version = SPAM_SYNC_VERSION;
+@@ -547,7 +563,7 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16
+ 	hdr.sh_length = htons(sizeof(hdr) + sizeof(sd) + sizeof(end));
+ 	iov[i].iov_base = &hdr;
+ 	iov[i].iov_len = sizeof(hdr);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	/* Add single SPAM sync address entry */
+@@ -558,7 +574,7 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16
+ 	sd.sd_ip = inet_addr(ip);
+ 	iov[i].iov_base = &sd;
+ 	iov[i].iov_len = sizeof(sd);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+ 	/* Add end marker */
+@@ -566,14 +582,14 @@ sync_addr(time_t now, time_t expire, char *ip, u_int16
+ 	end.st_length = htons(sizeof(end));
+ 	iov[i].iov_base = &end;
+ 	iov[i].iov_len = sizeof(end);
+-	HMAC_Update(&ctx, iov[i].iov_base, iov[i].iov_len);
++	spamd_hmac_update(ctx, iov[i].iov_base, iov[i].iov_len);
+ 	i++;
+ 
+-	HMAC_Final(&ctx, hdr.sh_hmac, &hmac_len);
++	spamd_hmac_final(ctx, hdr.sh_hmac, &hmac_len);
+ 
+ 	/* Send message to the target hosts */
+ 	sync_send(iov, i);
+-	HMAC_CTX_cleanup(&ctx);
++	spamd_hmac_cleanup(ctx);
+ }
+ 
+ void

Modified: head/mail/spamd/files/pkg-install.in
==============================================================================
--- head/mail/spamd/files/pkg-install.in	Mon Mar 30 21:06:11 2020	(r529920)
+++ head/mail/spamd/files/pkg-install.in	Mon Mar 30 21:10:08 2020	(r529921)
@@ -7,7 +7,6 @@
 
 SPAMDUSER=%%SPAMDUSER%%
 SPAMDGROUP=%%SPAMDGROUP%%
-FILE="/etc/services"
 
 check_db() {
 	DB=/var/db/spamd
@@ -24,48 +23,6 @@ check_db() {
 		fi
 	fi
 }
-
-check_service() {
-	local SERVICE PORT PROTO COMMENT
-
-	SERVICE=$1
-	PORT=$2
-	PROTO=$3
-	COMMENT=$4
-
-	# check
-	OK=no
-	HAS_SERVICE=no
-	COUNT=1
-	for i in $(grep ^${SERVICE} ${FILE}); do
-		if [ ${COUNT} -eq 1 ] && [ x"${i}" = x"${SERVICE}" ]; then
-			HAS_SERVICE=yes
-		elif [ ${COUNT} -eq 2 ] && [ "${HAS_SERVICE}" = "yes" ] && \
-			[ x"${i}" = x"${PORT}/${PROTO}" ]; then
-			OK=yes
-			break
-		fi
-		COUNT=$(( ${COUNT} + 1 ))
-	done
-	# add an entry for SERVICE to /etc/services
-	if [ "${OK}" = "no" ]; then
-		echo "==> add entry \"${SERVICE} ${PORT}/${PROTO}\""
-		(
-			grep -v -e "^${SERVICE}.*${PORT}/${PROTO}" ${FILE}
-			echo "${SERVICE}	${PORT}/${PROTO}   # ${COMMENT}"
-		) >> ${FILE}.new
-		mv ${FILE}.new ${FILE}
-	fi
-}
-
-# always add service entries
-if [ "$2" = "PRE-INSTALL" ]; then
-	echo "Checking ${FILE} for missing service entries"
-	[ ! -f ${FILE} ] && echo "==> cannot find ${FILE} ... => exit" &&  exit 1
-	check_service spamd 8025 tcp "spamd(8)"
-	check_service spamd-sync 8025 udp "spamd(8) synchronisation"
-	check_service spamd-cfg 8026 tcp "spamd(8) configuration"
-fi
 
 if [ "$2" = "POST-INSTALL" ]; then
 	check_db

Modified: head/mail/spamd/files/pkg-message.in
==============================================================================
--- head/mail/spamd/files/pkg-message.in	Mon Mar 30 21:06:11 2020	(r529920)
+++ head/mail/spamd/files/pkg-message.in	Mon Mar 30 21:10:08 2020	(r529921)
@@ -3,7 +3,10 @@
   message: <<EOM
 To enable spamd you need:
 
-1) Enable spamd in /etc/rc.conf with the following line:
+1) add required spamd entries to /etc/services, run command
+     %%PREFIX%%/sbin/add-spamd-to-etc-service
+
+2) Enable spamd in /etc/rc.conf with the following line:
    obspamd_enable="YES"
    obspamlogd_enable="YES"
 
@@ -11,11 +14,11 @@ To enable spamd you need:
    obspamlogd_pflog_if. This interface will be created and removed
    by the rc script of spamlogd.
 
-2) Configuration template is available in %%PREFIX%%/etc/spamd as
+3) Configuration template is available in %%PREFIX%%/etc/spamd as
    spamd.conf.sample file.  Copy then to spamd.conf file and
    edit to suit your needs.
 
-3) mount fdescfs to /dev/fd with the following line in /etc/fstab
+4) mount fdescfs to /dev/fd with the following line in /etc/fstab
 	fdescfs  	/dev/fd  	fdescfs rw 	0 	0
 
    Note for XEN users:
@@ -25,7 +28,7 @@ To enable spamd you need:
 	device	pf
 	device	pflog
 
-4) Add following lines to the pf.conf(5)
+5) Add following lines to the pf.conf(5)
 
   table <spamd-white> persist
   no rdr inet proto tcp from <spamd-white> to any \
@@ -35,7 +38,7 @@ To enable spamd you need:
 
 FreeBSD only features (not in OpenBSD):
   - sync for spamdb (parameter -Y)
-    See %%PREFIX%%/%%DOCSDIR%%/ for usage.
+    See %%DOCSDIR%%/ for usage.
 EOM
 }
 ]



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