Add common handling for libresolv similiar to dlopen(3) wrapping.

For now, DragonFly and FreeBSD use the libc version, it is not reentrant,
but thread-safe. NetBSD 3.0+ and Darwin 8.0+ use libresolv from base
(the BIND9 resolver), all other fall back to net/bind9. Feel free to add
your favorite platform if it has a thread-safe resolver in base.

Modify mail/libspf-alf, mail/milter-greylist, mail/spamdyke and
net/nocol accordingly. Testing on !DragonFly and feedback from tron@
This commit is contained in:
joerg 2007-07-03 13:54:45 +00:00
parent fa3e8e36f9
commit e24209d145
13 changed files with 169 additions and 24 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.14 2006/10/04 21:47:16 wiz Exp $ # $NetBSD: Makefile,v 1.15 2007/07/03 13:54:45 joerg Exp $
DISTNAME= libspf_alt-0.4.0 DISTNAME= libspf_alt-0.4.0
PKGREVISION= 3 PKGREVISION= 3
@ -15,5 +15,5 @@ GNU_CONFIGURE= YES
CONFIGURE_ARGS+=--with-bind=${BUILDLINK_PREFIX.bind} CONFIGURE_ARGS+=--with-bind=${BUILDLINK_PREFIX.bind}
.include "../../devel/gettext-lib/buildlink3.mk" .include "../../devel/gettext-lib/buildlink3.mk"
.include "../../net/bind9/buildlink3.mk" .include "../../mk/resolv.buildlink3.mk"
.include "../../mk/bsd.pkg.mk" .include "../../mk/bsd.pkg.mk"

View file

@ -1,4 +1,4 @@
# $NetBSD: buildlink3.mk,v 1.8 2006/07/08 23:10:57 jlam Exp $ # $NetBSD: buildlink3.mk,v 1.9 2007/07/03 13:54:45 joerg Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+ BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
LIBSPF_ALT_BUILDLINK3_MK:= ${LIBSPF_ALT_BUILDLINK3_MK}+ LIBSPF_ALT_BUILDLINK3_MK:= ${LIBSPF_ALT_BUILDLINK3_MK}+
@ -18,6 +18,6 @@ BUILDLINK_PKGSRCDIR.libspf_alt?= ../../mail/libspf-alt
.endif # LIBSPF_ALT_BUILDLINK3_MK .endif # LIBSPF_ALT_BUILDLINK3_MK
.include "../../devel/gettext-lib/buildlink3.mk" .include "../../devel/gettext-lib/buildlink3.mk"
.include "../../net/bind9/buildlink3.mk" .include "../../mk/resolv.buildlink3.mk"
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//} BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}

View file

@ -1,5 +1,6 @@
$NetBSD: distinfo,v 1.2 2005/02/24 09:59:23 agc Exp $ $NetBSD: distinfo,v 1.3 2007/07/03 13:54:45 joerg Exp $
SHA1 (libspf_alt-0.4.0.tar.gz) = ba269d7508daebf42e9e20720f410c9409207558 SHA1 (libspf_alt-0.4.0.tar.gz) = ba269d7508daebf42e9e20720f410c9409207558
RMD160 (libspf_alt-0.4.0.tar.gz) = 67a789cfbc4df391fd6938e81ce90e3b24264615 RMD160 (libspf_alt-0.4.0.tar.gz) = 67a789cfbc4df391fd6938e81ce90e3b24264615
Size (libspf_alt-0.4.0.tar.gz) = 598003 bytes Size (libspf_alt-0.4.0.tar.gz) = 598003 bytes
SHA1 (patch-aa) = c2663da02cd12ff6c148f4dd2d9670e5ce71d3cb

View file

