From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Feb 14 07:50:16 2004 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7EF8516A4CE for ; Sat, 14 Feb 2004 07:50:16 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 77E9F43D39 for ; Sat, 14 Feb 2004 07:50:16 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i1EFoGbv069093 for ; Sat, 14 Feb 2004 07:50:16 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i1EFoGZ6069092; Sat, 14 Feb 2004 07:50:16 -0800 (PST) (envelope-from gnats) Resent-Date: Sat, 14 Feb 2004 07:50:16 -0800 (PST) Resent-Message-Id: <200402141550.i1EFoGZ6069092@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, hugo@meiland.nl Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E84816A4CE for ; Sat, 14 Feb 2004 07:48:12 -0800 (PST) Received: from chuck.gorlaeus.net (fwncdat06.leidenuniv.nl [132.229.170.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id 290DA43D1F for ; Sat, 14 Feb 2004 07:48:11 -0800 (PST) (envelope-from hugo@chuck.gorlaeus.net) Received: by chuck.gorlaeus.net (Postfix, from userid 1001) id 3720375; Sat, 14 Feb 2004 16:33:50 +0100 (CET) Message-Id: <20040214153350.3720375@chuck.gorlaeus.net> Date: Sat, 14 Feb 2004 16:33:50 +0100 (CET) From: hugo@meiland.nl To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: hugo@meiland.nl Subject: ports/62840: New Port: Bind9-sdb-ldap, bind9 patched for ldap back-end support X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: hugo@meiland.nl List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Feb 2004 15:50:16 -0000 >Number: 62840 >Category: ports >Synopsis: New Port: Bind9-sdb-ldap, bind9 patched for ldap back-end support >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Feb 14 07:50:16 PST 2004 >Closed-Date: >Last-Modified: >Originator: hugo meiland >Release: FreeBSD 4.9-RELEASE i386 >Organization: wirelessleiden.nl >Environment: System: FreeBSD chuck.gorlaeus.net 4.9-RELEASE FreeBSD 4.9-RELEASE #0: Mon Oct 27 17:51:09 GMT 2003 root@freebsd-stable.sentex.ca:/usr/obj/usr/src/sys/GENERIC i386 >Description: New Port: Bind9-sdb-ldap, bind9 patched for ldap back-end support >How-To-Repeat: >Fix: --- port.bind9-sdb-ldap begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # ./bind9-sdb-ldap # ./bind9-sdb-ldap/Makefile # ./bind9-sdb-ldap/distinfo # ./bind9-sdb-ldap/pkg-descr # ./bind9-sdb-ldap/pkg-message # ./bind9-sdb-ldap/pkg-plist # ./bind9-sdb-ldap/files # ./bind9-sdb-ldap/files/patch-sdb-ldap.diff # echo c - ./bind9-sdb-ldap mkdir -p ./bind9-sdb-ldap > /dev/null 2>&1 echo x - ./bind9-sdb-ldap/Makefile sed 's/^X//' >./bind9-sdb-ldap/Makefile << 'END-of-./bind9-sdb-ldap/Makefile' X# New ports collection makefile for: bind9-sdb-ldap X# Date created: 11 Februari 2004 X# Whom: hugo X# X# $FreeBSD$ X# X X# This is the LDAP supporting version of BIND, with the ldap patches X# by Venaas X# release you can generally build it cleanly from the source - Doug X XPORTNAME= bind9-sdb-ldap XPORTVERSION= 9.2.3 XCATEGORIES= dns XMASTER_SITES= ${MASTER_SITE_ISC} \ X ${MASTER_SITE_RINGSERVER:S,%SUBDIR%,dns/bind9/${ISCVERSION}/,} XMASTER_SITE_SUBDIR= bind9/${ISCVERSION} XDISTFILES= bind-${ISCVERSION}.tar.gz X XMAINTAINER= hugo@meiland.nl XCOMMENT= The BIND DNS server with ldap back-end support X X# ISC releases things like 9.2.2rc1, which our versioning doesn't like XISCVERSION= 9.2.3 X XGNU_CONFIGURE= yes XCONFIGURE_ARGS= --localstatedir=/var --disable-linux-caps --disable-threads \ X --with-randomdev=/dev/random --with-openssl X XUSE_OPENSSL= yes X X.if defined(PORT_REPLACES_BASE_BIND9) XPKGNAMESUFFIX= -base XPREFIX= /usr XBIND_DESTETC= /etc/namedb XCONFIGURE_ARGS+= --prefix=${PREFIX} \ X --sysconfdir=${BIND_DESTETC} \ X --mandir=${MANPREFIX}/man X.else XBIND_DESTETC= ${PREFIX}/etc X.endif X XPLIST_SUB= BIND_DESTETC="${BIND_DESTETC}" X XMAN1= dig.1 host.1 XMAN3= lwres.3 lwres_addr_parse.3 lwres_buffer.3 lwres_buffer_add.3 \ X lwres_buffer_back.3 lwres_buffer_clear.3 lwres_buffer_first.3 \ X lwres_buffer_forward.3 lwres_buffer_getmem.3 lwres_buffer_getuint16.3 \ X lwres_buffer_getuint32.3 lwres_buffer_getuint8.3 lwres_buffer_init.3 \ X lwres_buffer_invalidate.3 lwres_buffer_putmem.3 \ X lwres_buffer_putuint16.3 lwres_buffer_putuint32.3 \ X lwres_buffer_putuint8.3 lwres_buffer_subtract.3 lwres_conf_clear.3 \ X lwres_conf_get.3 lwres_conf_init.3 lwres_conf_parse.3 \ X lwres_conf_print.3 lwres_config.3 lwres_context.3 \ X lwres_context_allocmem.3 lwres_context_create.3 \ X lwres_context_destroy.3 lwres_context_freemem.3 \ X lwres_context_initserial.3 lwres_context_nextserial.3 \ X lwres_context_sendrecv.3 lwres_endhostent.3 lwres_endhostent_r.3 \ X lwres_freeaddrinfo.3 lwres_freehostent.3 lwres_gabn.3 \ X lwres_gabnrequest_free.3 lwres_gabnrequest_parse.3 \ X lwres_gabnrequest_render.3 lwres_gabnresponse_free.3 \ X lwres_gabnresponse_parse.3 lwres_gabnresponse_render.3 \ X lwres_gai_strerror.3 lwres_getaddrinfo.3 lwres_getaddrsbyname.3 \ X lwres_gethostbyaddr.3 lwres_gethostbyaddr_r.3 lwres_gethostbyname.3 \ X lwres_gethostbyname2.3 lwres_gethostbyname_r.3 lwres_gethostent.3 \ X lwres_gethostent_r.3 lwres_getipnode.3 lwres_getipnodebyaddr.3 \ X lwres_getipnodebyname.3 lwres_getnamebyaddr.3 lwres_getnameinfo.3 \ X lwres_getrrsetbyname.3 lwres_gnba.3 lwres_gnbarequest_free.3 \ X lwres_gnbarequest_parse.3 lwres_gnbarequest_render.3 \ X lwres_gnbaresponse_free.3 lwres_gnbaresponse_parse.3 \ X lwres_gnbaresponse_render.3 lwres_herror.3 lwres_hstrerror.3 \ X lwres_inetntop.3 lwres_lwpacket_parseheader.3 \ X lwres_lwpacket_renderheader.3 lwres_net_ntop.3 lwres_noop.3 \ X lwres_nooprequest_free.3 lwres_nooprequest_parse.3 \ X lwres_nooprequest_render.3 lwres_noopresponse_free.3 \ X lwres_noopresponse_parse.3 lwres_noopresponse_render.3 \ X lwres_packet.3 lwres_resutil.3 lwres_sethostent.3 \ X lwres_sethostent_r.3 lwres_string_parse.3 XMAN5= rndc.conf.5 XMAN8= dnssec-keygen.8 dnssec-makekeyset.8 dnssec-signkey.8 dnssec-signzone.8 \ X lwresd.8 named-checkconf.8 named-checkzone.8 named.8 nsupdate.8 \ X rndc-confgen.8 rndc.8 X XWRKSRC= ${WRKDIR}/bind-${ISCVERSION} Xpost-patch: X.for FILE in check/named-checkconf.8 named/named.8 nsupdate/nsupdate.8 \ X rndc/rndc.8 X @ ${MV} ${WRKSRC}/bin/${FILE} ${WRKSRC}/bin/${FILE}.Dist X @ ${SED} -e 's#/etc/named.conf#${BIND_DESTETC}/named.conf#g' \ X -e 's#/etc/rndc.conf#${BIND_DESTETC}/rndc.conf#g' \ X ${WRKSRC}/bin/${FILE}.Dist > ${WRKSRC}/bin/${FILE} X.endfor X Xpost-install: X ${INSTALL_DATA} ${WRKSRC}/bin/rndc/rndc.conf \ X ${BIND_DESTETC}/rndc.conf.sample X.if !defined(NOPORTDOCS) X ${MKDIR} ${DOCSDIR}/arm ${DOCSDIR}/misc X ${INSTALL_DATA} ${WRKSRC}/doc/arm/Bv9ARM*html ${DOCSDIR}/arm X ${INSTALL_DATA} ${WRKSRC}/doc/misc/[a-z]* ${DOCSDIR}/misc X ${CP} ${WRKSRC}/CHANGES ${WRKSRC}/COPYRIGHT ${WRKSRC}/FAQ \ X ${WRKSRC}/README ${DOCSDIR}/ X.endif X X @${CAT} ${PKGMESSAGE} X X.include END-of-./bind9-sdb-ldap/Makefile echo x - ./bind9-sdb-ldap/distinfo sed 's/^X//' >./bind9-sdb-ldap/distinfo << 'END-of-./bind9-sdb-ldap/distinfo' XMD5 (bind-9.2.3.tar.gz) = 94ae7b0f20dc406fdbbf6fac5d57b32f XSIZE (bind-9.2.3.tar.gz) = 4553260 END-of-./bind9-sdb-ldap/distinfo echo x - ./bind9-sdb-ldap/pkg-descr sed 's/^X//' >./bind9-sdb-ldap/pkg-descr << 'END-of-./bind9-sdb-ldap/pkg-descr' XThis port includes all the excellent features of the BIND9 DNS server, Xincluding support for an LDAP back-end. These patches were written by Venaas. X XWWW: http://www.venaas.no/ldap/bind-sdb/ X X- Hugoo Xhugo@meiland.nl END-of-./bind9-sdb-ldap/pkg-descr echo x - ./bind9-sdb-ldap/pkg-message sed 's/^X//' >./bind9-sdb-ldap/pkg-message << 'END-of-./bind9-sdb-ldap/pkg-message' X************************************************************************* X* _ _____ _____ _____ _ _ _____ ___ ___ _ _ * X* / \|_ _|_ _| ____| \ | |_ _|_ _/ _ \| \ | | * X* / _ \ | | | | | _| | \| | | | | | | | | \| | * X* / ___ \| | | | | |___| |\ | | | | | |_| | |\ | * X* /_/ \_\_| |_| |_____|_| \_| |_| |___\___/|_| \_| * X* * X* BIND 9 requires a good source of randomness to operate. * X* It also requires configuration of rndc, including a * X* "secret" key. If you are using FreeBSD 4.x, visit * X* http://people.freebsd.org/~dougb/randomness.html for * X* information on how to set up entropy gathering. Users * X* of FreeBSD 5.x do not need to perform this step. If * X* you are running BIND 9 in a chroot environment, make * X* sure that there is a /dev/random device in the chroot. * X* * X* The easiest, and most secure way to configure rndc is * X* to run 'rndc-confgen -a' which will generate the proper * X* conf file, with a new random key, and appropriate file * X* permissions. * X* * X************************************************************************* END-of-./bind9-sdb-ldap/pkg-message echo x - ./bind9-sdb-ldap/pkg-plist sed 's/^X//' >./bind9-sdb-ldap/pkg-plist << 'END-of-./bind9-sdb-ldap/pkg-plist' Xbin/dig Xbin/host Xbin/isc-config.sh Xbin/nslookup Xbin/nsupdate Xinclude/dns/a6.h Xinclude/dns/acl.h Xinclude/dns/adb.h Xinclude/dns/byaddr.h Xinclude/dns/cache.h Xinclude/dns/callbacks.h Xinclude/dns/cert.h Xinclude/dns/compress.h Xinclude/dns/db.h Xinclude/dns/dbiterator.h Xinclude/dns/dbtable.h Xinclude/dns/diff.h Xinclude/dns/dispatch.h Xinclude/dns/dnssec.h Xinclude/dns/enumclass.h Xinclude/dns/enumtype.h Xinclude/dns/events.h Xinclude/dns/fixedname.h Xinclude/dns/journal.h Xinclude/dns/keyflags.h Xinclude/dns/keytable.h Xinclude/dns/keyvalues.h Xinclude/dns/lib.h Xinclude/dns/log.h Xinclude/dns/master.h Xinclude/dns/masterdump.h Xinclude/dns/message.h Xinclude/dns/name.h Xinclude/dns/ncache.h Xinclude/dns/nxt.h Xinclude/dns/peer.h Xinclude/dns/rbt.h Xinclude/dns/rcode.h Xinclude/dns/rdata.h Xinclude/dns/rdataclass.h Xinclude/dns/rdatalist.h Xinclude/dns/rdataset.h Xinclude/dns/rdatasetiter.h Xinclude/dns/rdataslab.h Xinclude/dns/rdatastruct.h Xinclude/dns/rdatatype.h Xinclude/dns/request.h Xinclude/dns/resolver.h Xinclude/dns/result.h Xinclude/dns/rootns.h Xinclude/dns/sdb.h Xinclude/dns/secalg.h Xinclude/dns/secproto.h Xinclude/dns/soa.h Xinclude/dns/ssu.h Xinclude/dns/tcpmsg.h Xinclude/dns/time.h Xinclude/dns/tkey.h Xinclude/dns/tsig.h Xinclude/dns/ttl.h Xinclude/dns/types.h Xinclude/dns/validator.h Xinclude/dns/view.h Xinclude/dns/xfrin.h Xinclude/dns/zone.h Xinclude/dns/zonekey.h Xinclude/dns/zt.h Xinclude/dst/dst.h Xinclude/dst/lib.h Xinclude/dst/result.h Xinclude/isc/app.h Xinclude/isc/assertions.h Xinclude/isc/base64.h Xinclude/isc/bitstring.h Xinclude/isc/boolean.h Xinclude/isc/buffer.h Xinclude/isc/bufferlist.h Xinclude/isc/commandline.h Xinclude/isc/condition.h Xinclude/isc/dir.h Xinclude/isc/entropy.h Xinclude/isc/error.h Xinclude/isc/event.h Xinclude/isc/eventclass.h Xinclude/isc/file.h Xinclude/isc/formatcheck.h Xinclude/isc/fsaccess.h Xinclude/isc/heap.h Xinclude/isc/hex.h Xinclude/isc/hmacmd5.h Xinclude/isc/int.h Xinclude/isc/interfaceiter.h Xinclude/isc/lang.h Xinclude/isc/lex.h Xinclude/isc/lfsr.h Xinclude/isc/lib.h Xinclude/isc/list.h Xinclude/isc/log.h Xinclude/isc/magic.h Xinclude/isc/md5.h Xinclude/isc/mem.h Xinclude/isc/msgcat.h Xinclude/isc/msgs.h Xinclude/isc/mutex.h Xinclude/isc/mutexblock.h Xinclude/isc/net.h Xinclude/isc/netaddr.h Xinclude/isc/netdb.h Xinclude/isc/offset.h Xinclude/isc/once.h Xinclude/isc/ondestroy.h Xinclude/isc/os.h Xinclude/isc/platform.h Xinclude/isc/print.h Xinclude/isc/quota.h Xinclude/isc/random.h Xinclude/isc/ratelimiter.h Xinclude/isc/refcount.h Xinclude/isc/region.h Xinclude/isc/resource.h Xinclude/isc/result.h Xinclude/isc/resultclass.h Xinclude/isc/rwlock.h Xinclude/isc/serial.h Xinclude/isc/sha1.h Xinclude/isc/sockaddr.h Xinclude/isc/socket.h Xinclude/isc/stdio.h Xinclude/isc/stdtime.h Xinclude/isc/string.h Xinclude/isc/symtab.h Xinclude/isc/syslog.h Xinclude/isc/task.h Xinclude/isc/taskpool.h Xinclude/isc/thread.h Xinclude/isc/time.h Xinclude/isc/timer.h Xinclude/isc/types.h Xinclude/isc/util.h Xinclude/isccc/alist.h Xinclude/isccc/base64.h Xinclude/isccc/cc.h Xinclude/isccc/ccmsg.h Xinclude/isccc/events.h Xinclude/isccc/lib.h Xinclude/isccc/result.h Xinclude/isccc/sexpr.h Xinclude/isccc/symtab.h Xinclude/isccc/symtype.h Xinclude/isccc/types.h Xinclude/isccc/util.h Xinclude/isccfg/cfg.h Xinclude/isccfg/check.h Xinclude/isccfg/log.h Xinclude/lwres/context.h Xinclude/lwres/int.h Xinclude/lwres/ipv6.h Xinclude/lwres/lang.h Xinclude/lwres/list.h Xinclude/lwres/lwbuffer.h Xinclude/lwres/lwpacket.h Xinclude/lwres/lwres.h Xinclude/lwres/net.h Xinclude/lwres/netdb.h Xinclude/lwres/platform.h Xinclude/lwres/result.h Xlib/libdns.a Xlib/libisc.a Xlib/libisccc.a Xlib/libisccfg.a Xlib/liblwres.a Xsbin/dnssec-keygen Xsbin/dnssec-makekeyset Xsbin/dnssec-signkey Xsbin/dnssec-signzone Xsbin/lwresd Xsbin/named Xsbin/named-checkconf Xsbin/named-checkzone Xsbin/rndc Xsbin/rndc-confgen X%%PORTDOCS%%%%DOCSDIR%%/CHANGES X%%PORTDOCS%%%%DOCSDIR%%/COPYRIGHT X%%PORTDOCS%%%%DOCSDIR%%/FAQ X%%PORTDOCS%%%%DOCSDIR%%/README X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch01.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch02.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch03.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch04.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch05.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch06.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch07.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch08.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.ch09.html X%%PORTDOCS%%%%DOCSDIR%%/arm/Bv9ARM.html X%%PORTDOCS%%%%DOCSDIR%%/misc/dnssec X%%PORTDOCS%%%%DOCSDIR%%/misc/format-options.pl X%%PORTDOCS%%%%DOCSDIR%%/misc/ipv6 X%%PORTDOCS%%%%DOCSDIR%%/misc/migration X%%PORTDOCS%%%%DOCSDIR%%/misc/migration-4to9 X%%PORTDOCS%%%%DOCSDIR%%/misc/options X%%PORTDOCS%%%%DOCSDIR%%/misc/rfc-compliance X%%PORTDOCS%%%%DOCSDIR%%/misc/roadmap X%%PORTDOCS%%%%DOCSDIR%%/misc/sdb X%%PORTDOCS%%@dirrm %%DOCSDIR%%/arm X%%PORTDOCS%%@dirrm %%DOCSDIR%%/misc X%%PORTDOCS%%@dirrm %%DOCSDIR%% X@unexec rm -f %%BIND_DESTETC%%/rndc.conf.sample X@dirrm include/dns X@dirrm include/dst X@unexec rmdir %D/include/isc 2>/dev/null || true X@dirrm include/isccc X@dirrm include/isccfg X@dirrm include/lwres END-of-./bind9-sdb-ldap/pkg-plist echo c - ./bind9-sdb-ldap/files mkdir -p ./bind9-sdb-ldap/files > /dev/null 2>&1 echo x - ./bind9-sdb-ldap/files/patch-sdb-ldap.diff sed 's/^X//' >./bind9-sdb-ldap/files/patch-sdb-ldap.diff << 'END-of-./bind9-sdb-ldap/files/patch-sdb-ldap.diff' Xdiff -Pru ../bind-9.2.3-old/bin/named/Makefile.in ./bin/named/Makefile.in X--- ../bind-9.2.3-old/bin/named/Makefile.in Fri Jun 1 02:45:00 2001 X+++ ./bin/named/Makefile.in Tue Feb 3 23:06:13 2004 X@@ -26,10 +26,10 @@ X # X # Add database drivers here. X # X-DBDRIVER_OBJS = X-DBDRIVER_SRCS = X-DBDRIVER_INCLUDES = X-DBDRIVER_LIBS = X+DBDRIVER_OBJS = ldapdb.@O@ X+DBDRIVER_SRCS = ldapdb.c X+DBDRIVER_INCLUDES = -I/usr/local/include X+DBDRIVER_LIBS = -L/usr/local/lib -lldap -llber X X CINCLUDES = -I${srcdir}/include -I${srcdir}/unix/include \ X ${LWRES_INCLUDES} ${DNS_INCLUDES} \ Xdiff -Pru ../bind-9.2.3-old/bin/named/include/ldapdb.h ./bin/named/include/ldapdb.h X--- ../bind-9.2.3-old/bin/named/include/ldapdb.h Thu Jan 1 01:00:00 1970 X+++ ./bin/named/include/ldapdb.h Tue Feb 3 23:08:37 2004 X@@ -0,0 +1,6 @@ X+#include X+ X+isc_result_t ldapdb_init(void); X+ X+void ldapdb_clear(void); X+ Xdiff -Pru ../bind-9.2.3-old/bin/named/ldapdb.c ./bin/named/ldapdb.c X--- ../bind-9.2.3-old/bin/named/ldapdb.c Thu Jan 1 01:00:00 1970 X+++ ./bin/named/ldapdb.c Tue Feb 3 23:08:19 2004 X@@ -0,0 +1,552 @@ X+/* X+ * ldapdb.c version 0.9 X+ * X+ * Copyright (C) 2002 Stig Venaas X+ * X+ * Permission to use, copy, modify, and distribute this software for any X+ * purpose with or without fee is hereby granted, provided that the above X+ * copyright notice and this permission notice appear in all copies. X+ */ X+ X+/* X+ * If you are using an old LDAP API uncomment the define below. Only do this X+ * if you know what you're doing or get compilation errors on ldap_memfree(). X+ */ X+/* #define RFC1823API */ X+ X+#include X+ X+#include X+#include X+#include X+#include X+ X+#include X+#include X+#include X+#include X+#include X+ X+#include X+ X+#include X+#include X+ X+#include X+#include "ldapdb.h" X+ X+/* X+ * A simple database driver for LDAP X+ */ X+ X+/* enough for name with 8 labels of max length */ X+#define MAXNAMELEN 519 X+ X+static dns_sdbimplementation_t *ldapdb = NULL; X+ X+struct ldapdb_data { X+ char *hostport; X+ char *hostname; X+ int portno; X+ char *base; X+ int defaultttl; X+ char *filterall; X+ int filteralllen; X+ char *filterone; X+ int filteronelen; X+ char *filtername; X+}; X+ X+/* used by ldapdb_getconn */ X+ X+struct ldapdb_entry { X+ void *index; X+ size_t size; X+ void *data; X+ struct ldapdb_entry *next; X+}; X+ X+static struct ldapdb_entry *ldapdb_find(struct ldapdb_entry *stack, X+ const void *index, size_t size) { X+ while (stack != NULL) { X+ if (stack->size == size && !memcmp(stack->index, index, size)) X+ return stack; X+ stack = stack->next; X+ } X+ return NULL; X+} X+ X+static void ldapdb_insert(struct ldapdb_entry **stack, X+ struct ldapdb_entry *item) { X+ item->next = *stack; X+ *stack = item; X+} X+ X+static void ldapdb_lock(int what) { X+ static isc_mutex_t lock; X+ X+ switch (what) { X+ case 0: X+ isc_mutex_init(&lock); X+ break; X+ case 1: X+ LOCK(&lock); X+ break; X+ case -1: X+ UNLOCK(&lock); X+ break; X+ } X+} X+ X+/* data == NULL means cleanup */ X+static LDAP ** X+ldapdb_getconn(struct ldapdb_data *data) X+{ X+ static struct ldapdb_entry *allthreadsdata = NULL; X+ struct ldapdb_entry *threaddata, *conndata; X+ unsigned long threadid; X+ X+ if (data == NULL) { X+ /* cleanup */ X+ /* lock out other threads */ X+ ldapdb_lock(1); X+ while (allthreadsdata != NULL) { X+ threaddata = allthreadsdata; X+ free(threaddata->index); X+ while (threaddata->data != NULL) { X+ conndata = threaddata->data; X+ free(conndata->index); X+ if (conndata->data != NULL) X+ ldap_unbind((LDAP *)conndata->data); X+ threaddata->data = conndata->next; X+ free(conndata); X+ } X+ allthreadsdata = threaddata->next; X+ free(threaddata); X+ } X+ ldapdb_lock(-1); X+ return (NULL); X+ } X+ X+ /* look for connection data for current thread */ X+ threadid = isc_thread_self(); X+ threaddata = ldapdb_find(allthreadsdata, &threadid, sizeof(threadid)); X+ if (threaddata == NULL) { X+ /* no data for this thread, create empty connection list */ X+ threaddata = malloc(sizeof(*threaddata)); X+ if (threaddata == NULL) X+ return (NULL); X+ threaddata->index = malloc(sizeof(threadid)); X+ if (threaddata->index == NULL) { X+ free(threaddata); X+ return (NULL); X+ } X+ *(unsigned long *)threaddata->index = threadid; X+ threaddata->size = sizeof(threadid); X+ threaddata->data = NULL; X+ X+ /* need to lock out other threads here */ X+ ldapdb_lock(1); X+ ldapdb_insert(&allthreadsdata, threaddata); X+ ldapdb_lock(-1); X+ } X+ X+ /* threaddata points at the connection list for current thread */ X+ /* look for existing connection to our server */ X+ conndata = ldapdb_find((struct ldapdb_entry *)threaddata->data, X+ data->hostport, strlen(data->hostport)); X+ if (conndata == NULL) { X+ /* no connection data structure for this server, create one */ X+ conndata = malloc(sizeof(*conndata)); X+ if (conndata == NULL) X+ return (NULL); X+ (char *)conndata->index = data->hostport; X+ conndata->size = strlen(data->hostport); X+ conndata->data = NULL; X+ ldapdb_insert((struct ldapdb_entry **)&threaddata->data, X+ conndata); X+ } X+ X+ return (LDAP **)&conndata->data; X+} X+ X+static void X+ldapdb_bind(struct ldapdb_data *data, LDAP **ldp) X+{ X+ if (*ldp != NULL) X+ ldap_unbind(*ldp); X+ *ldp = ldap_open(data->hostname, data->portno); X+ if (*ldp == NULL) X+ return; X+ if (ldap_simple_bind_s(*ldp, NULL, NULL) != LDAP_SUCCESS) { X+ ldap_unbind(*ldp); X+ *ldp = NULL; X+ } X+} X+ X+static isc_result_t X+ldapdb_search(const char *zone, const char *name, void *dbdata, void *retdata) X+{ X+ struct ldapdb_data *data = dbdata; X+ isc_result_t result = ISC_R_NOTFOUND; X+ LDAP **ldp; X+ LDAPMessage *res, *e; X+ char *fltr, *a, **vals, **names; X+ char type[64]; X+#ifdef RFC1823API X+ void *ptr; X+#else X+ BerElement *ptr; X+#endif X+ int i, j, errno, msgid; X+ X+ ldp = ldapdb_getconn(data); X+ if (ldp == NULL) X+ return (ISC_R_FAILURE); X+ if (*ldp == NULL) { X+ ldapdb_bind(data, ldp); X+ if (*ldp == NULL) { X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': bind failed", zone); X+ return (ISC_R_FAILURE); X+ } X+ } X+ X+ if (name == NULL) { X+ fltr = data->filterall; X+ } else { X+ if (strlen(name) > MAXNAMELEN) { X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': name %s too long", zone, name); X+ return (ISC_R_FAILURE); X+ } X+ sprintf(data->filtername, "%s))", name); X+ fltr = data->filterone; X+ } X+ X+ msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0); X+ if (msgid == -1) { X+ ldapdb_bind(data, ldp); X+ if (*ldp != NULL) X+ msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0); X+ } X+ X+ if (*ldp == NULL || msgid == -1) { X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': search failed, filter %s", zone, fltr); X+ return (ISC_R_FAILURE); X+ } X+ X+ /* Get the records one by one as they arrive and return them to bind */ X+ while ((errno = ldap_result(*ldp, msgid, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) { X+ LDAP *ld = *ldp; X+ int ttl = data->defaultttl; X+ X+ /* not supporting continuation references at present */ X+ if (errno != LDAP_RES_SEARCH_ENTRY) { X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': ldap_result returned %d", zone, errno); X+ ldap_msgfree(res); X+ return (ISC_R_FAILURE); X+ } X+ X+ /* only one entry per result message */ X+ e = ldap_first_entry(ld, res); X+ if (e == NULL) { X+ ldap_msgfree(res); X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': ldap_first_entry failed", zone); X+ return (ISC_R_FAILURE); X+ } X+ X+ if (name == NULL) { X+ names = ldap_get_values(ld, e, "relativeDomainName"); X+ if (names == NULL) X+ continue; X+ } X+ X+ vals = ldap_get_values(ld, e, "dNSTTL"); X+ if (vals != NULL) { X+ ttl = atoi(vals[0]); X+ ldap_value_free(vals); X+ } X+ X+ for (a = ldap_first_attribute(ld, e, &ptr); a != NULL; a = ldap_next_attribute(ld, e, ptr)) { X+ char *s; X+ X+ for (s = a; *s; s++) X+ *s = toupper(*s); X+ s = strstr(a, "RECORD"); X+ if ((s == NULL) || (s == a) || (s - a >= (signed int)sizeof(type))) { X+#ifndef RFC1823API X+ ldap_memfree(a); X+#endif X+ continue; X+ } X+ X+ strncpy(type, a, s - a); X+ type[s - a] = '\0'; X+ vals = ldap_get_values(ld, e, a); X+ if (vals != NULL) { X+ for (i = 0; vals[i] != NULL; i++) { X+ if (name != NULL) { X+ result = dns_sdb_putrr(retdata, type, ttl, vals[i]); X+ } else { X+ for (j = 0; names[j] != NULL; j++) { X+ result = dns_sdb_putnamedrr(retdata, names[j], type, ttl, vals[i]); X+ if (result != ISC_R_SUCCESS) X+ break; X+ } X+ } X+; if (result != ISC_R_SUCCESS) { X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': dns_sdb_put... failed for %s", zone, vals[i]); X+ ldap_value_free(vals); X+#ifndef RFC1823API X+ ldap_memfree(a); X+ if (ptr != NULL) X+ ber_free(ptr, 0); X+#endif X+ if (name == NULL) X+ ldap_value_free(names); X+ ldap_msgfree(res); X+ return (ISC_R_FAILURE); X+ } X+ } X+ ldap_value_free(vals); X+ } X+#ifndef RFC1823API X+ ldap_memfree(a); X+#endif X+ } X+#ifndef RFC1823API X+ if (ptr != NULL) X+ ber_free(ptr, 0); X+#endif X+ if (name == NULL) X+ ldap_value_free(names); X+ X+ /* cleanup this result */ X+ ldap_msgfree(res); X+ } X+ X+ return (result); X+} X+ X+ X+/* callback routines */ X+static isc_result_t X+ldapdb_lookup(const char *zone, const char *name, void *dbdata, X+ dns_sdblookup_t *lookup) X+{ X+ return ldapdb_search(zone, name, dbdata, lookup); X+} X+ X+static isc_result_t X+ldapdb_allnodes(const char *zone, void *dbdata, X+ dns_sdballnodes_t *allnodes) X+{ X+ return ldapdb_search(zone, NULL, dbdata, allnodes); X+} X+ X+static char * X+unhex(char *in) X+{ X+ static const char hexdigits[] = "0123456789abcdef"; X+ char *p, *s = in; X+ int d1, d2; X+ X+ while ((s = strchr(s, '%'))) { X+ if (!(s[1] && s[2])) X+ return NULL; X+ if ((p = strchr(hexdigits, tolower(s[1]))) == NULL) X+ return NULL; X+ d1 = p - hexdigits; X+ if ((p = strchr(hexdigits, tolower(s[2]))) == NULL) X+ return NULL; X+ d2 = p - hexdigits; X+ *s++ = d1 << 4 | d2; X+ memmove(s, s + 2, strlen(s) - 1); X+ } X+ return in; X+} X+ X+ X+ X+static void X+free_data(struct ldapdb_data *data) X+{ X+ if (data->hostport != NULL) X+ isc_mem_free(ns_g_mctx, data->hostport); X+ if (data->hostname != NULL) X+ isc_mem_free(ns_g_mctx, data->hostname); X+ if (data->filterall != NULL) X+ isc_mem_put(ns_g_mctx, data->filterall, data->filteralllen); X+ if (data->filterone != NULL) X+ isc_mem_put(ns_g_mctx, data->filterone, data->filteronelen); X+ isc_mem_put(ns_g_mctx, data, sizeof(struct ldapdb_data)); X+} X+ X+ X+static isc_result_t X+ldapdb_create(const char *zone, int argc, char **argv, X+ void *driverdata, void **dbdata) X+{ X+ struct ldapdb_data *data; X+ char *s, *filter = NULL; X+ int defaultttl; X+ X+ UNUSED(driverdata); X+ X+ /* we assume that only one thread will call create at a time */ X+ /* want to do this only once for all instances */ X+ X+ if ((argc < 2) X+ || (argv[0] != strstr( argv[0], "ldap://")) X+ || ((defaultttl = atoi(argv[1])) < 1)) X+ return (ISC_R_FAILURE); X+ data = isc_mem_get(ns_g_mctx, sizeof(struct ldapdb_data)); X+ if (data == NULL) X+ return (ISC_R_NOMEMORY); X+ X+ memset(data, 0, sizeof(struct ldapdb_data)); X+ data->hostport = isc_mem_strdup(ns_g_mctx, argv[0] + strlen("ldap://")); X+ if (data->hostport == NULL) { X+ free_data(data); X+ return (ISC_R_NOMEMORY); X+ } X+ X+ data->defaultttl = defaultttl; X+ X+ s = strchr(data->hostport, '/'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ data->base = s; X+ /* attrs, scope, filter etc? */ X+ s = strchr(s, '?'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ /* ignore attributes */ X+ s = strchr(s, '?'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ /* ignore scope */ X+ s = strchr(s, '?'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ /* filter */ X+ filter = s; X+ s = strchr(s, '?'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ } X+ if (*filter == '\0') { X+ filter = NULL; X+ } X+ } X+ } X+ } X+ if (*data->base == '\0') { X+ data->base = NULL; X+ } X+ X+ if ((data->base != NULL && unhex(data->base) == NULL) || (filter != NULL && unhex(filter) == NULL)) { X+ free_data(data); X+ isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER, ISC_LOG_ERROR, X+ "LDAP sdb zone '%s': bad hex values", zone); X+ return (ISC_R_FAILURE); X+ } X+ } X+ X+ /* compute filterall and filterone once and for all */ X+ if (filter == NULL) { X+ data->filteralllen = strlen(zone) + strlen("(zoneName=)") + 1; X+ data->filteronelen = strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1; X+ } else { X+ data->filteralllen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=))") + 1; X+ data->filteronelen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1; X+ } X+ X+ data->filterall = isc_mem_get(ns_g_mctx, data->filteralllen); X+ if (data->filterall == NULL) { X+ free_data(data); X+ return (ISC_R_NOMEMORY); X+ } X+ data->filterone = isc_mem_get(ns_g_mctx, data->filteronelen); X+ if (data->filterone == NULL) { X+ free_data(data); X+ return (ISC_R_NOMEMORY); X+ } X+ X+ if (filter == NULL) { X+ sprintf(data->filterall, "(zoneName=%s)", zone); X+ sprintf(data->filterone, "(&(zoneName=%s)(relativeDomainName=", zone); X+ } else { X+ sprintf(data->filterall, "(&%s(zoneName=%s))", filter, zone); X+ sprintf(data->filterone, "(&%s(zoneName=%s)(relativeDomainName=", filter, zone); X+ } X+ data->filtername = data->filterone + strlen(data->filterone); X+ X+ /* support URLs with literal IPv6 addresses */ X+ data->hostname = isc_mem_strdup(ns_g_mctx, data->hostport + (*data->hostport == '[' ? 1 : 0)); X+ if (data->hostname == NULL) { X+ free_data(data); X+ return (ISC_R_NOMEMORY); X+ } X+ X+ if (*data->hostport == '[' && X+ (s = strchr(data->hostname, ']')) != NULL ) X+ *s++ = '\0'; X+ else X+ s = data->hostname; X+ s = strchr(s, ':'); X+ if (s != NULL) { X+ *s++ = '\0'; X+ data->portno = atoi(s); X+ } else X+ data->portno = LDAP_PORT; X+ X+ *dbdata = data; X+ return (ISC_R_SUCCESS); X+} X+ X+static void X+ldapdb_destroy(const char *zone, void *driverdata, void **dbdata) { X+ struct ldapdb_data *data = *dbdata; X+ X+ UNUSED(zone); X+ UNUSED(driverdata); X+ X+ free_data(data); X+} X+ X+static dns_sdbmethods_t ldapdb_methods = { X+ ldapdb_lookup, X+ NULL, /* authority */ X+ ldapdb_allnodes, X+ ldapdb_create, X+ ldapdb_destroy X+}; X+ X+/* Wrapper around dns_sdb_register() */ X+isc_result_t X+ldapdb_init(void) { X+ unsigned int flags = X+ DNS_SDBFLAG_RELATIVEOWNER | X+ DNS_SDBFLAG_RELATIVERDATA | X+ DNS_SDBFLAG_THREADSAFE; X+ X+ ldapdb_lock(0); X+ return (dns_sdb_register("ldap", &ldapdb_methods, NULL, flags, X+ ns_g_mctx, &ldapdb)); X+} X+ X+/* Wrapper around dns_sdb_unregister() */ X+void X+ldapdb_clear(void) { X+ if (ldapdb != NULL) { X+ /* clean up thread data */ X+ ldapdb_getconn(NULL); X+ dns_sdb_unregister(&ldapdb); X+ } X+} Xdiff -Pru ../bind-9.2.3-old/bin/named/main.c ./bin/named/main.c X--- ../bind-9.2.3-old/bin/named/main.c Thu Oct 9 09:32:33 2003 X+++ ./bin/named/main.c Tue Feb 3 23:07:28 2004 X@@ -64,6 +64,7 @@ X * Include header files for database drivers here. X */ X /* #include "xxdb.h" */ X+#include "ldapdb.h" X X static isc_boolean_t want_stats = ISC_FALSE; X static char program_name[ISC_DIR_NAMEMAX] = "named"; X@@ -544,6 +545,7 @@ X * Add calls to register sdb drivers here. X */ X /* xxdb_init(); */ X+ ldapdb_init (); X X ns_server_create(ns_g_mctx, &ns_g_server); X } X@@ -558,6 +560,7 @@ X * Add calls to unregister sdb drivers here. X */ X /* xxdb_clear(); */ X+ ldapdb_clear (); X X isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, X ISC_LOG_NOTICE, "exiting"); END-of-./bind9-sdb-ldap/files/patch-sdb-ldap.diff exit --- port.bind9-sdb-ldap ends here --- >Release-Note: >Audit-Trail: >Unformatted: