Index: MESSAGE
===================================================================
RCS file: MESSAGE
diff -N MESSAGE
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MESSAGE	9 Nov 2005 22:12:02 -0000	1.1
@@ -0,0 +1,21 @@
+===========================================================================
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+
+ * Before starting the OpenLDAP server slapd, you must either make 
+   ${VARBASE}/openldap, or else set slapd_chrootdir in /etc/rc.conf to a 
+   chroot jail for slapd.  I suggest the chroot jail.
+
+ * You should set the rootdn password in ${PKG_SYSCONFDIR}/slapd.conf 
+   before starting slapd.
+
+ * slapd listens by default on a Unix-domain socket.  To listen on all 
+   interfaces, add 
+
+	slapd_flags="-h ldapi:/// -h ldap:///"
+
+   to /etc/rc.conf
+
+ * slapd logs diagnostics to syslog with priority LOG_DEBUG, so you may 
+   have to edit /etc/syslog.conf to see its error messages.
+
+===========================================================================
Index: Makefile
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/Makefile,v
retrieving revision 1.1.1.10
retrieving revision 1.3
diff -u -r1.1.1.10 -r1.3
--- Makefile	29 Aug 2005 20:04:10 -0000	1.1.1.10
+++ Makefile	9 Nov 2005 22:18:04 -0000	1.3
@@ -15,23 +15,41 @@
 
 PKG_INSTALLATION_TYPES=	overwrite pkgviews
 
+USE_TOOLS+=		gtar
 USE_LIBTOOL=		yes
 GNU_CONFIGURE=		yes
 TEST_TARGET=		test
 
 MAKE_ENV+=		LIBMODE=${LIBMODE}
-OPENLDAP_ETCDIR=	${PKG_SYSCONFDIR}/openldap
+# slapd opens /var/run/ldapi and /var/run/log sockets before chroot.
+MAKE_ENV+=		DEFINES=" -DLDAPI_SOCK=\\\"${VARBASE:Q}/run/ldapi\\\" "
+PKG_SYSCONFSUBDIR?=	openldap
+OPENLDAP_ETCDIR=	${PKG_SYSCONFDIR}
 OPENLDAP_MODULEDIR=	${PREFIX}/lib/openldap
 OPENLDAP_VARDIR=	${VARBASE}/openldap
+OPENLDAP_USER?=		openldap
+OPENLDAP_GROUP?=	openldap
 FILES_SUBST+=		OPENLDAP_ETCDIR=${OPENLDAP_ETCDIR:Q}
+FILES_SUBST+=		OPENLDAP_USER=${OPENLDAP_USER}
+FILES_SUBST+=		OPENLDAP_GROUP=${OPENLDAP_GROUP}
+FILES_SUBST+=		ROOT_USER=${ROOT_USER}
+MESSAGE_SUBST+=		VARBASE=${VARBASE:Q}
 
 .include "../../mk/bsd.prefs.mk"
 .include "options.mk"
 
+.if ${OPSYS} == "FreeBSD"
+FILES_SUBST+=		FREEBSD_PWDMKDB_ETC=/etc
+.else
+FILES_SUBST+=		FREEBSD_PWDMKDB_ETC=
+.endif
+
 CPPFLAGS.Darwin+=	-DBIND_8_COMPAT
 
 CONFIGURE_ARGS+=	--sysconfdir=${PKG_SYSCONFDIR:Q}
 CONFIGURE_ARGS+=	--localstatedir=${OPENLDAP_VARDIR:Q}
+CONFIGURE_ARGS+=	--datadir=${PREFIX}/share/openldap
+CONFIGURE_ARGS+=	--without-subdir
 CONFIGURE_ARGS+=	--enable-dynamic   # link servers against shared libs
 CONFIGURE_ARGS+=	--with-tls=openssl
 
@@ -53,16 +71,13 @@
 .endfor
 .undef _mod_
 