@ -0,0 +1,56 @@
$NetBSD: patch-aa,v 1.1 2007/07/03 13:54:45 joerg Exp $
--- configure.orig 2007-07-02 14:03:12.000000000 +0000
+++ configure
@@ -19389,13 +19389,13 @@ echo "${ECHO_T}$ac_cv_lib_bind_res_query
if test $ac_cv_lib_bind_res_query = yes; then
LIBS="$LIBS -lbind"
else
- echo "$as_me:$LINENO: checking for res_query in -lresolv" >&5
-echo $ECHO_N "checking for res_query in -lresolv... $ECHO_C" >&6
+ echo "$as_me:$LINENO: checking for res_query in ${RESOLV_LDFLAGS}" >&5
+echo $ECHO_N "checking for res_query in ${RESOLV_LDFLAGS}... $ECHO_C" >&6
if test "${ac_cv_lib_resolv_res_query+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv $LIBS"
+LIBS="${RESOLV_LDFLAGS} $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -19453,7 +19453,7 @@ fi
echo "$as_me:$LINENO: result: $ac_cv_lib_resolv_res_query" >&5
echo "${ECHO_T}$ac_cv_lib_resolv_res_query" >&6
if test $ac_cv_lib_resolv_res_query = yes; then
- LIBS="$LIBS -lresolv"
+ LIBS="$LIBS ${RESOLV_LDFLAGS}"
else
echo "cannot find resolver library"; exit 1;
fi
@@ -19464,13 +19464,13 @@ fi
else
-echo "$as_me:$LINENO: checking for res_query in -lresolv" >&5
-echo $ECHO_N "checking for res_query in -lresolv... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking for res_query in ${RESOLV_LDFLAGS}" >&5
+echo $ECHO_N "checking for res_query in ${RESOLV_LDFLAGS}... $ECHO_C" >&6
if test "${ac_cv_lib_resolv_res_query+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lresolv $LIBS"
+LIBS="${RESOLV_LDFLAGS} $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
@@ -19532,7 +19532,7 @@ if test $ac_cv_lib_resolv_res_query = ye
#define HAVE_LIBRESOLV 1
_ACEOF
- LIBS="-lresolv $LIBS"
+ LIBS="${RESOLV_LDFLAGS} $LIBS"
fi

View file

@ -1,4 +1,4 @@
# $NetBSD: options.mk,v 1.2 2006/11/09 13:15:10 ghen Exp $ # $NetBSD: options.mk,v 1.3 2007/07/03 13:54:45 joerg Exp $
PKG_OPTIONS_VAR= PKG_OPTIONS.milter-greylist PKG_OPTIONS_VAR= PKG_OPTIONS.milter-greylist
PKG_SUPPORTED_OPTIONS= dnsrbl drac spf PKG_SUPPORTED_OPTIONS= dnsrbl drac spf
@ -12,7 +12,7 @@ PKG_SUGGESTED_OPTIONS= dnsrbl spf
.if empty(PKG_OPTIONS:Mdnsrbl) .if empty(PKG_OPTIONS:Mdnsrbl)
CONFIGURE_ARGS+= --disable-dnsrbl CONFIGURE_ARGS+= --disable-dnsrbl
.else .else
CONFIGURE_ARGS+= --enable-dnsrbl CONFIGURE_ARGS+= --enable-dnsrbl --with-thread-safe-resolver
.endif .endif
### ###

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.8 2007/06/21 19:08:45 schmonz Exp $ # $NetBSD: Makefile,v 1.9 2007/07/03 13:54:45 joerg Exp $
# #
DISTNAME= spamdyke-2.6.3 DISTNAME= spamdyke-2.6.3
@ -41,4 +41,5 @@ do-install:
${INSTALL_DATA} $${f} ${PREFIX}/share/doc/${PKGBASE}; \ ${INSTALL_DATA} $${f} ${PREFIX}/share/doc/${PKGBASE}; \
done done
.include "../../mk/resolv.buildlink3.mk"
.include "../../mk/bsd.pkg.mk" .include "../../mk/bsd.pkg.mk"

View file

