Submitted by:            Bruce Dubbs <bdubbs at linuxfromscratch.org>
Date:                    2012-03-26 
Initial Package Version: 2.4.40
Upstream Status:         BLFS Specific
Origin:                  Armin K. <krejzi at email dot com> and Debian 
Comment:                 Rediffed by Fernando de Oliveira <famobr at yahoo dot
                         com dot br> for version 2.4.44 - 2016.02.06
                         Rediffed by Pierre Labastie <pierre dot labastie at
                         neuf dot fr> to add mdb backend and slapd.ldif. See
                         ticket #7394 - 2016.02.24
                         Rediffed by Douglas R. Reno <renodr at linuxfromscratch
                         dot org> to function on 2.4.51. - 2020-08-13
Description:             Consolidate earlier patches to:
 1. Update various installation options, such as ldap database path, 
    configuration file options, slapd install location, etc.
 2. Remove reference to bdb module
 3. Enables symbol versioning in ldap libraries. Without these changes
    some applications might generate a warning about missing symbol versions.

diff -Naurp openldap-2.4.51.orig/build/openldap.m4 openldap-2.4.51/build/openldap.m4
--- openldap-2.4.51.orig/build/openldap.m4	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/build/openldap.m4	2020-08-13 17:04:30.366225523 -0500
@@ -1115,3 +1115,54 @@ AC_DEFUN([OL_SSL_COMPAT],
 #endif
 	], [ol_cv_ssl_crl_compat=yes], [ol_cv_ssl_crl_compat=no])])
 ])
+
+dnl ====================================================================
+dnl check for symbol versioning support
+AC_DEFUN([OL_SYMBOL_VERSIONING],
+[AC_CACHE_CHECK([for .symver assembler directive],
+        [ol_cv_asm_symver_directive],[
+cat > conftest.c <<EOF
+${libc_cv_dot_text}
+_sym:
+.symver _sym,sym@VERS
+EOF
+if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+   ol_cv_asm_symver_directive=yes
+else
+   ol_cv_asm_symver_directive=no
+fi
+rm -f conftest*])
+AC_CACHE_CHECK([for ld --version-script],
+        [ol_cv_ld_version_script_option],[
+if test $ol_cv_asm_symver_directive = yes; then
+  cat > conftest.s <<EOF
+${libc_cv_dot_text}
+_sym:
+.symver _sym,sym@VERS
+EOF
+  cat > conftest.map <<EOF
+VERS_1 {
+         global: sym;
+};
+
+VERS_2 {
+         global: sym;
+} VERS_1;
+EOF
+   if ${CC-cc} -c $ASFLAGS conftest.s 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
+      if AC_TRY_COMMAND([${CC-cc} $CFLAGS $LDFLAGS --shared
+                                                   -o conftest.so conftest.o
+                                                   -Wl,--version-script,conftest.map
+                         1>&AS_MESSAGE_LOG_FD]);
+      then
+        ol_cv_ld_version_script_option=yes
+      else
+        ol_cv_ld_version_script_option=no
+      fi
+   else
+      ol_cv_ld_version_script_option=no
+   fi
+else
+   ol_cv_version_script_option=no
+fi
+rm -f conftest*])])
diff -Naurp openldap-2.4.51.orig/build/top.mk openldap-2.4.51/build/top.mk
--- openldap-2.4.51.orig/build/top.mk	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/build/top.mk	2020-08-13 17:05:06.758224238 -0500
@@ -104,6 +104,9 @@ LTFLAGS_MOD = $(@PLAT@_LTFLAGS_MOD)
 # LINK_LIBS referenced in library and module link commands.
 LINK_LIBS = $(MOD_LIBS) $(@PLAT@_LINK_LIBS)
 
+# option to pass to $(CC) to support library symbol versioning, if any
+VERSION_OPTION = @VERSION_OPTION@
+
 LTSTATIC = @LTSTATIC@
 
 LTLINK   = $(LIBTOOL) --mode=link \
@@ -113,7 +116,7 @@ LTCOMPILE_LIB = $(LIBTOOL) $(LTONLY_LIB)
 	$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(LIB_DEFS) -c
 
 LTLINK_LIB = $(LIBTOOL) $(LTONLY_LIB) --mode=link \
