diff --git a/README.update b/README.update
new file mode 100644
index 0000000..207e396
--- /dev/null
+++ b/README.update
@@ -0,0 +1,28 @@
+Updating from OpenLDAP 2.3.X to 2.4.X
+=====================================
+
+Changed Database format:
+ Due change in the "BDB"-backend's index database format, existing
+ bdb-databases need to be reloaded from LDIF completely. This is
+ normally done during the package installation/update. This might not
+ work in all setups and for that database dumps of all bdb/hdb
+ databases are created during the update.
+ You can find the database dump of each bdb database in the
+ database directory for that database (default: /var/lib/ldap/). The
+ file name is "ldapbak.ldif.X" where "X" presents the number of the
+ database.
+ If the database backups where not created during the package update for
+ some reason, you can do them manually by using the command:
+ /usr/sbin/openldap-2.3-slapcat -T c \
+ -f /etc/openldap/schema.backup.XXXXXX/slapd.conf.update
+ Before dumping the database you should remove the db's enviroment (the
+ __db*-file in /var/lib/ldap)
+ To reload the databases please use the tool "slapadd".
+
+Other Changes:
+ For additional information on important changes and upgrade
+ instructions, please have a look a the OpenLDAP Administrator's Guide.
+ You can find in at:
+ /usr/share/doc/packages/openldap2/guide/admin/guide.html
+ or online at:
+ http://www.openldap.org/doc/admin24/
diff --git a/openldap-2.3.37.dif b/openldap-2.3.37.dif
new file mode 100644
index 0000000..c416cb0
--- /dev/null
+++ b/openldap-2.3.37.dif
@@ -0,0 +1,331 @@
+Index: build/top.mk
+===================================================================
+--- build/top.mk.orig
++++ build/top.mk
+@@ -39,7 +39,7 @@ libdir = @libdir@
+ libexecdir = @libexecdir@
+ localstatedir = @localstatedir@
+ mandir = @mandir@
+-moduledir = @libexecdir@$(ldap_subdir)
++moduledir = @libexecdir@/modules
+ sbindir = @sbindir@
+ sharedstatedir = @sharedstatedir@
+ sysconfdir = @sysconfdir@$(ldap_subdir)
+@@ -58,7 +58,7 @@ INSTALL_PROGRAM = $(INSTALL)
+ INSTALL_DATA = $(INSTALL) -m 644
+ INSTALL_SCRIPT = $(INSTALL)
+
+-STRIP = -s
++#STRIP = -s
+
+ LINT = lint
+ 5LINT = 5lint
+@@ -175,9 +175,9 @@ SLAPD_L = $(LDAP_LIBLUNICODE_A) $(LDAP_L
+ WRAP_LIBS = @WRAP_LIBS@
+ # AutoConfig generated
+ AC_CC = @CC@
+-AC_CFLAGS = @CFLAGS@
++AC_CFLAGS = @CFLAGS@ $(PIE_CFLAGS)
+ AC_DEFS = @CPPFLAGS@ # @DEFS@
+-AC_LDFLAGS = @LDFLAGS@
++AC_LDFLAGS = @LDFLAGS@ $(PIE_LDFLAGS)
+ AC_LIBS = @LIBS@
+
+ KRB4_LIBS = @KRB4_LIBS@
+Index: configure.in
+===================================================================
+--- configure.in.orig
++++ configure.in
+@@ -64,7 +64,9 @@ dnl Determine host platform
+ dnl we try not to use this for much
+ AC_CANONICAL_TARGET([])
+
+-AM_INIT_AUTOMAKE([$OL_PACKAGE],[$OL_VERSION], [no defines])dnl
++AC_PROG_MAKE_SET
++PACKAGE=$OL_PACKAGE
++VERSION=$OL_VERSION
+ AC_SUBST(PACKAGE)dnl
+ AC_SUBST(VERSION)dnl
+ AC_DEFINE_UNQUOTED(OPENLDAP_PACKAGE,"$PACKAGE",Package)
+Index: servers/slapd/aclparse.c
+===================================================================
+--- servers/slapd/aclparse.c.orig
++++ servers/slapd/aclparse.c
+@@ -662,7 +662,7 @@ parse_acl(
+ if ( rc != LDAP_SUCCESS ) {
+ char buf[ SLAP_TEXT_BUFLEN ];
+
+- snprintf( buf, sizeof( buf ), "%s: line %d: "
++ snprintf( buf, sizeof( buf ),
+ " attr \"%s\" normalization failed (%d: %s)",
+ fname, lineno,
+ a->acl_attrs[ 0 ].an_name.bv_val, rc, text );
+Index: libraries/liblunicode/Makefile.in
+===================================================================
+--- libraries/liblunicode/Makefile.in.orig
++++ libraries/liblunicode/Makefile.in
+@@ -35,6 +35,9 @@ $(XXDIR)/uctable.h: $(XXDIR)/ucgendat.c
+ $(MAKE) ucgendat
+ ./ucgendat $(srcdir)/UnicodeData.txt -x $(srcdir)/CompositionExclusions.txt
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ ucgendat: $(XLIBS) ucgendat.o
+ $(LTLINK) -o $@ ucgendat.o $(LIBS)
+
+Index: libraries/liblutil/Makefile.in
+===================================================================
+--- libraries/liblutil/Makefile.in.orig
++++ libraries/liblutil/Makefile.in
+@@ -19,6 +19,9 @@ PROGRAM = testavl
+ LDAP_INCDIR= ../../include
+ LDAP_LIBDIR= ../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ NT_SRCS = ntservice.c
+ NT_OBJS = ntservice.o slapdmsg.res
+
+Index: servers/slapd/Makefile.in
+===================================================================
+--- servers/slapd/Makefile.in.orig
++++ servers/slapd/Makefile.in
+@@ -69,6 +69,9 @@ SLAPD_DYNAMIC_BACKENDS=@SLAPD_DYNAMIC_BA
+
+ SLAPI_LIBS=@LIBSLAPI@ @SLAPI_LIBS@
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ XDEFS = $(MODULES_CPPFLAGS)
+ XLDFLAGS = $(MODULES_LDFLAGS)
+
+Index: servers/slurpd/Makefile.in
+===================================================================
+--- servers/slurpd/Makefile.in.orig
++++ servers/slurpd/Makefile.in
+@@ -38,6 +38,9 @@ BUILD_SRV = @BUILD_SLURPD@
+
+ all-local-srv: $(PROGRAMS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ # $(LTHREAD_LIBS) must be last!
+ XLIBS = $(SLURPD_L)
+ XXLIBS = $(SLURPD_LIBS) $(SECURITY_LIBS) $(LUTIL_LIBS)
+Index: servers/slapd/back-bdb/Makefile.in
+===================================================================
+--- servers/slapd/back-bdb/Makefile.in.orig
++++ servers/slapd/back-bdb/Makefile.in
+@@ -37,6 +37,9 @@ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_BDB@_DEFS)
+ MOD_LIBS = $(LDBM_LIBS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: servers/slapd/back-hdb/Makefile.in
+===================================================================
+--- servers/slapd/back-hdb/Makefile.in.orig
++++ servers/slapd/back-hdb/Makefile.in
+@@ -39,6 +39,9 @@ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_HDB@_DEFS)
+ MOD_LIBS = $(LDBM_LIBS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: servers/slapd/back-ldbm/Makefile.in
+===================================================================
+--- servers/slapd/back-ldbm/Makefile.in.orig
++++ servers/slapd/back-ldbm/Makefile.in
+@@ -36,6 +36,9 @@ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_LDBM@_DEFS)
+ MOD_LIBS = $(LDBM_LIBS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: servers/slapd/overlays/Makefile.in
+===================================================================
+--- servers/slapd/overlays/Makefile.in.orig
++++ servers/slapd/overlays/Makefile.in
+@@ -41,6 +41,9 @@ LTONLY_MOD = $(LTONLY_mod)
+ LDAP_INCDIR= ../../../include
+ LDAP_LIBDIR= ../../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ MOD_DEFS = -DSLAPD_IMPORT
+
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+Index: servers/slapd/back-relay/Makefile.in
+===================================================================
+--- servers/slapd/back-relay/Makefile.in.orig
++++ servers/slapd/back-relay/Makefile.in
+@@ -24,6 +24,9 @@ BUILD_MOD = @BUILD_RELAY@
+ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_RELAY@_DEFS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) $(REWRITE)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) $(REWRITE)
+Index: servers/slapd/back-ldif/Makefile.in
+===================================================================
+--- servers/slapd/back-ldif/Makefile.in.orig
++++ servers/slapd/back-ldif/Makefile.in
+@@ -25,6 +25,9 @@ BUILD_MOD = yes
+ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(yes_DEFS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: libraries/librewrite/Makefile.in
+===================================================================
+--- libraries/librewrite/Makefile.in.orig
++++ libraries/librewrite/Makefile.in
+@@ -26,6 +26,9 @@ OBJS = config.o context.o info.o ldapmap
+ LDAP_INCDIR= ../../include
+ LDAP_LIBDIR= ../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ LIBRARY = librewrite.a
+ PROGRAMS = rewrite
+ XLIBS = $(LIBRARY) $(LDAP_LIBLUTIL_A) \
+Index: servers/slapd/back-ldap/Makefile.in
+===================================================================
+--- servers/slapd/back-ldap/Makefile.in.orig
++++ servers/slapd/back-ldap/Makefile.in
+@@ -27,6 +27,9 @@ BUILD_MOD = @BUILD_LDAP@
+ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_LDAP@_DEFS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: servers/slapd/back-monitor/Makefile.in
+===================================================================
+--- servers/slapd/back-monitor/Makefile.in.orig
++++ servers/slapd/back-monitor/Makefile.in
+@@ -33,6 +33,9 @@ BUILD_MOD = @BUILD_MONITOR@
+ mod_DEFS = -DSLAPD_IMPORT
+ MOD_DEFS = $(@BUILD_MONITOR@_DEFS)
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ shared_LDAP_LIBS = $(LDAP_LIBLDAP_R_LA) $(LDAP_LIBLBER_LA)
+ NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+ UNIX_LINK_LIBS = $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
+Index: servers/slapd/modify.c
+===================================================================
+--- servers/slapd/modify.c.orig
++++ servers/slapd/modify.c
+@@ -1,4 +1,4 @@
+-/* $OpenLDAP: pkg/ldap/servers/slapd/modify.c,v 1.227.2.25 2007/01/02 21:43:56 kurt Exp $ */
++/* $OpenLDAP: pkg/ldap/servers/slapd/modify.c,v 1.227.2.26 2007/09/04 03:42:37 hyc Exp $ */
+ /* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2007 The OpenLDAP Foundation.
+@@ -734,6 +734,7 @@ int slap_mods_check(
+ "%s: value #%ld normalization failed",
+ ml->sml_type.bv_val, (long) nvals );
+ *text = textbuf;
++ BER_BVZERO( &ml->sml_nvalues[nvals] );
+ return rc;
+ }
+ }
+Index: servers/slapd/back-bdb/modrdn.c
+===================================================================
+--- servers/slapd/back-bdb/modrdn.c.orig
++++ servers/slapd/back-bdb/modrdn.c
+@@ -729,6 +729,8 @@ retry: /* transaction retry */
+ } else {
+ rs->sr_err = LDAP_X_NO_OPERATION;
+ ltid = NULL;
++ /* Only free attrs if they were dup'd. */
++ if ( dummy.e_attrs == e->e_attrs ) dummy.e_attrs = NULL;
+ goto return_results;
+ }
+
+Index: libraries/liblber/Makefile.in
+===================================================================
+--- libraries/liblber/Makefile.in.orig
++++ libraries/liblber/Makefile.in
+@@ -34,6 +34,9 @@ PROGRAMS= dtest etest idtest
+ LDAP_INCDIR= ../../include
+ LDAP_LIBDIR= ../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ XLIBS = $(LIBRARY) $(LDAP_LIBLUTIL_A)
+ XXLIBS =
+ NT_LINK_LIBS = $(AC_LIBS)
+Index: libraries/libldap/Makefile.in
+===================================================================
+--- libraries/libldap/Makefile.in.orig
++++ libraries/libldap/Makefile.in
+@@ -42,6 +42,9 @@ OBJS = bind.lo open.lo result.lo error.l
+ LDAP_INCDIR= ../../include
+ LDAP_LIBDIR= ../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ LIB_DEFS = -DLDAP_LIBRARY
+
+ XLIBS = $(LIBRARY) $(LDAP_LIBLBER_LA) $(LDAP_LIBLUTIL_A)
+Index: libraries/libldap_r/Makefile.in
+===================================================================
+--- libraries/libldap_r/Makefile.in.orig
++++ libraries/libldap_r/Makefile.in
+@@ -49,6 +49,9 @@ OBJS = threads.lo rdwr.lo tpool.lo rq.l
+ LDAP_INCDIR= ../../include
+ LDAP_LIBDIR= ../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ LIB_DEFS = -DLDAP_LIBRARY
+
+ XDEFS = -DLDAP_R_COMPILE -I$(XXDIR)
+Index: servers/slapd/back-meta/Makefile.in
+===================================================================
+--- servers/slapd/back-meta/Makefile.in.orig
++++ servers/slapd/back-meta/Makefile.in
+@@ -23,6 +23,9 @@ OBJS = init.lo config.lo search.lo bind.
+ LDAP_INCDIR= ../../../include
+ LDAP_LIBDIR= ../../../libraries
+
++PIE_CFLAGS="-fPIE"
++PIE_LDFLAGS="-pie"
++
+ BUILD_OPT = "--enable-meta"
+ BUILD_MOD = @BUILD_META@
+
diff --git a/openldap-2.3.37.tar.bz2 b/openldap-2.3.37.tar.bz2
new file mode 100644
index 0000000..f1233f4
--- /dev/null
+++ b/openldap-2.3.37.tar.bz2
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f08ee02ed2dde1ce2bc3dc2d894984b69749fd29f7907fcbadfb077e52b8b818
+size 2948378
diff --git a/openldap2-client.changes b/openldap2-client.changes
index c5ca45b..1ec48cf 100644
--- a/openldap2-client.changes
+++ b/openldap2-client.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Fri May 16 13:24:11 CEST 2008 - rhafer@suse.de
+
+- Support update from 2.3 releases (bnc#390247)
+
-------------------------------------------------------------------
Thu May 8 08:55:00 CEST 2008 - rhafer@suse.de
diff --git a/openldap2-client.spec b/openldap2-client.spec
index d2ee2f1..b1eb63f 100644
--- a/openldap2-client.spec
+++ b/openldap2-client.spec
@@ -29,12 +29,14 @@ Summary: OpenLDAP Client Utilities
%endif
AutoReqProv: on
Version: 2.4.9
-Release: 1
+Release: 3
Source: openldap-%{version}.tar.bz2
Source1: openldap-rc.tgz
Source2: addonschema.tar.gz
Source3: DB_CONFIG
Source4: sasl-slapd.conf
+Source5: README.update
+Source100: openldap-2.3.37.tar.bz2
Patch: openldap2.dif
Patch1: secpatch.dif
Patch2: slapd_conf.dif
@@ -45,6 +47,7 @@ Patch6: libldap-gethostbyname_r.dif
Patch7: pie-compile.dif
Patch8: slapd_getaddrinfo_dupl.dif
Patch9: openldap2-add-gnu-source.diff
+Patch100: openldap-2.3.37.dif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@@ -112,7 +115,7 @@ Authors:
The OpenLDAP Project
%prep
-%setup -q -n openldap-%{version} -a1 -a2
+%setup -q -n openldap-%{version} -a1 -a2 -b100
%patch
%patch1
%patch2
@@ -123,6 +126,9 @@ Authors:
%patch7
%patch8 -p1
%patch9 -p1
+cp %{SOURCE5} .
+cd ../openldap-2.3.37
+%patch100
%build
%{?suse_update_config:%{suse_update_config -f build}}
@@ -165,6 +171,25 @@ export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -DLDAP_DEPRECATED -DLDAP_CONN
--with-yielding-select
make depend
make %{?jobs:-j%jobs}
+%if "%{name}" == "openldap2"
+# build a static slapcat binary from the OpenLDAP 2.3 release
+# to be able to update existing databases
+cd ../openldap-2.3.37
+%{?suse_update_config:%{suse_update_config -f build}}
+libtoolize --force
+#aclocal -I build
+autoreconf
+export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -DLDAP_DEPRECATED"
+./configure --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc \
+ --localstatedir=/var/run/slapd --libexecdir=/usr/lib/openldap \
+ --libdir=%{_libdir} --mandir=%{_mandir} --enable-aci \
+ --enable-hdb --enable-bdb --enable-ldbm --enable-crypt \
+ --enable-ipv6=no \
+ --enable-ldap --enable-monitor --enable-meta --enable-rewrite \
+ --enable-dynamic=no --enable-shared=no
+make depend
+make %{?jobs:-j%jobs}
+%endif
%check
# calculate the base port to be use in the test-suite
@@ -204,6 +229,8 @@ rm -f `find doc/guide ! -name *.html -a ! -name *.gif -a ! -name *.png -a ! -ty
rm -rf doc/guide/release
rm -f $RPM_BUILD_ROOT/etc/openldap/DB_CONFIG.example
rm -f $RPM_BUILD_ROOT/var/run/slapd/openldap-data/DB_CONFIG.example
+# install 2.3 slapcat
+install -m 755 ../openldap-2.3.37/servers/slapd/slapcat $RPM_BUILD_ROOT/usr/sbin/openldap-2.3-slapcat
%endif
rm -f $RPM_BUILD_ROOT/usr/lib/openldap/modules/*.a
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-dnssrv.5
@@ -215,7 +242,6 @@ rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-sql.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-tcl.5
# Remove *.la files, libtool does not handle this correct
rm -f $RPM_BUILD_ROOT%{_libdir}/lib*.la
-#
#put filelists into files
cat >openldap2.filelist <openldap2.filelist <openldap2.filelist < openldap2-client.filelist < /dev/null || :
/usr/sbin/useradd -r -o -g ldap -u 76 -s /bin/bash -c "User for OpenLDAP" -d \
-/var/lib/ldap ldap 2> /dev/null || :
+ /var/lib/ldap ldap 2> /dev/null || :
+# try to figure out if a db update is needed
+if [ ${1:-0} -gt 1 ] && [ -f /usr/lib/openldap/slapd ] &&
+ /usr/bin/strings /usr/lib/openldap/slapd | \
+ grep "slapd 2.3" 2>&1 > /dev/null;
+then
+ # create a backup of the schema shipped with 2.3
+ # at least core.schema changed between 2.3 and 2.4
+ TEMPDIR=`mktemp -d /etc/openldap/schema.backup.XXXXXX`
+ echo "Schema backup created in $TEMPDIR"
+ cp -p --remove-destination /etc/openldap/schema/* $TEMPDIR
+ echo $TEMPDIR > /etc/openldap/UPDATE_NEEDED ;
+fi
%post
if [ ${1:-0} -gt 1 ] && [ -f %{_libdir}/sasl2/slapd.conf ] ; then
@@ -315,6 +355,67 @@ if [ ${1:-0} -gt 1 ] && [ -f %{_libdir}/sasl2/slapd.conf ] ; then
fi
%{fillup_and_insserv -n -s openldap ldap START_LDAP}
%{remove_and_set -n openldap OPENLDAP_RUN_DB_RECOVER}
+# convert database if needed
+if [ -f /etc/openldap/UPDATE_NEEDED ] ; then
+ read SCHEMA_BACKUP < /etc/openldap/UPDATE_NEEDED
+ SLAPD_CONF=/etc/openldap/slapd.conf
+ sed -e "s;/etc/openldap/schema/;$SCHEMA_BACKUP/;g" \
+ < $SLAPD_CONF > $SCHEMA_BACKUP/slapd.conf.update
+ LOGFILE="slaptool.log"
+ BACKENDS=`grep ^database $SLAPD_CONF | awk '{print $2}'`
+ DIRECTORIES=(`grep ^directory $SLAPD_CONF | awk '{print $2}'`)
+ MSG=""
+ db_num=0
+ dir_num=0
+ for i in $BACKENDS; do
+ db_num=$((db_num+1));
+ if [ "x$i" = "xbdb" ]; then
+ db_dir=${DIRECTORIES[$dir_num]};
+ if [ -f $db_dir/id2entry.bdb ] ; then
+ rm $db_dir/__db* ;
+ mkdir $db_dir/db_bak ;
+ echo "Dumping database to: $db_dir/ldapbak.ldif.$db_num" ;
+ /usr/sbin/openldap-2.3-slapcat -T c \
+ -f $SCHEMA_BACKUP/slapd.conf.update \
+ -n $db_num -l $db_dir/ldapbak.ldif.$db_num ;
+ mv $db_dir/*.bdb $db_dir/db_bak/ ;
+ mv $db_dir/log.* $db_dir/db_bak/ ;
+ rm -f $db_dir/__db* ;
+ fi
+ dir_num=$((dir_num+1));
+ fi
+ done
+ db_num=0
+ dir_num=0
+ for i in $BACKENDS; do
+ db_num=$((db_num+1));
+ if [ "x$i" = "xbdb" ] || [ "x$i" = "xhdb" ] ; then
+ db_dir=${DIRECTORIES[$dir_num]};
+ if [ -s $db_dir/ldapbak.ldif.$db_num ] ; then
+ if [ `wc -l $db_dir/ldapbak.ldif.$db_num | awk '{print $1}'` -lt 1000000 ]; then
+ echo "Restoring $i database in $db_dir" ;
+ slapadd -q -n $db_num -f $SLAPD_CONF -l $db_dir/ldapbak.ldif.$db_num 2>> $db_dir/$LOGFILE ;
+ if [ $? -ne 0 ]; then
+ MSG="$MSG\nFailed to restore database in $db_dir";
+ MSG="$MSG\nPlease restore manually from the LDIF dump $db_dir/ldapbak.ldif.$db_num\n";
+ else
+ rm -f $db_dir/ldapbak.ldif.$db_num
+ rm -rf $db_dir/db_bak/
+ fi
+ else
+ MSG="$MSG\nPlease restore the database in $db_dir manually by using";
+ MSG="$MSG\nslapadd with the LDIF dump $db_dir/ldapbak.ldif.$db_num\n";
+ fi
+ fi
+ dir_num=$((dir_num+1));
+ fi
+ done
+ if [ "$MSG" ] ; then
+ echo -e "$MSG";
+ else
+ rm -f /etc/openldap/UPDATE_NEEDED ;
+ fi
+fi
%preun
%stop_on_removal ldap
@@ -345,6 +446,8 @@ fi
%endif
%changelog
+* Fri May 16 2008 rhafer@suse.de
+- Support update from 2.3 releases (bnc#390247)
* Thu May 08 2008 rhafer@suse.de
- Update to Version 2.4.9. Most important changes:
* Fixed libldap to use unsigned port (ITS#5436)
diff --git a/openldap2.changes b/openldap2.changes
index c5ca45b..1ec48cf 100644
--- a/openldap2.changes
+++ b/openldap2.changes
@@ -1,3 +1,8 @@
+-------------------------------------------------------------------
+Fri May 16 13:24:11 CEST 2008 - rhafer@suse.de
+
+- Support update from 2.3 releases (bnc#390247)
+
-------------------------------------------------------------------
Thu May 8 08:55:00 CEST 2008 - rhafer@suse.de
diff --git a/openldap2.spec b/openldap2.spec
index 7da7fe6..f680374 100644
--- a/openldap2.spec
+++ b/openldap2.spec
@@ -29,12 +29,14 @@ Summary: The OpenLDAP Server
%endif
AutoReqProv: on
Version: 2.4.9
-Release: 1
+Release: 3
Source: openldap-%{version}.tar.bz2
Source1: openldap-rc.tgz
Source2: addonschema.tar.gz
Source3: DB_CONFIG
Source4: sasl-slapd.conf
+Source5: README.update
+Source100: openldap-2.3.37.tar.bz2
Patch: openldap2.dif
Patch1: secpatch.dif
Patch2: slapd_conf.dif
@@ -45,6 +47,7 @@ Patch6: libldap-gethostbyname_r.dif
Patch7: pie-compile.dif
Patch8: slapd_getaddrinfo_dupl.dif
Patch9: openldap2-add-gnu-source.diff
+Patch100: openldap-2.3.37.dif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@@ -115,7 +118,7 @@ Authors:
The OpenLDAP Project
%prep
-%setup -q -n openldap-%{version} -a1 -a2
+%setup -q -n openldap-%{version} -a1 -a2 -b100
%patch
%patch1
%patch2
@@ -126,6 +129,9 @@ Authors:
%patch7
%patch8 -p1
%patch9 -p1
+cp %{SOURCE5} .
+cd ../openldap-2.3.37
+%patch100
%build
%{?suse_update_config:%{suse_update_config -f build}}
@@ -168,6 +174,25 @@ export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -DLDAP_DEPRECATED -DLDAP_CONN
--with-yielding-select
make depend
make %{?jobs:-j%jobs}
+%if "%{name}" == "openldap2"
+# build a static slapcat binary from the OpenLDAP 2.3 release
+# to be able to update existing databases
+cd ../openldap-2.3.37
+%{?suse_update_config:%{suse_update_config -f build}}
+libtoolize --force
+#aclocal -I build
+autoreconf
+export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -DLDAP_DEPRECATED"
+./configure --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc \
+ --localstatedir=/var/run/slapd --libexecdir=/usr/lib/openldap \
+ --libdir=%{_libdir} --mandir=%{_mandir} --enable-aci \
+ --enable-hdb --enable-bdb --enable-ldbm --enable-crypt \
+ --enable-ipv6=no \
+ --enable-ldap --enable-monitor --enable-meta --enable-rewrite \
+ --enable-dynamic=no --enable-shared=no
+make depend
+make %{?jobs:-j%jobs}
+%endif
%check
# calculate the base port to be use in the test-suite
@@ -207,6 +232,8 @@ rm -f `find doc/guide ! -name *.html -a ! -name *.gif -a ! -name *.png -a ! -ty
rm -rf doc/guide/release
rm -f $RPM_BUILD_ROOT/etc/openldap/DB_CONFIG.example
rm -f $RPM_BUILD_ROOT/var/run/slapd/openldap-data/DB_CONFIG.example
+# install 2.3 slapcat
+install -m 755 ../openldap-2.3.37/servers/slapd/slapcat $RPM_BUILD_ROOT/usr/sbin/openldap-2.3-slapcat
%endif
rm -f $RPM_BUILD_ROOT/usr/lib/openldap/modules/*.a
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-dnssrv.5
@@ -218,7 +245,6 @@ rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-sql.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-tcl.5
# Remove *.la files, libtool does not handle this correct
rm -f $RPM_BUILD_ROOT%{_libdir}/lib*.la
-#
#put filelists into files
cat >openldap2.filelist <openldap2.filelist <openldap2.filelist < openldap2-client.filelist < /dev/null || :
/usr/sbin/useradd -r -o -g ldap -u 76 -s /bin/bash -c "User for OpenLDAP" -d \
-/var/lib/ldap ldap 2> /dev/null || :
+ /var/lib/ldap ldap 2> /dev/null || :
+# try to figure out if a db update is needed
+if [ ${1:-0} -gt 1 ] && [ -f /usr/lib/openldap/slapd ] &&
+ /usr/bin/strings /usr/lib/openldap/slapd | \
+ grep "slapd 2.3" 2>&1 > /dev/null;
+then
+ # create a backup of the schema shipped with 2.3
+ # at least core.schema changed between 2.3 and 2.4
+ TEMPDIR=`mktemp -d /etc/openldap/schema.backup.XXXXXX`
+ echo "Schema backup created in $TEMPDIR"
+ cp -p --remove-destination /etc/openldap/schema/* $TEMPDIR
+ echo $TEMPDIR > /etc/openldap/UPDATE_NEEDED ;
+fi
%post
if [ ${1:-0} -gt 1 ] && [ -f %{_libdir}/sasl2/slapd.conf ] ; then
@@ -318,6 +358,67 @@ if [ ${1:-0} -gt 1 ] && [ -f %{_libdir}/sasl2/slapd.conf ] ; then
fi
%{fillup_and_insserv -n -s openldap ldap START_LDAP}
%{remove_and_set -n openldap OPENLDAP_RUN_DB_RECOVER}
+# convert database if needed
+if [ -f /etc/openldap/UPDATE_NEEDED ] ; then
+ read SCHEMA_BACKUP < /etc/openldap/UPDATE_NEEDED
+ SLAPD_CONF=/etc/openldap/slapd.conf
+ sed -e "s;/etc/openldap/schema/;$SCHEMA_BACKUP/;g" \
+ < $SLAPD_CONF > $SCHEMA_BACKUP/slapd.conf.update
+ LOGFILE="slaptool.log"
+ BACKENDS=`grep ^database $SLAPD_CONF | awk '{print $2}'`
+ DIRECTORIES=(`grep ^directory $SLAPD_CONF | awk '{print $2}'`)
+ MSG=""
+ db_num=0
+ dir_num=0
+ for i in $BACKENDS; do
+ db_num=$((db_num+1));
+ if [ "x$i" = "xbdb" ]; then
+ db_dir=${DIRECTORIES[$dir_num]};
+ if [ -f $db_dir/id2entry.bdb ] ; then
+ rm $db_dir/__db* ;
+ mkdir $db_dir/db_bak ;
+ echo "Dumping database to: $db_dir/ldapbak.ldif.$db_num" ;
+ /usr/sbin/openldap-2.3-slapcat -T c \
+ -f $SCHEMA_BACKUP/slapd.conf.update \
+ -n $db_num -l $db_dir/ldapbak.ldif.$db_num ;
+ mv $db_dir/*.bdb $db_dir/db_bak/ ;
+ mv $db_dir/log.* $db_dir/db_bak/ ;
+ rm -f $db_dir/__db* ;
+ fi
+ dir_num=$((dir_num+1));
+ fi
+ done
+ db_num=0
+ dir_num=0
+ for i in $BACKENDS; do
+ db_num=$((db_num+1));
+ if [ "x$i" = "xbdb" ] || [ "x$i" = "xhdb" ] ; then
+ db_dir=${DIRECTORIES[$dir_num]};
+ if [ -s $db_dir/ldapbak.ldif.$db_num ] ; then
+ if [ `wc -l $db_dir/ldapbak.ldif.$db_num | awk '{print $1}'` -lt 1000000 ]; then
+ echo "Restoring $i database in $db_dir" ;
+ slapadd -q -n $db_num -f $SLAPD_CONF -l $db_dir/ldapbak.ldif.$db_num 2>> $db_dir/$LOGFILE ;
+ if [ $? -ne 0 ]; then
+ MSG="$MSG\nFailed to restore database in $db_dir";
+ MSG="$MSG\nPlease restore manually from the LDIF dump $db_dir/ldapbak.ldif.$db_num\n";
+ else
+ rm -f $db_dir/ldapbak.ldif.$db_num
+ rm -rf $db_dir/db_bak/
+ fi
+ else
+ MSG="$MSG\nPlease restore the database in $db_dir manually by using";
+ MSG="$MSG\nslapadd with the LDIF dump $db_dir/ldapbak.ldif.$db_num\n";
+ fi
+ fi
+ dir_num=$((dir_num+1));
+ fi
+ done
+ if [ "$MSG" ] ; then
+ echo -e "$MSG";
+ else
+ rm -f /etc/openldap/UPDATE_NEEDED ;
+ fi
+fi
%preun
%stop_on_removal ldap
@@ -348,6 +449,8 @@ fi
%endif
%changelog
+* Fri May 16 2008 rhafer@suse.de
+- Support update from 2.3 releases (bnc#390247)
* Thu May 08 2008 rhafer@suse.de
- Update to Version 2.4.9. Most important changes:
* Fixed libldap to use unsigned port (ITS#5436)