main/libspf2: upgrade to 1.2.10 and fix build with musl

This commit is contained in:
Natanael Copa 2014-09-11 08:14:50 +00:00
parent 4d479202ab
commit 12cf2d5083
7 changed files with 65 additions and 249 deletions

View File

@ -1,27 +1,27 @@
From abfd38dbff2be2e63ee222a87b4f24de5573e7eb Mon Sep 17 00:00:00 2001
From: Natanael Copa <natanael.copa@gmail.com>
Date: Mon, 19 Apr 2010 14:53:35 +0000
From 808b584d22106828aaaa3f2a52b1d076b6e66040 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 11 Sep 2014 08:09:34 +0000
Subject: [PATCH] provide dn_skipname
---
configure.ac | 3 +-
src/libreplace/__dn_skipname.c | 87 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+), 1 deletions(-)
configure.ac | 2 +-
src/libreplace/__dn_skipname.c | 87 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 src/libreplace/__dn_skipname.c
diff --git a/configure.ac b/configure.ac
index 310d73c..8a0dd2b 100644
index 63e398c..739da3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -272,7 +273,7 @@ AC_CHECK_FUNCS([strcasecmp strncasecmp strspn strtoul])
@@ -274,7 +274,7 @@ AC_CHECK_FUNCS([strcasecmp strncasecmp strspn strtoul])
AC_CHECK_FUNCS([gethostbyname inet_ntoa select strrchr strstr strtol])
AC_REPLACE_FUNCS([getopt_long_only strncasecmp])
-AC_REPLACE_FUNCS([__ns_initparse __ns_name_uncompress __ns_get16 __ns_msg_getflag])
+AC_REPLACE_FUNCS([__ns_initparse __ns_name_uncompress __ns_get16 __ns_msg_getflag __dn_skipname])
-AC_REPLACE_FUNCS([__ns_initparse __ns_name_uncompress __ns_msg_getflag])
+AC_REPLACE_FUNCS([__ns_initparse __ns_name_uncompress __ns_msg_getflag __dn_skipname])
dnl Magnus Holmgren says this avoids linking a private function
AC_LIBOBJ([__ns_get16])
AC_CONFIG_FILES([Makefile
Doxyfile
diff --git a/src/libreplace/__dn_skipname.c b/src/libreplace/__dn_skipname.c
new file mode 100644
index 0000000..88d48b5
@ -116,5 +116,5 @@ index 0000000..88d48b5
+
+
--
1.7.0.4
2.1.0

View File

@ -1,20 +1,19 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libspf2
pkgver=1.2.9
pkgrel=8
pkgver=1.2.10
pkgrel=0
pkgdesc="Sender Policy Framework library, a part of the SPF/SRS protocol pair."
url="http://www.libspf2.org"
arch=""
arch="all"
license="LGPL-2.1 BSD-2"
subpackages="$pkgname-dev"
makedepends="autoconf automake libtool bind-dev"
makedepends="autoconf automake libtool"
depends=
source="http://www.libspf2.org/spf/libspf2-$pkgver.tar.gz
libspf2-localpolicy-fix.patch
0001-provide-dn_skipname.patch
libspf2-libreplace-fix.patch
libspf2-res_ninit-uclibc.patch
automake.patch
netdb_success.patch
musl-res_close.patch
"
_builddir="$srcdir"/$pkgname-$pkgver
@ -45,9 +44,18 @@ package() {
make DESTDIR="$pkgdir" install || return 1
rm "$pkgdir"/usr/lib/*.la
}
md5sums="3305df4d1b13ca964d80b23bb5e4e2b6 libspf2-1.2.9.tar.gz
dab7cc92ed1ff332e4fcfab95b8d35ea libspf2-localpolicy-fix.patch
201889cbd209aa7cae9ce11ed5ebaaa6 0001-provide-dn_skipname.patch
md5sums="7bb9937d0705649eaa8646de66dc3562 libspf2-1.2.10.tar.gz
24b77cb74901d56de89b24ef10b46b85 0001-provide-dn_skipname.patch
6dd2d5f33c5f1a5b7c14eec4c71767cd libspf2-libreplace-fix.patch
06c981fcca0434d447f8a2749b51696f libspf2-res_ninit-uclibc.patch
4a83b623d8751e4049f3e68b3a074d21 automake.patch"
e364ae123e18ec330339824e71774b44 netdb_success.patch
984f356b97d936395ee061d6c6003d0a musl-res_close.patch"
sha256sums="d91e3de81ae287a2976c44f60283bd3000d720e6a112dc7142eedf1831b821c9 libspf2-1.2.10.tar.gz
b6038c035c08e31a5407ed06d4af490aea357c1e51c218a02c703a9eace9a072 0001-provide-dn_skipname.patch
f9ee6d10be25a52d2432ac62114c37e2dd4c00c8e11d908f2f2ed0d4ba71b139 libspf2-libreplace-fix.patch
381d3cb2ef4257eb93dc52b39944948705feaf29223fa263af9c362963eb136e netdb_success.patch
8d7392aaf3db6f32c96c3f3dac6d928762e0149d966e98fbedc434308894e03b musl-res_close.patch"
sha512sums="162ce382628c6fcadac3e11f5a12442db622bb23f7ec503e16f5ba7fc88afdd777bce6b093c12a58210355985fd11b74b140f08fab347334d82d953dd183b130 libspf2-1.2.10.tar.gz
cc8c77963a3bc0c54442c81146cc27e482c43787586ab8885e3fe0fd2cfcba089f5a5cfeda4c3307fe5cc36ac8768f748d9a8467e9b8ca41e9ad157b61bbce49 0001-provide-dn_skipname.patch
226e1d7a1d381f35206aaecafb33955a6ecd08c8c18f4d6fe443e359f0139aeeb314012296a53e7c017d68373f4e1fa27010514296f15ab86f059e531866b95a libspf2-libreplace-fix.patch
033dd1e959004f7a1026fb1de73813e934560101e04897297e468918ee28e4d7d0f271d6f05d984db22dd43e097f6aa133df18d11419b085d89db89b120750c9 netdb_success.patch
4fb8a28a667d8fe54a48fa89230446b758c6d532866ee26e8b9ef3032f6e0993ec19a2cc2fb265d18d259e35de6fe66183763bbc69c424de70ad8fe0dbcf7a2f musl-res_close.patch"

View File

@ -1,11 +0,0 @@
--- ./configure.ac.orig 2012-12-31 20:13:11.653376850 +0000
+++ ./configure.ac 2012-12-31 20:13:26.790177076 +0000
@@ -6,7 +6,7 @@
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(libspf2, $PACKAGE_VERSION)
AC_CONFIG_SRCDIR([src/libspf2/spf_server.c])
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADER(config.h)
# remember the version info for later

View File

@ -1,149 +0,0 @@
diff --git a/src/libspf2/spf_interpret.c b/src/libspf2/spf_interpret.c
index 78fa81a..6dbdd8d 100644
--- a/src/libspf2/spf_interpret.c
+++ b/src/libspf2/spf_interpret.c
@@ -594,10 +594,6 @@ SPF_record_interpret(SPF_record_t *spf_record,
SPF_data_t *data;
SPF_data_t *data_end; /* XXX Replace with size_t data_len */
- /* Where to insert the local policy (whitelist) */
- SPF_mech_t *local_policy; /* Not the local policy */
- int found_all; /* A crappy temporary. */
-
char *buf = NULL;
size_t buf_len = 0;
ns_type fetch_ns_type;
@@ -662,58 +658,6 @@ SPF_record_interpret(SPF_record_t *spf_record,
#endif
/*
- * Do some start up stuff if we haven't recursed yet
- */
-
- local_policy = NULL;
-
- if ( spf_request->use_local_policy ) {
- /*
- * find the location for the whitelist execution
- *
- * Philip Gladstone says:
- *
- * I think that the localpolicy should only be inserted if the
- * final mechanism is '-all', and it should be inserted after
- * the last mechanism which is not '-'.
- *
- * Thus for the case of 'v=spf1 +a +mx -all', this would be
- * interpreted as 'v=spf1 +a +mx +localpolicy -all'. Whereas
- * 'v=spf1 -all' would remain the same (no non-'-'
- * mechanism). 'v=spf1 +a +mx -exists:%stuff -all' would
- * become 'v=spf1 +a +mx +localpolicy -exists:%stuff -all'.
- */
-
- if ( spf_server->local_policy ) {
- mech = spf_record->mech_first;
-
- found_all = FALSE;
- for(m = 0; m < spf_record->num_mech; m++)
- {
- if ( mech->mech_type == MECH_ALL
- && (mech->prefix_type == PREFIX_FAIL
- || mech->prefix_type == PREFIX_UNKNOWN
- || mech->prefix_type == PREFIX_SOFTFAIL
- )
- )
- found_all = TRUE;
-
- if ( mech->prefix_type != PREFIX_FAIL
- && mech->prefix_type != PREFIX_SOFTFAIL
- )
- local_policy = mech;
-
- mech = SPF_mech_next( mech );
- }
-
- if ( !found_all )
- local_policy = NULL;
- }
-
- }
-
-
- /*
* evaluate the mechanisms
*/
@@ -751,6 +695,35 @@ SPF_record_interpret(SPF_record_t *spf_record,
resolver = spf_server->resolver;
+ /*
+ * execute the local policy
+ */
+ if ( spf_request->use_local_policy && spf_server->local_policy ) {
+ spf_request->use_local_policy = 0;
+ err = SPF_record_interpret(spf_server->local_policy,
+ spf_request, spf_response, depth + 1);
+ spf_request->use_local_policy = 1;
+
+ if ( spf_server->debug > 0 )
+ SPF_debugf( "local_policy: executed SPF record: %s result: %s reason: %s",
+ SPF_strerror( err ),
+ SPF_strresult( spf_response->result ),
+ SPF_strreason( spf_response->reason ) );
+
+ if (spf_response->result != SPF_RESULT_INVALID &&
+ spf_response->result != SPF_RESULT_NONE &&
+ spf_response->result != SPF_RESULT_NEUTRAL) {
+ SPF_FREE_LOOKUP_DATA();
+ return err;
+ }
+
+ if ( spf_server->debug > 0 )
+ SPF_debugf( "local_policy: not definite",
+ SPF_strerror( err ),
+ SPF_strresult( spf_response->result ),
+ SPF_strreason( spf_response->reason ) );
+ }
+
mech = spf_record->mech_first;
for (m = 0; m < spf_record->num_mech; m++) {
@@ -1256,26 +1229,6 @@ SPF_record_interpret(SPF_record_t *spf_record,
break;
}
- /*
- * execute the local policy
- */
-
- if ( mech == local_policy ) {
- err = SPF_record_interpret(spf_server->local_policy,
- spf_request, spf_response, depth + 1);
-
- if ( spf_server->debug > 0 )
- SPF_debugf( "local_policy: executed SPF record: %s result: %s reason: %s",
- SPF_strerror( err ),
- SPF_strresult( spf_response->result ),
- SPF_strreason( spf_response->reason ) );
-
- if (spf_response->result != SPF_RESULT_INVALID) {
- SPF_FREE_LOOKUP_DATA();
- return err;
- }
- }
-
mech = SPF_mech_next( mech );
}
diff --git a/src/libspf2/spf_request.c b/src/libspf2/spf_request.c
index 7614141..9eb1774 100644
--- a/src/libspf2/spf_request.c
+++ b/src/libspf2/spf_request.c
@@ -47,6 +47,7 @@ SPF_request_new(SPF_server_t *spf_server)
return sr;
memset(sr, 0, sizeof(SPF_request_t));
+ sr->use_local_policy = 1;
sr->spf_server = spf_server;
sr->client_ver = AF_UNSPEC;
sr->ipv4.s_addr = htonl(INADDR_ANY);

View File

@ -1,64 +0,0 @@
diff --git a/src/libspf2/spf_dns_resolv.c b/src/libspf2/spf_dns_resolv.c
index 10ccee6..7acdd1f 100644
--- a/src/libspf2/spf_dns_resolv.c
+++ b/src/libspf2/spf_dns_resolv.c
@@ -79,13 +79,13 @@ static const struct res_sym ns_sects[] = {
static const int num_ns_sect = sizeof(ns_sects) / sizeof(*ns_sects);
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
# define SPF_h_errno res_state->res_h_errno
#else
# define SPF_h_errno h_errno
#endif
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
static pthread_once_t res_state_control = PTHREAD_ONCE_INIT;
static pthread_key_t res_state_key;
@@ -239,14 +239,14 @@ SPF_dns_resolv_lookup(SPF_dns_server_t *spf_dns_server,
size_t rdlen;
const u_char *rdata;
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
void *res_spec;
struct __res_state *res_state;
#endif
SPF_ASSERT_NOTNULL(spf_dns_server);
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
/** Get the thread-local resolver state. */
res_spec = pthread_getspecific(res_state_key);
if (res_spec == NULL) {
@@ -292,7 +292,7 @@ SPF_dns_resolv_lookup(SPF_dns_server_t *spf_dns_server,
for (;;) {
int dns_len;
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
/* Resolve the name. */
dns_len = res_nquery(res_state, domain, ns_c_in, rr_type,
responsebuf, responselen);
@@ -606,7 +606,7 @@ SPF_dns_resolv_free(SPF_dns_server_t *spf_dns_server)
{
SPF_ASSERT_NOTNULL(spf_dns_server);
-#if ! HAVE_DECL_RES_NINIT
+#if ! HAVE_DECL_RES_NINIT || defined(__UCLIBC__)
res_close();
#endif
@@ -619,7 +619,7 @@ SPF_dns_resolv_new(SPF_dns_server_t *layer_below,
{
SPF_dns_server_t *spf_dns_server;
-#if HAVE_DECL_RES_NINIT
+#if HAVE_DECL_RES_NINIT && !defined(__UCLIBC__)
pthread_once(&res_state_control, SPF_dns_resolv_init_key);
#else
if (res_init() != 0) {

View File

@ -0,0 +1,15 @@
musl does not have res_close and if it had, it would have been a NOP
diff --git a/src/libspf2/spf_dns_resolv.c b/src/libspf2/spf_dns_resolv.c
index 8f795ce..e3563d8 100644
--- a/src/libspf2/spf_dns_resolv.c
+++ b/src/libspf2/spf_dns_resolv.c
@@ -606,7 +606,7 @@ SPF_dns_resolv_free(SPF_dns_server_t *spf_dns_server)
{
SPF_ASSERT_NOTNULL(spf_dns_server);
-#if ! HAVE_DECL_RES_NINIT
+#if ! HAVE_DECL_RES_NINIT && HAVE_RES_CLOSE
res_close();
#endif

View File

@ -0,0 +1,17 @@
--- ./src/include/spf_dns.h.orig
+++ ./src/include/spf_dns.h
@@ -99,11 +99,13 @@
*/
#if !defined(HAVE_NETDB_H) && !defined(_WIN32)
-#define NETDB_SUCCESS 0
#define HOST_NOT_FOUND 1 /**< NXDOMAIN (authoritative answer)*/
#define TRY_AGAIN 2 /**< SERVFAIL (no authoritative answer)*/
#define NO_RECOVERY 3 /**< invalid/unimplmeneted query */
#define NO_DATA 4 /**< host found, but no RR of req type*/
+#endif
+#ifndef NETDB_SUCCESS
+#define NETDB_SUCCESS 0
#endif
typedef int SPF_dns_stat_t;