@ -1,8 +1,8 @@
$NetBSD: distinfo,v 1.7 2007/06/21 19:08:45 schmonz Exp $ $NetBSD: distinfo,v 1.8 2007/07/03 13:54:46 joerg Exp $
SHA1 (spamdyke-2.6.3.tgz) = e893b319c8808bc26a649b5ec7b82dae41e64e5f SHA1 (spamdyke-2.6.3.tgz) = e893b319c8808bc26a649b5ec7b82dae41e64e5f
RMD160 (spamdyke-2.6.3.tgz) = 9b061fc32ee92d731db0d8ad2cf04d61829d59ac RMD160 (spamdyke-2.6.3.tgz) = 9b061fc32ee92d731db0d8ad2cf04d61829d59ac
Size (spamdyke-2.6.3.tgz) = 116041 bytes Size (spamdyke-2.6.3.tgz) = 116041 bytes
SHA1 (patch-aa) = 9bb28e5535b28fa558ce577670e4a13324664ef4 SHA1 (patch-aa) = 9bb28e5535b28fa558ce577670e4a13324664ef4
SHA1 (patch-ab) = e92e9ed2265debd1bf3607d83c3645a37acb4ffe SHA1 (patch-ab) = 7297b987c9195d5c111390aaa4dfd2c82df37bac
SHA1 (patch-ac) = b8e6f4aedfcc721055c280d23019e26ac4e05ca1 SHA1 (patch-ac) = 64e4f02e7ff14dee2016c33a4678eba2dc2951f0

View file

@ -1,14 +1,15 @@
$NetBSD: patch-ab,v 1.3 2007/05/30 05:58:11 schmonz Exp $ $NetBSD: patch-ab,v 1.4 2007/07/03 13:54:46 joerg Exp $
--- spamdyke/Makefile.orig 2007-05-24 18:55:10.000000000 -0400 --- spamdyke/Makefile.orig 2007-05-24 22:55:10.000000000 +0000
+++ spamdyke/Makefile +++ spamdyke/Makefile
@@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
#CFLAGS := -Wall -g -funsigned-char #CFLAGS := -Wall -g -funsigned-char
-CFLAGS := -Wall -O2 -funsigned-char -CFLAGS := -Wall -O2 -funsigned-char
+CFLAGS += -Wall -O2 -funsigned-char -LFLAGS := -lresolv
LFLAGS := -lresolv
-CFLAGS_TLS := -DTLS -CFLAGS_TLS := -DTLS
-LFLAGS_TLS := -lssl -lcrypto -LFLAGS_TLS := -lssl -lcrypto
+CFLAGS += -Wall -O2 -funsigned-char
+LFLAGS := ${RESOLV_DLFAGS}
+CFLAGS_TLS ?= -DTLS +CFLAGS_TLS ?= -DTLS
+LFLAGS_TLS ?= -lssl -lcrypto +LFLAGS_TLS ?= -lssl -lcrypto
OFILES := spamdyke.o command_line.o dns.o environment.o usage.o search_fs.o exec.o base64.o tls.o OFILES := spamdyke.o command_line.o dns.o environment.o usage.o search_fs.o exec.o base64.o tls.o

View file

@ -1,11 +1,13 @@
$NetBSD: patch-ac,v 1.4 2007/06/08 01:08:29 schmonz Exp $ $NetBSD: patch-ac,v 1.5 2007/07/03 13:54:46 joerg Exp $
--- utils/Makefile.orig 2007-06-05 22:51:35.000000000 -0400 --- utils/Makefile.orig 2007-06-06 02:51:35.000000000 +0000
+++ utils/Makefile +++ utils/Makefile
@@ -1,5 +1,5 @@ @@ -1,6 +1,6 @@
#CFLAGS := -Wall -g -funsigned-char -I../spamdyke #CFLAGS := -Wall -g -funsigned-char -I../spamdyke
-CFLAGS := -Wall -O2 -funsigned-char -I../spamdyke -CFLAGS := -Wall -O2 -funsigned-char -I../spamdyke
-LFLAGS := -lresolv
+CFLAGS += -Wall -O2 -funsigned-char -I../spamdyke +CFLAGS += -Wall -O2 -funsigned-char -I../spamdyke
LFLAGS := -lresolv +LFLAGS := ${RESOLV_LDFLAGS}
all: domain2path domainsplit dnstxt dnsptr dnsmx passwordcheck all: domain2path domainsplit dnstxt dnsptr dnsmx passwordcheck

