[Midnightbsd-cvs] mports: mports/mail: Add libspf2

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 18 14:37:59 EDT 2008


Log Message:
-----------
Add libspf2

Modified Files:
--------------
    mports/mail:
        Makefile (r1.40 -> r1.41)

Added Files:
-----------
    mports/mail/libspf2:
        Makefile (r1.1)
        distinfo (r1.1)
        pkg-descr (r1.1)
        pkg-plist (r1.1)
    mports/mail/libspf2/files:
        patch-RFC4408-DOS (r1.1)
        patch-configure (r1.1)
        patch-src__libspf2__spf_interpret.c (r1.1)
        patch-src_include_spf__server.h (r1.1)
        patch-src_libspf2_spf__dns__resolv.c (r1.1)
        patch-src_libspf2_spf__dns__rr.c (r1.1)
        patch-src_libspf2_spf__request.c (r1.1)
        patch-src_libspf2_spf__response.c (r1.1)
        patch-src_spf__example_spf__example.c (r1.1)
        patch-src_spfquery_spfquery.c (r1.1)

-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mports/mail/Makefile,v
retrieving revision 1.40
retrieving revision 1.41
diff -L mail/Makefile -L mail/Makefile -u -r1.40 -r1.41
--- mail/Makefile
+++ mail/Makefile
@@ -18,6 +18,7 @@
     SUBDIR += gmime2
     SUBDIR += gnumail
     SUBDIR += hashcash
+    SUBDIR += libspf2
     SUBDIR += linux-thunderbird
     SUBDIR += milter-greylist
     SUBDIR += msmtp