-	$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB)
+	$(CC) $(LT_CFLAGS) $(LDFLAGS) $(LTFLAGS_LIB) $(VERSION_FLAGS)
 
 LTCOMPILE_MOD = $(LIBTOOL) $(LTONLY_MOD) --mode=compile \
 	$(CC) $(LT_CFLAGS) $(LT_CPPFLAGS) $(MOD_DEFS) -c
diff -Naurp openldap-2.4.51.orig/configure.in openldap-2.4.51/configure.in
--- openldap-2.4.51.orig/configure.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/configure.in	2020-08-13 17:06:23.965221512 -0500
@@ -1921,6 +1921,13 @@ else
 fi
 AC_SUBST(LTSTATIC)dnl
 
+VERSION_OPTION=""
+OL_SYMBOL_VERSIONING
+if test $ol_cv_ld_version_script_option = yes; then
+   VERSION_OPTION="-Wl,--version-script="
+fi
+AC_SUBST(VERSION_OPTION)
+
 dnl ----------------------------------------------------------------
 if test $ol_enable_wrappers != no ; then
 	AC_CHECK_HEADERS(tcpd.h,[
diff -Naurp openldap-2.4.51.orig/doc/man/man5/slapd-bdb.5 openldap-2.4.51/doc/man/man5/slapd-bdb.5
--- openldap-2.4.51.orig/doc/man/man5/slapd-bdb.5	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/doc/man/man5/slapd-bdb.5	2020-08-13 17:06:49.002220627 -0500
@@ -135,7 +135,7 @@ Specify the directory where the BDB file
 associated indexes live.
 A separate directory must be specified for each database.
 The default is
-.BR LOCALSTATEDIR/openldap\-data .
+.BR LOCALSTATEDIR/lib/openldap .
 .TP
 .B dirtyread
 Allow reads of modified but not yet committed data.
diff -Naurp openldap-2.4.51.orig/doc/man/man5/slapd.conf.5 openldap-2.4.51/doc/man/man5/slapd.conf.5
--- openldap-2.4.51.orig/doc/man/man5/slapd.conf.5	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/doc/man/man5/slapd.conf.5	2020-08-13 17:08:39.869216713 -0500
@@ -2037,7 +2037,7 @@ suffix    "dc=our\-domain,dc=com"
 # The database directory MUST exist prior to
 # running slapd AND should only be accessible
 # by the slapd/tools. Mode 0700 recommended.
-directory LOCALSTATEDIR/openldap\-data
+directory LOCALSTATEDIR/lib/openldap
 # Indices to maintain
 index     objectClass  eq
 index     cn,sn,mail   pres,eq,approx,sub
diff -Naurp openldap-2.4.51.orig/doc/man/man5/slapd-config.5 openldap-2.4.51/doc/man/man5/slapd-config.5
--- openldap-2.4.51.orig/doc/man/man5/slapd-config.5	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/doc/man/man5/slapd-config.5	2020-08-13 17:07:57.079218224 -0500
@@ -2067,7 +2067,7 @@ olcSuffix: "dc=our\-domain,dc=com"
 # The database directory MUST exist prior to
 # running slapd AND should only be accessible
 # by the slapd/tools. Mode 0700 recommended.
-olcDbDirectory: LOCALSTATEDIR/openldap\-data
+olcDbDirectory: LOCALSTATEDIR/lib/openldap
 # Indices to maintain
 olcDbIndex:     objectClass  eq
 olcDbIndex:     cn,sn,mail   pres,eq,approx,sub
diff -Naurp openldap-2.4.51.orig/include/ldap_defaults.h openldap-2.4.51/include/ldap_defaults.h
--- openldap-2.4.51.orig/include/ldap_defaults.h	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/include/ldap_defaults.h	2020-08-13 17:10:11.297213484 -0500
@@ -39,7 +39,7 @@
 #define LDAP_ENV_PREFIX "LDAP"
 
 /* default ldapi:// socket */
-#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi"
+#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "openldap" LDAP_DIRSEP "ldapi"
 
 /*
  * SLAPD DEFINITIONS
@@ -47,7 +47,7 @@
 	/* location of the default slapd config file */
 #define SLAPD_DEFAULT_CONFIGFILE	LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.conf"
 #define SLAPD_DEFAULT_CONFIGDIR		LDAP_SYSCONFDIR LDAP_DIRSEP "slapd.d"
-#define SLAPD_DEFAULT_DB_DIR		LDAP_RUNDIR LDAP_DIRSEP "openldap-data"
+#define SLAPD_DEFAULT_DB_DIR		LDAP_RUNDIR LDAP_DIRSEP "lib" LDAP_DIRSEP "openldap"
 #define SLAPD_DEFAULT_DB_MODE		0600
 #define SLAPD_DEFAULT_UCDATA		LDAP_DATADIR LDAP_DIRSEP "ucdata"
 	/* default max deref depth for aliases */
diff -Naurp openldap-2.4.51.orig/libraries/liblber/liblber.map openldap-2.4.51/libraries/liblber/liblber.map
--- openldap-2.4.51.orig/libraries/liblber/liblber.map	1969-12-31 18:00:00.000000000 -0600
+++ openldap-2.4.51/libraries/liblber/liblber.map	2020-08-13 17:11:56.589209766 -0500
@@ -0,0 +1,8 @@
+OPENLDAP_2.4_2 {
+   global:
+      ber_*;
+      der_alloc;
+      lutil_*;
+   local:
+      *;
+};
diff -Naurp openldap-2.4.51.orig/libraries/liblber/Makefile.in openldap-2.4.51/libraries/liblber/Makefile.in
--- openldap-2.4.51.orig/libraries/liblber/Makefile.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/libraries/liblber/Makefile.in	2020-08-13 17:11:02.505211676 -0500
@@ -38,6 +38,9 @@ XLIBS = $(LIBRARY) $(LDAP_LIBLUTIL_A)
 XXLIBS = 
 NT_LINK_LIBS = $(AC_LIBS)
 UNIX_LINK_LIBS = $(AC_LIBS)
+ifneq (,$(VERSION_OPTION))
+	VERSION_FLAGS = "$(VERSION_OPTION)$(srcdir)/liblber.map"
+endif
 
 dtest:    $(XLIBS) dtest.o
 	$(LTLINK) -o $@ dtest.o $(LIBS)
@@ -48,6 +51,6 @@ idtest:  $(XLIBS) idtest.o
 
 install-local: FORCE
 	-$(MKDIR) $(DESTDIR)$(libdir)
-	$(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir)
+	$(LTINSTALL) $(INSTALLFLAGS) -m 755 $(LIBRARY) $(DESTDIR)$(libdir)
 	$(LTFINISH) $(DESTDIR)$(libdir)
 
diff -Naurp openldap-2.4.51.orig/libraries/libldap/libldap.map openldap-2.4.51/libraries/libldap/libldap.map
--- openldap-2.4.51.orig/libraries/libldap/libldap.map	1969-12-31 18:00:00.000000000 -0600
+++ openldap-2.4.51/libraries/libldap/libldap.map	2020-08-13 17:13:03.469207405 -0500
@@ -0,0 +1,7 @@
+OPENLDAP_2.4_2 {
+   global:
+      ldap_*;
+      ldif_*;
+   local:
+      *;
+};
diff -Naurp openldap-2.4.51.orig/libraries/libldap/Makefile.in openldap-2.4.51/libraries/libldap/Makefile.in
--- openldap-2.4.51.orig/libraries/libldap/Makefile.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/libraries/libldap/Makefile.in	2020-08-13 17:12:40.847208204 -0500
@@ -52,6 +52,9 @@ XLIBS = $(LIBRARY) $(LDAP_LIBLBER_LA) $(
 XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
 NT_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
 UNIX_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
+ifneq (,$(VERSION_OPTION))
+	VERSION_FLAGS = $(VERSION_OPTION)$(srcdir)/libldap.map
+endif
 
 apitest:	$(XLIBS) apitest.o
 	$(LTLINK) -o $@ apitest.o $(LIBS)
@@ -68,7 +71,7 @@ CFFILES=ldap.conf
 
 install-local: $(CFFILES) FORCE
 	-$(MKDIR) $(DESTDIR)$(libdir)
-	$(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir)
+	$(LTINSTALL) $(INSTALLFLAGS) -m 755 $(LIBRARY) $(DESTDIR)$(libdir)
 	$(LTFINISH) $(DESTDIR)$(libdir)
 	-$(MKDIR) $(DESTDIR)$(sysconfdir)
 	@for i in $(CFFILES); do \
diff -Naurp openldap-2.4.51.orig/libraries/libldap_r/Makefile.in openldap-2.4.51/libraries/libldap_r/Makefile.in
--- openldap-2.4.51.orig/libraries/libldap_r/Makefile.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/libraries/libldap_r/Makefile.in	2020-08-13 17:14:46.760203758 -0500
@@ -61,6 +61,9 @@ XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
 XXXLIBS = $(LTHREAD_LIBS)
 NT_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS)
 UNIX_LINK_LIBS = $(LDAP_LIBLBER_LA) $(AC_LIBS) $(SECURITY_LIBS) $(LTHREAD_LIBS)
+ifneq (,$(VERSION_OPTION))
+	VERSION_FLAGS = "$(VERSION_OPTION)$(XXDIR)/libldap.map"
+endif
 
 .links : Makefile
 	@for i in $(XXSRCS); do \
@@ -83,6 +86,6 @@ ltest:	$(XLIBS) test.o
 
 install-local: $(CFFILES) FORCE
 	-$(MKDIR) $(DESTDIR)$(libdir)
-	$(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir)
+	$(LTINSTALL) $(INSTALLFLAGS) -m 755 $(LIBRARY) $(DESTDIR)$(libdir)
 	$(LTFINISH) $(DESTDIR)$(libdir)
 
diff -Naurp openldap-2.4.51.orig/servers/slapd/Makefile.in openldap-2.4.51/servers/slapd/Makefile.in
--- openldap-2.4.51.orig/servers/slapd/Makefile.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/servers/slapd/Makefile.in	2020-08-13 17:16:03.270201056 -0500
@@ -376,10 +376,10 @@ install-local-srv: install-slapd install
 	install-conf install-dbc-maybe install-schema install-tools
 
 install-slapd: FORCE
-	-$(MKDIR) $(DESTDIR)$(libexecdir)
+	-$(MKDIR) $(DESTDIR)$(sbindir)
 	-$(MKDIR) $(DESTDIR)$(localstatedir)/run
 	$(LTINSTALL) $(INSTALLFLAGS) $(STRIP) -m 755 \
-		slapd$(EXEEXT) $(DESTDIR)$(libexecdir)
+		slapd$(EXEEXT) $(DESTDIR)$(sbindir)
 	@for i in $(SUBDIRS); do \
 	    if test -d $$i && test -f $$i/Makefile ; then \
 		echo; echo "  cd $$i; $(MAKE) $(MFLAGS) install"; \
@@ -445,9 +445,9 @@ install-conf: FORCE
 
 install-db-config: FORCE
 	@-$(MKDIR) $(DESTDIR)$(localstatedir) $(DESTDIR)$(sysconfdir)
-	@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/openldap-data
+	@-$(INSTALL) -m 700 -d $(DESTDIR)$(localstatedir)/lib/openldap
 	$(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
-		$(DESTDIR)$(localstatedir)/openldap-data/DB_CONFIG.example
+		$(DESTDIR)$(localstatedir)/lib/openldap/DB_CONFIG.example
 	$(INSTALL) $(INSTALLFLAGS) -m 600 $(srcdir)/DB_CONFIG \
 		$(DESTDIR)$(sysconfdir)/DB_CONFIG.example
 
@@ -455,6 +455,6 @@ install-tools: FORCE
 	-$(MKDIR) $(DESTDIR)$(sbindir)
 	for i in $(SLAPTOOLS); do \
 		$(RM) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
-		$(LN_S) -f $(DESTDIR)$(libexecdir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
+		$(LN_S) -f $(DESTDIR)$(sbindir)/slapd$(EXEEXT) $(DESTDIR)$(sbindir)/$$i$(EXEEXT); \
 	done
 
diff -Naurp openldap-2.4.51.orig/servers/slapd/slapd.conf openldap-2.4.51/servers/slapd/slapd.conf
--- openldap-2.4.51.orig/servers/slapd/slapd.conf	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/servers/slapd/slapd.conf	2020-08-13 17:17:01.239199009 -0500
@@ -10,12 +10,12 @@ include		%SYSCONFDIR%/schema/core.schema
 # service AND an understanding of referrals.
 #referral	ldap://root.openldap.org
 
-pidfile		%LOCALSTATEDIR%/run/slapd.pid
-argsfile	%LOCALSTATEDIR%/run/slapd.args
+pidfile		%LOCALSTATEDIR%/run/openldap/slapd.pid
+argsfile	%LOCALSTATEDIR%/run/openldap/slapd.args
 
 # Load dynamic backend modules:
-# modulepath	%MODULEDIR%
-# moduleload	back_mdb.la
+modulepath	%MODULEDIR%
+moduleload	back_mdb.la
 # moduleload	back_ldap.la
 
 # Sample security restrictions
@@ -60,6 +60,6 @@ rootpw		secret
 # The database directory MUST exist prior to running slapd AND 
 # should only be accessible by the slapd and slap tools.
 # Mode 700 recommended.
-directory	%LOCALSTATEDIR%/openldap-data
+directory	%LOCALSTATEDIR%/lib/openldap
 # Indices to maintain
 index	objectClass	eq
diff -Naurp openldap-2.4.51.orig/servers/slapd/slapd.ldif openldap-2.4.51/servers/slapd/slapd.ldif
--- openldap-2.4.51.orig/servers/slapd/slapd.ldif	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/servers/slapd/slapd.ldif	2020-08-13 17:18:00.106196931 -0500
@@ -9,8 +9,8 @@ cn: config
 #
 # Define global ACLs to disable default read access.
 #
-olcArgsFile: %LOCALSTATEDIR%/run/slapd.args
-olcPidFile: %LOCALSTATEDIR%/run/slapd.pid
+olcArgsFile: %LOCALSTATEDIR%/run/openldap/slapd.args
+olcPidFile: %LOCALSTATEDIR%/run/openldap/slapd.pid
 #
 # Do not enable referrals until AFTER you have a working directory
 # service AND an understanding of referrals.
@@ -26,11 +26,11 @@ olcPidFile: %LOCALSTATEDIR%/run/slapd.pi
 #
 # Load dynamic backend modules:
 #
-#dn: cn=module,cn=config
-#objectClass: olcModuleList
-#cn: module
-#olcModulepath:	%MODULEDIR%
-#olcModuleload:	back_mdb.la
+dn: cn=module,cn=config
+objectClass: olcModuleList
+cn: module
+olcModulepath:	%MODULEDIR%
+olcModuleload:	back_mdb.la
 #olcModuleload:	back_bdb.la
 #olcModuleload:	back_hdb.la
 #olcModuleload:	back_ldap.la
@@ -91,6 +91,6 @@ olcRootPW: secret
 # The database directory MUST exist prior to running slapd AND 
 # should only be accessible by the slapd and slap tools.
 # Mode 700 recommended.
-olcDbDirectory:	%LOCALSTATEDIR%/openldap-data
+olcDbDirectory:	%LOCALSTATEDIR%/lib/openldap
 # Indices to maintain
 olcDbIndex: objectClass eq
diff -Naurp openldap-2.4.51.orig/servers/slapd/slapi/Makefile.in openldap-2.4.51/servers/slapd/slapi/Makefile.in
--- openldap-2.4.51.orig/servers/slapd/slapi/Makefile.in	2020-08-11 13:33:20.000000000 -0500
+++ openldap-2.4.51/servers/slapd/slapi/Makefile.in	2020-08-13 17:18:16.643196347 -0500
@@ -46,6 +46,6 @@ BUILD_MOD = @BUILD_SLAPI@
 install-local: FORCE
 	if test "$(BUILD_MOD)" = "yes"; then \
 		$(MKDIR) $(DESTDIR)$(libdir); \
-		$(LTINSTALL) $(INSTALLFLAGS) -m 644 $(LIBRARY) $(DESTDIR)$(libdir); \
+		$(LTINSTALL) $(INSTALLFLAGS) -m 755 $(LIBRARY) $(DESTDIR)$(libdir); \
 	fi
 