-OPENLDAP_FILEPERMS=	${ROOT_USER} ${ROOT_GROUP} 0600
-OPENLDAP_DIRPERMS=	${ROOT_USER} ${ROOT_GROUP} 0700
+OPENLDAP_FILEPERMS=	${ROOT_USER} ${OPENLDAP_GROUP} 0640
 
 USE_PKGINSTALL=		yes
 EGDIR=			${PREFIX}/share/examples/openldap
 MAKE_DIRS=		${OPENLDAP_ETCDIR} ${OPENLDAP_ETCDIR}/schema
-OWN_DIRS=		${OPENLDAP_VARDIR} ${OPENLDAP_VARDIR}/run
-OWN_DIRS_PERMS=		${OPENLDAP_VARDIR}/openldap-data ${OPENLDAP_DIRPERMS}
-OWN_DIRS_PERMS+=	${OPENLDAP_VARDIR}/openldap-ldbm ${OPENLDAP_DIRPERMS}
-OWN_DIRS_PERMS+=	${OPENLDAP_VARDIR}/openldap-slurp ${OPENLDAP_DIRPERMS}
+PKG_GROUPS=		${OPENLDAP_GROUP}
+PKG_USERS=		${OPENLDAP_USER}:${OPENLDAP_GROUP}::OpenLDAP\ pseudo-user
 
 CNFS=			ldap.conf ${CNFS_SCHEMAS_cmd:sh}
 CNFS_SCHEMAS_cmd=	${SED} -ne "/\.schema$$/{ s,share/examples/openldap/,,; p; }" ${PKGDIR}/PLIST
@@ -79,6 +94,20 @@
 .endfor
 RCD_SCRIPTS=		slapd
 