--- /dev/null
+++ mail/libspf2/pkg-descr
@@ -0,0 +1,8 @@
+libspf2 implements the Sender Policy Framework, a part of the SPF/SRS 
+protocol pair. libspf2 is a library which allows email systems such as 
+Sendmail, Postfix, Exim, Zmailer and MS Exchange to check SPF records 
+and make sure that the email is authorized by the domain name that it 
+is coming from. This prevents email forgery, commonly used by spammers, 
+scammers and email viruses/worms.
+
+WWW: http://www.libspf2.org/
--- /dev/null
+++ mail/libspf2/pkg-plist
@@ -0,0 +1,27 @@
+bin/spf_example
+bin/spf_example_static
+bin/spfd
+bin/spfd_static
+bin/spfquery
+bin/spfquery_static
+bin/spftest
+bin/spftest_static
+include/spf2/spf.h
+include/spf2/spf_dns.h
+include/spf2/spf_dns_cache.h
+include/spf2/spf_dns_null.h
+include/spf2/spf_dns_resolv.h
+include/spf2/spf_dns_rr.h
+include/spf2/spf_dns_test.h
+include/spf2/spf_dns_zone.h
+include/spf2/spf_lib_version.h
+include/spf2/spf_log.h
+include/spf2/spf_record.h
+include/spf2/spf_request.h
+include/spf2/spf_response.h
+include/spf2/spf_server.h
+ at dirrm include/spf2
+lib/libspf2.a
+lib/libspf2.la
+lib/libspf2.so
+lib/libspf2.so.2
--- /dev/null
+++ mail/libspf2/Makefile
@@ -0,0 +1,30 @@
+# New ports collection makefile for:   libspf2
+# Date created:        May 17 2008
+# Whom:                Lucas Holt <luke at midnightbsd.org>
+#
+# $MidnightBSD: mports/mail/libspf2/Makefile,v 1.1 2008/05/18 18:37:57 laffer1 Exp $
+#
+
+PORTNAME=	libspf2
+PORTVERSION=	1.2.5
+PORTREVISION=	0
+CATEGORIES=	mail
+MASTER_SITES=	http://www.libspf2.org/%SUBDIR%/
+MASTER_SITE_SUBDIR=	spf
+
+MAINTAINER=	ports at MidnightBSD.org
+COMMENT=	Sender Rewriting Scheme 2 C Implementation
+LICENSE=	bsd2
+# dual license
+
+USE_AUTOTOOLS=	libtool:15
+USE_LDCONFIG=	yes
+GNU_CONFIGURE=	yes
+
+CONFIGURE_TARGET=	--build=${MACHINE_ARCH}-portbld-freebsd6.0
+
+post-patch:
+	@${REINPLACE_CMD} -e "s|-lpthread|${PTHREAD_LIBS}|g" \
+		${WRKSRC}/configure
+
+.include <bsd.port.mk>
--- /dev/null
+++ mail/libspf2/distinfo
@@ -0,0 +1,3 @@
+MD5 (libspf2-1.2.5.tar.gz) = 06ed6a3b0b54c8590679315ae2d28ad9
+SHA256 (libspf2-1.2.5.tar.gz) = 879410f87ab4ffd575b1d8149167de6d5eee751199debc039efcc1558c7d0ecb
+SIZE (libspf2-1.2.5.tar.gz) = 517945
--- /dev/null
+++ mail/libspf2/files/patch-src_libspf2_spf__dns__resolv.c
@@ -0,0 +1,102 @@
+Index: src/libspf2/spf_dns_resolv.c
+diff -u -p src/libspf2/spf_dns_resolv.c.orig src/libspf2/spf_dns_resolv.c
+--- src/libspf2/spf_dns_resolv.c.orig	Sat Feb 19 11:38:12 2005
++++ src/libspf2/spf_dns_resolv.c	Mon Jul 31 14:02:57 2006
+@@ -71,13 +71,18 @@ typedef struct
+ # define SPF_h_errno h_errno
+ #endif
+ 
++#if HAVE_DECL_RES_NINIT
+ static pthread_once_t	res_state_control = PTHREAD_ONCE_INIT;
+ static pthread_key_t	res_state_key;
+ 
+ static void
+ SPF_dns_resolv_thread_term(void *arg)
+ {
++#ifdef res_ndestroy
++	res_ndestroy( (struct __res_state *)arg );
++#else
+ 	res_nclose( (struct __res_state *)arg );
++#endif
+ 	free(arg);
+ }
+ 
+@@ -86,6 +91,7 @@ SPF_dns_resolv_init_key()
+ {
+ 	pthread_key_create(&res_state_key, SPF_dns_resolv_thread_term);
+ }
++#endif
+ 
+ 
+ #if 0
+@@ -130,8 +136,10 @@ SPF_dns_resolv_lookup(SPF_dns_server_t *
+     int		rdlen;
+     const u_char	*rdata, *rdata_end;
+ 
++#if HAVE_DECL_RES_NINIT
+ 	void				*res_spec;
+ 	struct __res_state	*res_state;
++#endif
+ 
+ 	SPF_ASSERT_NOTNULL(spf_dns_server);
+ 
+@@ -140,10 +148,15 @@ SPF_dns_resolv_lookup(SPF_dns_server_t *
+ 	SPF_ASSERT_NOTNULL(spfhook);
+ #endif
+ 
++#if HAVE_DECL_RES_NINIT
+ 	res_spec = pthread_getspecific(res_state_key);
+ 	if (res_spec == NULL) {
+ 		res_state = (struct __res_state *)
+ 						malloc(sizeof(struct __res_state));
++		if (res_state == NULL) {
++			SPF_error("Failed to call malloc()");
++		}
++		memset(res_state, 0, sizeof(*res_state));
+ 		if (res_ninit(res_state) != 0) {
+ 			SPF_error("Failed to call res_ninit()");
+ 		}
+@@ -152,6 +165,11 @@ SPF_dns_resolv_lookup(SPF_dns_server_t *
+ 	else {
+ 		res_state = (struct __res_state *)res_spec;
+ 	}
++#else
++	if ((_res.options & RES_INIT) == 0 && res_init() != 0) {
++		SPF_error("Failed to call res_init()");
++	}
++#endif
+ 
+     /*
+      * try resolving the name
+@@ -486,7 +504,9 @@ SPF_dns_resolv_new(SPF_dns_server_t *lay
+ 	SPF_dns_resolv_config_t	*spfhook;
+ #endif
+ 
++#if HAVE_DECL_RES_NINIT
+ 	pthread_once(&res_state_control, SPF_dns_resolv_init_key);
++#endif
+ 
+     spf_dns_server = malloc(sizeof(SPF_dns_server_t));
+     if ( spf_dns_server == NULL )
+@@ -517,19 +537,19 @@ SPF_dns_resolv_new(SPF_dns_server_t *lay
+     spfhook = SPF_voidp2spfhook( spf_dns_server->hook );
+ #endif
+ 
+-#if HAVE_DECL_RES_NINIT
+ #if 0
++#if HAVE_DECL_RES_NINIT
+     if ( res_ninit( &spfhook->res_state ) != 0 ) {
+ 		free(spfhook);
+ 		free(spf_dns_server);
+ 		return NULL;
+     }
+-#endif
+ #else
+     if ( res_init() != 0 ) {
+ 		free( spf_dns_server );
+ 		return NULL;
+     }
++#endif
+ #endif
+ 
+     return spf_dns_server;
--- /dev/null
+++ mail/libspf2/files/patch-src_libspf2_spf__response.c
@@ -0,0 +1,12 @@
+--- src/libspf2/spf_response.c.orig	Tue Oct 19 11:05:19 2004
++++ src/libspf2/spf_response.c	Mon Mar 28 10:58:26 2005
+@@ -132,6 +132,9 @@
+ SPF_result_t
+ SPF_response_result(SPF_response_t *rp)
+ {
++	if (rp == NULL)
++		return SPF_RESULT_NONE;
++
+ 	return rp->result;
+ }
+ 
--- /dev/null
+++ mail/libspf2/files/patch-src_spfquery_spfquery.c
@@ -0,0 +1,11 @@
+--- src/spfquery/spfquery.c.orig	Thu Jul 28 19:04:46 2005
++++ src/spfquery/spfquery.c	Thu Jul 28 19:04:54 2005
+@@ -261,7 +261,7 @@
+ response_print_errors(const char *context,
+ 				SPF_response_t *spf_response, SPF_errcode_t err)
+ {
+-	SPF_error_t		*spf_error;;
++	SPF_error_t		*spf_error;
+ 	int				 i;
+ 
+ 	printf("StartError\n");
--- /dev/null
+++ mail/libspf2/files/patch-src_libspf2_spf__request.c
@@ -0,0 +1,12 @@
+--- src/libspf2/spf_request.c.orig	Mon Feb 21 23:38:57 2005
++++ src/libspf2/spf_request.c	Mon Mar 28 10:37:52 2005
+@@ -307,6 +307,9 @@
+ 	char			*record;
+ 	size_t			 len;
+ 
++	if ( (spf_request == NULL) || (rcpt_to == NULL) )
++		return SPF_E_INVALID_OPT;
++
+ 	SPF_ASSERT_NOTNULL(spf_request);
+ 	spf_server = spf_request->spf_server;
+ 	SPF_ASSERT_NOTNULL(spf_server);
--- /dev/null
+++ mail/libspf2/files/patch-configure
@@ -0,0 +1,15 @@
+--- configure.orig	Wed Feb 23 23:14:51 2005
++++ configure	Thu Jul 28 20:12:32 2005
+@@ -23661,12 +23661,6 @@
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ 
+-	#ifdef HAVE_SYS_SOCKET_H
+-	# include <sys/socket.h>		/* inet_ functions / structs */
+-	#endif
+-	#ifdef HAVE_NETINET_IN_H
+-	# include <netinet/in.h>		/* inet_ functions / structs */
+-	#endif
+ 	#ifdef HAVE_ARPA_NAMESER_H
+ 	#  include <arpa/nameser.h> /* DNS HEADER struct */
+ 	#endif
--- /dev/null
+++ mail/libspf2/files/patch-RFC4408-DOS
@@ -0,0 +1,49 @@
+--- src/include/spf.h.orig	2008-02-10 11:30:04.000000000 -0200
++++ src/include/spf.h	2008-02-10 11:30:20.000000000 -0200
+@@ -52,8 +52,8 @@
+ 
+ /* FYI only -- defaults can't be changed without recompiling the library */
+ #define SPF_DEFAULT_MAX_DNS_MECH 10	/* DoS limit on SPF mechanisms	*/
+-#define SPF_DEFAULT_MAX_DNS_PTR	  5	/* DoS limit on PTR records	*/
+-#define SPF_DEFAULT_MAX_DNS_MX	  5	/* DoS limit on MX records	*/
++#define SPF_DEFAULT_MAX_DNS_PTR	 10	/* DoS limit on PTR records	*/
++#define SPF_DEFAULT_MAX_DNS_MX	 10	/* DoS limit on MX records	*/
+ #define SPF_DEFAULT_SANITIZE	  1
+ #define SPF_DEFAULT_WHITELIST	  "include:spf.trusted-forwarder.org"
+ #define SPF_EXP_MOD_NAME	"exp-text"
+--- src/include/spf_internal.h.orig	2008-02-10 11:30:28.000000000 -0200
++++ src/include/spf_internal.h	2008-02-10 11:31:26.000000000 -0200
+@@ -57,13 +57,13 @@
+ /* It is a bad idea to change this for the same reasons as mentioned
+  * above for SPF_MAX_DNS_MECH
+  */
+-#define SPF_MAX_DNS_PTR   5
++#define SPF_MAX_DNS_PTR   10
+ #endif
+ #ifndef SPF_MAX_DNS_MX
+ /* It is a bad idea to change this for the same reasons as mentioned
+  * above for SPF_MAX_DNS_MECH
+  */
+-#define SPF_MAX_DNS_MX    5
++#define SPF_MAX_DNS_MX    10
+ #endif
+ 
+ #if 1
+--- src/include/spf_server.h.orig	2008-02-10 11:31:38.000000000 -0200
++++ src/include/spf_server.h	2008-02-10 11:31:55.000000000 -0200
+@@ -43,13 +43,13 @@
+ /* It is a bad idea to change this for the same reasons as mentioned
+  * above for SPF_MAX_DNS_MECH
+  */
+-#define SPF_MAX_DNS_PTR   5
++#define SPF_MAX_DNS_PTR   10
+ #endif
+ #ifndef SPF_MAX_DNS_MX
+ /* It is a bad idea to change this for the same reasons as mentioned
+  * above for SPF_MAX_DNS_MECH
+  */
+-#define SPF_MAX_DNS_MX    5
++#define SPF_MAX_DNS_MX    10
+ #endif
+ 
+ struct SPF_server_struct {
--- /dev/null
+++ mail/libspf2/files/patch-src_libspf2_spf__dns__rr.c
@@ -0,0 +1,11 @@
+--- src/libspf2/spf_dns_rr.c.orig	Thu Jul 28 18:40:13 2005
++++ src/libspf2/spf_dns_rr.c	Thu Jul 28 18:40:29 2005
+@@ -45,7 +45,7 @@
+ 				const char *domain)
+ {
+ 	return SPF_dns_rr_new_init(spf_dns_server,
+-					domain, ns_t_any, 0, NXDOMAIN);
++					domain, ns_t_any, 0, HOST_NOT_FOUND);
+ }
+ 
+ SPF_dns_rr_t *
--- /dev/null
+++ mail/libspf2/files/patch-src__libspf2__spf_interpret.c
@@ -0,0 +1,13 @@
+--- src/libspf2/spf_interpret.c.orig	Wed Dec 13 00:46:58 2006
++++ src/libspf2/spf_interpret.c	Wed Dec 13 00:47:23 2006
+@@ -49,8 +49,8 @@
+ 	SPF_record_t	*spf_record;
+ 	SPF_errcode_t	 err;
+ 	char			*buf;
+-	int				 buflen;
+-	int				 len;
++	size_t				 buflen;
++	size_t				 len;
+ 
+ 	SPF_ASSERT_NOTNULL(spf_response);
+ 	spf_request = spf_response->spf_request;
--- /dev/null
+++ mail/libspf2/files/patch-src_include_spf__server.h
@@ -0,0 +1,10 @@
+--- src/include/spf_server.h.orig	Thu Jul 28 18:35:53 2005
++++ src/include/spf_server.h	Thu Jul 28 18:35:59 2005
+@@ -20,7 +20,6 @@
+ 
+ #include "spf_record.h"
+ #include "spf_dns.h"
+-#include "spf_dns_internal.h"
+ 
+ #ifndef SPF_MAX_DNS_MECH
+ /* It is a bad idea to change this for two reasons.
--- /dev/null
+++ mail/libspf2/files/patch-src_spf__example_spf__example.c
@@ -0,0 +1,69 @@
+--- src/spf_example/spf_example.c.orig	Mon Mar 28 14:17:20 2005
++++ src/spf_example/spf_example.c	Mon Mar 28 14:22:46 2005
+@@ -90,17 +90,17 @@
+ 	"\n"
+ 	"Valid data options are:\n"
+ 	"	-i <IP address>			The IP address that is sending email\n"
+-	"	-s <email address>		 The email address used as the\n"
+-	"							   envelope-from.  If no username (local\n"
+-	"							   part) is given, 'postmaster' will be\n"
+-	"							   assumed.\n"
+-	"	-r <email address>		 [optional] The email address used as\n"
+-	"							   the envelope-to email address, for\n"
+-	"							   secondary-MX checking.\n"
+-	"	-h <domain name>		   The domain name given on the SMTP HELO\n"
+-	"							   command.  This is only needed if the\n"
+-	"							   -sender option is not given.\n"
+-	"	-d [debug level]		   debug level.\n"
++	"	-s <email address>		The email address used as the\n"
++	"					envelope-from.  If no username (local\n"
++	"					part) is given, 'postmaster' will be\n"
++	"					assumed.\n"
++	"	-r <email address>		[optional] The email address used as\n"
++	"					the envelope-to email address, for\n"
++	"					secondary-MX checking.\n"
++	"	-h <domain name>		The domain name given on the SMTP HELO\n"
++	"					command.  This is only needed if the\n"
++	"					-sender option is not given.\n"
++	"	-d [debug level]		debug level.\n"
+ 	);
+ }
+ 
+@@ -206,7 +206,7 @@
+ 	 * destroyed when you are finished.
+ 	 */
+ 
+-	spf_server = SPF_server_new(SPF_DNS_CACHE, 1);
++	spf_server = SPF_server_new(SPF_DNS_CACHE, opt_debug);
+ 
+ 	if (spf_server == NULL) {
+ 		fprintf( stderr, "SPF_create_config failed.\n" );
+@@ -264,10 +264,24 @@
+ 	 * message.
+ 	 */
+ 
+-	if ( SPF_request_set_helo_dom( spf_request, opt_helo ) ) {
+-		printf( "Invalid HELO domain.\n" );
+-		res = 255;
+-		goto error;
++	if (opt_helo == NULL) {
++		if (opt_sender != NULL) {
++			if (strstr(opt_sender, "@") != NULL) {
++				opt_helo = strdup(strstr(opt_sender, "@") + 1);
++
++				if ( SPF_request_set_helo_dom( spf_request, opt_helo ) ) {
++					printf( "Invalid HELO domain.\n" );
++					res = 255;
++					goto error;
++				}
++			}
++		}
++	} else {
++		if ( SPF_request_set_helo_dom( spf_request, opt_helo ) ) {
++			printf( "Invalid HELO domain.\n" );
++			res = 255;
++			goto error;
++		}
+ 	}
+ 
+ 	/*


More information about the Midnightbsd-cvs mailing list