66
mk/resolv.buildlink3.mk Normal file
View file

@ -0,0 +1,66 @@
# $NetBSD: resolv.buildlink3.mk,v 1.1 2007/07/03 13:54:45 joerg Exp $
#
# This Makefile fragment is included by package Makefiles and
# buildlink3.mk files for the packages that need a thread-safe
# DNS resolver..
#
# It defines the variables RESOLV_LDFLAGS and RESOLV_LIBS,
# which are also exported into the CONFIGURE_ENV and MAKE_ENV environments.
#
# Package-settable variables:
#
# RESOLV_AUTO_VARS
# When set to "yes", the necessary flags are added automatically
# to LDFLAGS and friends.
#
# Default: no
#
# Keywords: resolv
#
RESOLV_BUILDLINK3_MK:= ${RESOLV_BUILDLINK3_MK}+
.include "../../mk/bsd.fast.prefs.mk"
RESOLV_AUTO_VARS?= no
CHECK_BUILTIN.resolv= no
.if ${OPSYS} == "DragonFly" || ${OPSYS} == "FreeBSD"
USE_BUILTIN.resolv?= yes
BUILDLINK_LDFLAGS.resolv= # empty, in libc
.elif (${OPSYS} == "NetBSD" && empty(OS_VERSION:M[012].*)) || \
(${OPSYS} == "Darwin" && empty(OS_VERSION:M[0123467].*))
USE_BUILTIN.resolv?= yes
# BIND 9 resolver
BUILDLINK_LDFLAGS.resolv= -lresolv
.else
USE_BUILTIN.resolv?= no
.endif
.if !empty(USE_BUILTIN.resolv:M[yY][eE][sS])
BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Nresolv}
BUILDLINK_PACKAGES+= resolv
BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}resolv
BUILDLINK_AUTO_VARS.resolv= ${RESOLV_AUTO_VARS}
.else
. include "../../net/bind9/buildlink3.mk"
BUILDLINK_AUTO_VARS.bind= ${RESOLV_AUTO_VARS}
BUILDLINK_LDFLAGS.resolv= ${BUILDLINK_LDFLAGS.bind}
BUILDLINK_LIBS.resolv= ${BUILDLINK_LIBS.bind}
.endif
.if !empty(RESOLV_BUILDLINK3_MK:M+)
#
# Define user-visible RESOLV_{LDFLAGS,LIBS} as compiler options used
# to link code that needs a thread-safe DNS resolver.
#
RESOLV_LDFLAGS= ${BUILDLINK_LDFLAGS.resolv}
RESOLV_LIBS= ${BUILDLINK_LIBS.resolv}
CONFIGURE_ENV+= RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
CONFIGURE_ENV+= RESOLV_LIBS=${RESOLV_LIBS:Q}
MAKE_ENV+= RESOLV_LDFLAGS=${RESOLV_LDFLAGS:Q}
MAKE_ENV+= RESOLV_LIBS=${RESOLV_LIBS:Q}
.endif # RESOLV_BUILDLINK3_MK

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.31 2007/02/22 19:26:57 wiz Exp $ # $NetBSD: Makefile,v 1.32 2007/07/03 13:54:46 joerg Exp $
# #
DISTNAME= nocol-4.3.1 DISTNAME= nocol-4.3.1
@ -62,4 +62,5 @@ post-install:
${PREFIX}/share/nocol/gifs; \ ${PREFIX}/share/nocol/gifs; \
done done
.include "../../mk/resolv.buildlink3.mk"
.include "../../mk/bsd.pkg.mk" .include "../../mk/bsd.pkg.mk"