+.if ${:!hostname!:S/./ /g:[\#]} < 3
+temp_LDAP_BASE=		nonce example org
+.else
+temp_LDAP_BASE=		${:!hostname!:S/./ /g}
+.endif
+LDAP_BASE?=		${temp_LDAP_BASE:[2..-1]:S/^/dc=/:ts,}
+CNF_SUBST+=		LDAP_BASE=${LDAP_BASE:Q}
+BUILD_DEFS+=		LDAP_BASE
+
+SUBST_CLASSES+=		cnf
+SUBST_STAGE.cnf=	pre-configure
+SUBST_FILES.cnf=	libraries/libldap/ldap.conf servers/slapd/slapd.conf
+SUBST_SED.cnf=		${CNF_SUBST:S/=/@!/:S/$/!g/:S/^/ -e s!@/}
+
 PTHREAD_OPTS+=		require
 
 .include "../../security/openssl/buildlink3.mk"
Index: PLIST
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/PLIST,v
retrieving revision 1.1.1.9
retrieving revision 1.2
diff -u -r1.1.1.9 -r1.2
--- PLIST	29 Aug 2005 20:04:10 -0000	1.1.1.9
+++ PLIST	9 Nov 2005 22:12:02 -0000	1.2
@@ -233,8 +233,6 @@
 share/examples/openldap/schema/nis.schema
 share/examples/openldap/schema/openldap.schema
 share/examples/openldap/slapd.conf
-share/examples/rc.d/slurpd
-share/examples/rc.d/slapd
 share/openldap/ucdata/case.dat
 share/openldap/ucdata/cmbcl.dat
 share/openldap/ucdata/comp.dat
@@ -242,3 +240,4 @@
 share/openldap/ucdata/decomp.dat
 share/openldap/ucdata/kdecomp.dat
 share/openldap/ucdata/num.dat
+@unexec ${RM} -f %D/share/openldap/ucdata/.chroot_timestamp
Index: distinfo
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/distinfo,v
retrieving revision 1.1.1.8
retrieving revision 1.3
diff -u -r1.1.1.8 -r1.3
--- distinfo	29 Aug 2005 20:04:10 -0000	1.1.1.8
+++ distinfo	11 Nov 2005 01:33:21 -0000	1.3
@@ -5,10 +5,14 @@
 Size (openldap-2.2.27.tgz) = 2628140 bytes
 SHA1 (patch-ac) = 473ad88f580ef60d520647033901d8070382ba11
 SHA1 (patch-ad) = ca8efe627797c83e97ff0f4a905b73a346d0b25a
-SHA1 (patch-af) = 7b2f7e0e6cd545a371dba06433ae306f50b40c82
-SHA1 (patch-ag) = 4221d6762ccb9e253e4ad9f98d64ad86c4c4c66b
+SHA1 (patch-af) = 8479e8754a0d93a6c318c4bba3b4363d69688854
+SHA1 (patch-ag) = 79af0c5d45601b8a7411789ec59df1a85708c4d7
 SHA1 (patch-ah) = b0e2a31920dd1d0a99b04e84561195d669815df7
 SHA1 (patch-aj) = cb425a00e480ce625332d9e3c56fd9305075fd01
-SHA1 (patch-ak) = 1fd396ea0591fc61a97038bb754a2fd3c9436a48
+SHA1 (patch-ak) = c9d11b33b28ed23f3c7ddbe428b5c5d102cfcb87
 SHA1 (patch-am) = 8ee096a08a70ca0c6d75564fda1b28e24edce122
 SHA1 (patch-an) = 91878841fb92a0d5f2073a299949088c791d0753
+SHA1 (patch-la) = 25ffb10186f60cb71ce38b8f88af0b078eda7c65
+SHA1 (patch-lb) = 91e7494af17cbad5bed273b571c184ac6a50f256
+SHA1 (patch-lc) = 21b766ca67c593ca70ccad4242c0de8727acd584
+SHA1 (patch-ld) = 5621c5ff9ae96422c6b30eaaee90a71bb3b131bf
Index: files/slapd.sh
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/files/slapd.sh,v
retrieving revision 1.1.1.4
retrieving revision 1.3
diff -u -r1.1.1.4 -r1.3
--- files/slapd.sh	16 Aug 2004 00:20:04 -0000	1.1.1.4
+++ files/slapd.sh	9 Nov 2005 22:18:04 -0000	1.3
@@ -6,20 +6,136 @@
 #
 # PROVIDE: slapd
 # REQUIRE: DAEMON
+# KEYWORD: chrootdir
 
-if [ -f /etc/rc.subr ]; then
-	. /etc/rc.subr
-fi
+. /etc/rc.subr
 
 name="slapd"
 rcvar=${name}
 command="@PREFIX@/libexec/${name}"
-required_files="@OPENLDAP_ETCDIR@/${name}.conf"
+pidfile="@VARBASE@/run/${name}.pid"
+start_precmd="slapd_precmd"
+
+load_rc_config $name
 
-if [ -f /etc/rc.subr ]; then
-	load_rc_config $name
-	run_rc_command "$1"
+if [ -n "$slapd_chrootdir" ]; then
+	required_dirs="$slapd_chrootdir"
 else
-	@ECHO@ -n " ${name}"
-	${command} ${slapd_flags} ${command_args}
+	required_dirs="@VARBASE@/openldap"
+	required_files="@OPENLDAP_ETCDIR@/${name}.conf"
 fi
+
+versionsafe_copy() {
+	if [ -d "${2}" -a -f "${1}/.chroot_timestamp" ]; then
+		if [ X$( set -- $(
+				@FIND@ "${2}" -newer \
+				     "${1}/.chroot_timestamp" \
+				| wc -l
+				)
+			 @ECHO@ $1
+		      ) != X0 ]; then
+			warn "${2} modified.  modify master copy in ${1}, rm -rf ${2}, and try again."
+			if [ -z "$rc_force" ]; then
+				return 1
+			fi
+		fi
+	fi
+	if [ ! -d "${1}" ]; then
+		warn "${1} is not a directory."
+		if [ -z "$rc_force" ]; then
+			return 1
+		fi
+	fi
+	@RM@ -rf "${2}"
+	( cd ${1} && \
+	  @RM@ -f .chroot_timestamp && \
+	  @MKDIR@ -p "${2}" && \
+	  @GTAR@ cf - . | ( cd "${2}" && @GTAR@ xpf - ) && \
+	  @TOUCH@ .chroot_timestamp )
+}
+
+slapd_precmd()
+{
+    if [ -n "$slapd_chrootdir" ]; then
+
+	# If running in a chroot cage, ensure that the appropriate files
+	# exist inside the cage, as well as helper symlinks into the cage 
+	# from outside.
+	#
+	# As this is called after the is_running and required_dir checks
+	# are made in run_rc_command(), we can safely assume ${slapd_chrootdir}
+	# exists and slapd isn't running at this point (unless forcestart
+	# is used).
+	#
+
+	for t in var usr usr/pkg; do 
+		if [ ! -d "${slapd_chrootdir}/${t}/." ]; then
+			@LN@ -s . "${slapd_chrootdir}/${t}"
+		fi
+	done
+	( cd "${slapd_chrootdir}" && \
+	  @MKDIR@ -p etc share openldap )
+	for t in etc share; do
+		if [ ! -d "${slapd_chrootdir}/${t}/openldap/." ]; then
+			@LN@ -s . "${slapd_chrootdir}/${t}/openldap"
+		fi
+	done
+
+	if [ -f /etc/localtime ]; then
+		@CMP@ -s /etc/localtime "${slapd_chrootdir}/etc/localtime" || \
+		    @CP@ -p /etc/localtime "${slapd_chrootdir}/etc/localtime"
+	fi
+	if [ ! -f "${slapd_chrootdir}/etc/${name}.conf" ]; then
+		if [ ! -f "@OPENLDAP_ETCDIR@/${name}.conf" ]; then
+			warn "@OPENLDAP_ETCDIR@/${name}.conf is not readable."
+			if [ -z "$rc_force" ]; then
+				return 1
+			fi
+		fi
+		@MV@ "@OPENLDAP_ETCDIR@/${name}.conf" \
+		   "${slapd_chrootdir}/etc/${name}.conf"
+		@CHOWN@ @ROOT_USER@:@OPENLDAP_GROUP@ "${slapd_chrootdir}/etc/${name}.conf"
+		@CHMOD@ 640 "${slapd_chrootdir}/etc/${name}.conf"
+	fi
+	@LN@ -fs "${slapd_chrootdir}/etc/${name}.conf" \
+	       "@OPENLDAP_ETCDIR@/${name}.conf"
+	versionsafe_copy "@OPENLDAP_ETCDIR@/schema" "${slapd_chrootdir}/etc/schema" || return 1
+	versionsafe_copy "@PREFIX@/share/openldap/ucdata" "${slapd_chrootdir}/share/ucdata" || return 1
+	# this is such total garbage
+	@EGREP@ "^(@ROOT_USER@|@OPENLDAP_USER@):" /etc/master.passwd | \
+		@SED@ 's/^\([^:]*\):[^:]*:/\1:*:/' > \
+		"${slapd_chrootdir}/etc/t0"
+	pwd_mkdb -p -d "${slapd_chrootdir}@FREEBSD_PWDMKDB_ETC@" "${slapd_chrootdir}/etc/t0"
+
+	#	Change run_rc_commands()'s internal copy of $slapd_flags
+	#
+	rc_flags="-r ${slapd_chrootdir} -f /etc/slapd.conf $rc_flags"
+    fi
+
+    for t in openldap-data run; do
+	@MKDIR@ -p "${slapd_chrootdir}/var/openldap/${t}"
+	@CHOWN@ @OPENLDAP_USER@:@OPENLDAP_GROUP@ "${slapd_chrootdir}/var/openldap/${t}"
+    done
+    @CHMOD@ 700 "${slapd_chrootdir}/var/openldap/openldap-data"
+    @CHMOD@ 775 "${slapd_chrootdir}/var/openldap/run"
+    # this is not just for chroot.  slapd.pid needs to be writeable by dropped-privs user
+    @LN@ -fs "${slapd_chrootdir}/var/openldap/run/${name}.pid" \
+	@VARBASE@/run/${name}.pid
+
+    rc_flags="-u @OPENLDAP_USER@ $rc_flags"
+    rc_flags="$(
+	set -- $rc_flags
+	while [ $# -ne 0 ]; do
+	    if [ X"$1" = X-h ]; then
+		break
+	    fi
+	    shift
+	done
+	if [ $# -eq 0 ]; then
+	    @ECHO@ "-h ldapi:///"
+	fi
+	) $rc_flags"
+
+}
+
+run_rc_command "$1"
Index: patches/patch-af
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/patches/patch-af,v
retrieving revision 1.1.1.4
retrieving revision 1.2
diff -u -r1.1.1.4 -r1.2
--- patches/patch-af	29 Aug 2005 20:04:10 -0000	1.1.1.4
+++ patches/patch-af	9 Nov 2005 22:12:02 -0000	1.2
@@ -1,8 +1,8 @@
-$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
 
---- libraries/libldap/Makefile.in.orig	2005-01-20 12:01:01.000000000 -0500
+--- libraries/libldap/Makefile.in.orig	Thu Jan  1 13:16:29 2004
 +++ libraries/libldap/Makefile.in
-@@ -59,7 +59,7 @@ CFFILES=ldap.conf
+@@ -59,17 +59,16 @@ CFFILES=ldap.conf
  
  install-local: $(CFFILES) FORCE
  	-$(MKDIR) $(DESTDIR)$(libdir)
@@ -11,3 +11,15 @@
  	$(LTFINISH) $(DESTDIR)$(libdir)
  	-$(MKDIR) $(DESTDIR)$(sysconfdir)
  	@for i in $(CFFILES); do \
+ 		if test ! -f $(DESTDIR)$(sysconfdir)/$$i; then \
+ 			echo "installing $$i in $(sysconfdir)"; \
+-			echo "$(INSTALL) $(INSTALLFLAGS) -m 644  $(srcdir)/$$i $(DESTDIR)$(sysconfdir)/$$i"; \
+-			$(INSTALL) $(INSTALLFLAGS) -m 644 $(srcdir)/$$i $(DESTDIR)$(sysconfdir)/$$i; \
++			echo "$(INSTALL) $(INSTALLFLAGS) -m 444  $(srcdir)/$$i $(DESTDIR)$(sysconfdir)/$$i"; \
++			$(INSTALL) $(INSTALLFLAGS) -m 444 $(srcdir)/$$i $(DESTDIR)$(sysconfdir)/$$i; \
+ 		else \
+ 			echo "PRESERVING EXISTING CONFIGURATION FILE $(sysconfdir)/$$i" ; \
+ 		fi; \
+-		$(INSTALL) $(INSTALLFLAGS) -m 644 $(srcdir)/$$i $(DESTDIR)$(sysconfdir)/$$i.default; \
+ 	done
+ 
Index: patches/patch-ag
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/patches/patch-ag,v
retrieving revision 1.1.1.4
retrieving revision 1.2
diff -u -r1.1.1.4 -r1.2
--- patches/patch-ag	29 Aug 2005 20:04:10 -0000	1.1.1.4
+++ patches/patch-ag	9 Nov 2005 22:12:02 -0000	1.2
@@ -1,8 +1,8 @@
-$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
 
 --- servers/slapd/Makefile.in.orig	2004-07-25 18:31:04.000000000 -0400
-+++ servers/slapd/Makefile.in
-@@ -74,6 +74,10 @@ XLIBS = $(SLAPD_STATIC_DEPENDS) $(SLAPD_
++++ servers/slapd/Makefile.in	2005-03-15 20:27:39.000000000 -0500
+@@ -74,6 +74,10 @@
  XXLIBS = $(SLAPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
  XXXLIBS = $(LTHREAD_LIBS) $(SLAPI_LIBS) $(MODULES_LIBS)
  
@@ -13,3 +13,31 @@
  BUILD_OPT = "--enable-slapd"
  BUILD_SRV = @BUILD_SLAPD@
  
+@@ -354,7 +358,6 @@
+ 
+ install-slapd: FORCE
+ 	-$(MKDIR) $(DESTDIR)$(libexecdir)
+-	-$(MKDIR) $(DESTDIR)$(localstatedir)/run
+ 	$(LTINSTALL) $(INSTALLFLAGS) -s -m 755 \
+ 		slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
+ 	@for i in $(SUBDIRS); do \
+@@ -401,17 +404,14 @@
+ 		else \
+ 			echo "PRESERVING EXISTING SCHEMA FILE $$SD" ; \
+ 		fi ; \
+-		$(INSTALL) $(INSTALLFLAGS) -m 444 $$i $$SD.default ; \
+ 	done
+ 
+ install-conf: FORCE
+ 	@-$(MKDIR) $(DESTDIR)$(sysconfdir)
+-	@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
+-	$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf.default
+ 	if test ! -f $(DESTDIR)$(sysconfdir)/slapd.conf; then \
+ 		echo "installing slapd.conf in $(sysconfdir)"; \
+-		echo "$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
+-		$(INSTALL) $(INSTALLFLAGS) -m 600 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
++		echo "$(INSTALL) $(INSTALLFLAGS) -m 444 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf"; \
++		$(INSTALL) $(INSTALLFLAGS) -m 444 slapd.conf.tmp $(DESTDIR)$(sysconfdir)/slapd.conf; \
+ 	else \
+ 		echo "PRESERVING EXISTING CONFIGURATION FILE $(DESTDIR)$(sysconfdir)/slapd.conf" ; \
+ 	fi
Index: patches/patch-ak
===================================================================
RCS file: /scratch/cvsroot/netbsd/pkgsrc/databases/openldap/patches/patch-ak,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- patches/patch-ak	2 Apr 2005 21:37:16 -0000	1.1.1.1
+++ patches/patch-ak	9 Nov 2005 22:12:02 -0000	1.2
@@ -1,8 +1,8 @@
-$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
 
 --- servers/slurpd/Makefile.in.orig	2004-01-01 13:16:42.000000000 -0500
-+++ servers/slurpd/Makefile.in
-@@ -43,6 +43,9 @@ XLIBS = $(SLURPD_L)
++++ servers/slurpd/Makefile.in	2005-03-18 18:04:25.000000000 -0500
+@@ -43,6 +43,9 @@
  XXLIBS = $(SLURPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
  XXXLIBS = $(LTHREAD_LIBS)
  
@@ -12,3 +12,11 @@
  slurpd:	version.o
  	$(LTLINK) -o $@ $(OBJS) version.o $(LIBS)
  
+@@ -57,7 +60,6 @@
+ 
+ install-local-srv: FORCE
+ 	-$(MKDIR) $(DESTDIR)$(libexecdir)
+-	@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-slurp
+ 	@(								\
+ 	    for prg in $(PROGRAMS); do					\
+ 		$(LTINSTALL) $(INSTALLFLAGS) -s -m 755 $$prg$(EXEEXT)	\
Index: patches/patch-la
===================================================================
RCS file: patches/patch-la
diff -N patches/patch-la
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-la	9 Nov 2005 22:12:02 -0000	1.1
@@ -0,0 +1,14 @@
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+
+--- include/ldap_defaults.h.orig	2005-03-11 17:45:45.000000000 -0500
++++ include/ldap_defaults.h	2005-03-11 17:46:11.000000000 -0500
+@@ -39,7 +39,9 @@
+ #define LDAP_ENV_PREFIX "LDAP"
+ 
+ /* default ldapi:// socket */
++#ifndef LDAPI_SOCK
+ #define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi"
++#endif
+ 
+ /*
+  * SLAPD DEFINITIONS
Index: patches/patch-lb
===================================================================
RCS file: patches/patch-lb
diff -N patches/patch-lb
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-lb	9 Nov 2005 22:12:02 -0000	1.1
@@ -0,0 +1,15 @@
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+
+--- libraries/libldap/ldap.conf.orig	2003-05-24 22:09:37.000000000 -0400
++++ libraries/libldap/ldap.conf
+@@ -5,8 +5,9 @@
+ # See ldap.conf(5) for details
+ # This file should be world readable but not world writable.
+ 
+-#BASE	dc=example, dc=com
++BASE	@LDAP_BASE@
+ #URI	ldap://ldap.example.com ldap://ldap-master.example.com:666
++URI	ldapi:///
+ 
+ #SIZELIMIT	12
+ #TIMELIMIT	15
Index: patches/patch-lc
===================================================================
RCS file: patches/patch-lc
diff -N patches/patch-lc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-lc	9 Nov 2005 22:12:02 -0000	1.1
@@ -0,0 +1,44 @@
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+
+--- servers/slapd/slapd.conf.orig	2004-06-29 17:45:50.000000000 -0400
++++ servers/slapd/slapd.conf
+@@ -4,8 +4,13 @@
+ #
+ include		%SYSCONFDIR%/schema/core.schema
+ 
++#loglevel 4095
++
+ # Define global ACLs to disable default read access.
+ 
++access to * by anonymous auth
++#allow bind_v2
++
+ # Do not enable referrals until AFTER you have a working directory
+ # service AND an understanding of referrals.
+ #referral	ldap://root.openldap.org
+@@ -53,11 +58,22 @@ argsfile	%LOCALSTATEDIR%/run/slapd.args
+ #######################################################################
+ 
+ database	bdb
+-suffix		"dc=my-domain,dc=com"
+-rootdn		"cn=Manager,dc=my-domain,dc=com"
++suffix		"@LDAP_BASE@"
++rootdn		"cn=Manager,@LDAP_BASE@"
+ # Cleartext passwords, especially for the rootdn, should
+ # be avoid.  See slappasswd(8) and slapd.conf(5) for details.
+-# Use of strong authentication encouraged.
++# here is how to use crypt in a fancy way with slappasswd:
++#
++# slappasswd command				passwd.conf equivalent
++#  slappasswd -h {CRYPT} -c "_.../%.4s" 	 newsalt,262144
++#  slappasswd -h {CRYPT} -c '$1$%.8s$'		 md5
++#  slappasswd -h {CRYPT} -c '$2a$07$%.22s'	 blowfish,7
++# the output string less the {CRYPT} prefix is appropriately formatted 
++# for a master.passwd file on NetBSD.
++#
++# if that doesn't work, use slappasswd -h {SSHA} for a one-way hash that 
++# is only meaningful to openldap.  In either case, copy the entire string 
++# slappasswd outputs including the {STYLE} prefix into the rootpw option.
+ rootpw		secret
+ # The database directory MUST exist prior to running slapd AND 
+ # should only be accessible by the slapd and slap tools.
Index: patches/patch-ld
===================================================================
RCS file: patches/patch-ld
diff -N patches/patch-ld
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-ld	11 Nov 2005 01:33:21 -0000	1.1
@@ -0,0 +1,33 @@
+$NetBSD: openldap-package.diff,v 1.4 2011/11/21 19:08:57 absd Exp $
+
+--- servers/slapd/daemon.c.orig	Fri Nov 11 01:21:32 2005
++++ servers/slapd/daemon.c
+@@ -731,11 +731,10 @@ static int slap_open_listener(
+ 	l.sl_is_udp = ( tmp == LDAP_PROTO_UDP );
+ #endif
+ 
++	l.sl_perms = S_IRWXU | S_IRWXG | S_IRWXO;
+ #if defined(LDAP_PF_LOCAL) || defined(SLAP_X_LISTENER_MOD)
+ 	if ( lud->lud_exts ) {
+ 		err = get_url_perms( lud->lud_exts, &l.sl_perms, &crit );
+-	} else {
+-		l.sl_perms = S_IRWXU | S_IRWXO;
+ 	}
+ #endif /* LDAP_PF_LOCAL || SLAP_X_LISTENER_MOD */
+ 
+@@ -888,7 +887,6 @@ static int slap_open_listener(
+ #ifdef LDAP_PF_LOCAL
+ 	case AF_LOCAL: {
+ 		char *addr = ((struct sockaddr_un *)*sal)->sun_path;
+-#if 0 /* don't muck with socket perms */
+ 		if ( chmod( addr, l.sl_perms ) < 0 && crit ) {
+ 			int err = sock_errno();
+ #ifdef NEW_LOGGING
+@@ -903,7 +901,6 @@ static int slap_open_listener(
+ 			slap_free_listener_addresses(psal);
+ 			return -1;
+ 		}
+-#endif
+ 		l.sl_name.bv_len = strlen(addr) + sizeof("PATH=") - 1;
+ 		l.sl_name.bv_val = ber_memalloc( l.sl_name.bv_len + 1 );
+ 		snprintf( l.sl_name.bv_val, l.sl_name.bv_len + 1, 