View file

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.9 2005/12/27 13:47:11 joerg Exp $ $NetBSD: distinfo,v 1.10 2007/07/03 13:54:46 joerg Exp $
SHA1 (nocol-4.3.1.tar.gz) = a8cb88727bc3a3ddd544792407d431b3ef13a325 SHA1 (nocol-4.3.1.tar.gz) = a8cb88727bc3a3ddd544792407d431b3ef13a325
RMD160 (nocol-4.3.1.tar.gz) = 77a57ae447f0a8f1ce2417d9b828710f21865cc8 RMD160 (nocol-4.3.1.tar.gz) = 77a57ae447f0a8f1ce2417d9b828710f21865cc8
@ -13,7 +13,7 @@ SHA1 (patch-ai) = d8317fad7c5e4574fa980859762f5acb1a7c631d
SHA1 (patch-aj) = 0eb201f47864132b04702fab4d03e452c07c2e2a SHA1 (patch-aj) = 0eb201f47864132b04702fab4d03e452c07c2e2a
SHA1 (patch-ak) = 8013fbe6dbff80749dbdc0d0fad391741e48a468 SHA1 (patch-ak) = 8013fbe6dbff80749dbdc0d0fad391741e48a468
SHA1 (patch-al) = aa4fa83d53c72e17ea9ffe2685f326ebbbde9132 SHA1 (patch-al) = aa4fa83d53c72e17ea9ffe2685f326ebbbde9132
SHA1 (patch-am) = 810cbecf5bb1f8a995579e8352be1007f09fa69e SHA1 (patch-am) = 395a5c446ac24cedf90783fc504c8817405d8e37
SHA1 (patch-an) = ed0e6099bdc29faf90de8b2916c858e8df57e493 SHA1 (patch-an) = ed0e6099bdc29faf90de8b2916c858e8df57e493
SHA1 (patch-ao) = 114ebcc55d00981cc6709095f3280509880d76eb SHA1 (patch-ao) = 114ebcc55d00981cc6709095f3280509880d76eb
SHA1 (patch-ap) = 45f30a886adda7831df056cf0f7a136b97a7e17d SHA1 (patch-ap) = 45f30a886adda7831df056cf0f7a136b97a7e17d

View file

@ -1,8 +1,25 @@
$NetBSD: patch-am,v 1.2 2005/12/27 13:47:11 joerg Exp $ $NetBSD: patch-am,v 1.3 2007/07/03 13:54:46 joerg Exp $
--- Configure.orig 2000-01-19 04:34:04.000000000 +0000 --- Configure.orig 2000-01-19 04:34:04.000000000 +0000
+++ Configure +++ Configure
@@ -207,7 +207,7 @@ case "$OS" in @@ -167,15 +167,7 @@ export PSFLAGS
(ps $PSFLAGS) 2>&1 | egrep -i '^usage' >/dev/null 2>&1
if [ $? = 0 ]; then PSFLAGS='-ef' ; fi
-LIBRESOLV="-lresolv"
-ls /usr/lib/libresolv* >/dev/null 2>&1
-if [ $? = 1 ]; then
- ls /lib/libresolv* >/dev/null 2>&1
- if [ $? = 1 ]; then
- ls /usr/lib/libbind* >/dev/null 2>&1
- if [ $? = 1 ]; then LIBRESOLV="" ; else LIBRESOLV="-lbind" ; fi
- fi
-fi
+LIBRESOLV="${RESOLV_LDFLAGS}"
# mainly for Solaris systems
WHOAMI="/usr/ucb/whoami"
@@ -207,7 +199,7 @@ case "$OS" in
OS_LIBS="${LIBRESOLV}" # -lcompat OS_LIBS="${LIBRESOLV}" # -lcompat
PING=`which ping` # can do ping -c cnt host PING=`which ping` # can do ping -c cnt host
;; ;;