[Pkg-openldap-devel] Bug#517556: upgrading slapd fails with multiple databases and dbconfig settings in slapd.conf

Peter Marschall peter at adpm.de
Sat Feb 28 16:20:55 UTC 2009


Package: slapd
Version: 2.4.15-1pm1
Severity: important
Tags: patch

Hi,

on an update from versions below 2.1.14 slapd 2.1.15's postinst script
dumps and reloads the databases.
When trying to relaod the databases the postinst script checks whether the
database directory is empty.
Unfortunately this fails on the second database when slapd.conf contains
"dbconfig" settings.

Cause:
When creating the first database slapadd creates DB_CONFIG files in the
directories of all databases with "dbconfig" settings in slapd.conf.

The attached patch changes the reload routine so that it accepts a
DB_CONFIG in an otherwise empty directory. This makes the upgrade.

This - freshly created - DB_CONFIG file will not be overwritten from
a DB_CONFIG file from the backup (rationale: the admin gave these values
in slapd.conf - no need to get something back from backup).

In addition to that the patch fixes a warning message generated by find
because of the wrong order of parameters.

Hope it helps
Peter

PS: Don't worry about the version number: it's Debian's slapd + the attached patch.



-- System Information:
Debian Release: 5.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages slapd depends on:
ii  adduser                  3.110           add and remove users and groups
ii  coreutils                6.10-6          The GNU core utilities
ii  debconf [debconf-2.0]    1.5.24          Debian configuration management sy
ii  libc6                    2.7-18          GNU C Library: Shared libraries
ii  libdb4.7                 4.7.25-6        Berkeley v4.7 Database Libraries [
ii  libgnutls26              2.6.4-2         the GNU TLS library - runtime libr
ii  libgssapi2-heimdal       1.2.dfsg.1-2.1  Heimdal Kerberos - GSSAPI support 
ii  libldap-2.4-2            2.4.15-1pm1     OpenLDAP libraries
ii  libltdl3                 1.5.26-4        A system independent dlopen wrappe
ii  libperl5.10              5.10.0-19       Shared Perl library
ii  libsasl2-2               2.1.22.dfsg1-23 Cyrus SASL - authentication abstra
ii  libslp1                  1.2.1-7.5       OpenSLP libraries
ii  libwrap0                 7.6.q-16        Wietse Venema's TCP wrappers libra
ii  perl [libmime-base64-per 5.10.0-19       Larry Wall's Practical Extraction 
ii  psmisc                   22.6-1          Utilities that use the proc filesy
ii  unixodbc                 2.2.11-16       ODBC tools libraries

Versions of packages slapd recommends:
ii  libsasl2-modules         2.1.22.dfsg1-23 Cyrus SASL - pluggable authenticat

Versions of packages slapd suggests:
ii  ldap-utils                   2.4.15-1pm1 OpenLDAP utilities

-- debconf information:
  slapd/tlsciphersuite:
  shared/organization: adpm.de
  slapd/upgrade_slapcat_failure:
  slapd/backend: HDB
  slapd/allow_ldap_v2: false
  slapd/no_configuration: false
  slapd/move_old_database: true
  slapd/suffix_change: false
  slapd/dump_database_destdir: /var/backups/slapd-VERSION
  slapd/domain: adpm.de
  slapd/password_mismatch:
  slapd/invalid_config: true
  slapd/slurpd_obsolete:
  slapd/dump_database: when needed
  slapd/migrate_ldbm_to_bdb: false
  slapd/purge_database: false
-------------- next part --------------
--- debian/slapd.scripts-common
+++ debian/slapd.scripts-common	2009-02-28 14:14:36.000000000 +0100
@@ -160,7 +160,8 @@
 	for db in `get_database_list`; do
 		suffix=`get_suffix $db`
 		dbdir=`get_directory $db`
-		if ! is_empty_dir "$dbdir"; then
+		if ! is_empty_dir "$dbdir" &&
+		   ! dir_only_contains_DB_CONFIG "$dbdir"; then
 			echo >&2 \
 			  "  Directory $dbdir for $suffix not empty, aborting."
 			exit 1
@@ -169,13 +170,16 @@
 		file="$dir/$suffix.ldif"
 		echo -n "  - directory $suffix... " >&2
 
-		# If there is an old DB_CONFIG file, restore it before
-		# running slapadd
-		backupdir=`compute_backup_path -n "$dbdir" "$suffix"`
-		if [ -e "$backupdir"/DB_CONFIG ]; then
-			cp -a "$backupdir"/DB_CONFIG "$dbdir"/
-		else
-			copy_example_DB_CONFIG "$dbdir"/
+		# If there is no DB_CONFIG file in the database dir, but
+		# an old DB_CONFIG file in the backup dir,
+		# restore it before running slapadd
+		if [ ! -e "$dbdir"/DB_CONFIG ]; then
+			backupdir=`compute_backup_path -n "$dbdir" "$suffix"`
+			if [ -e "$backupdir"/DB_CONFIG ]; then
+				cp -a "$backupdir"/DB_CONFIG "$dbdir"/
+			else
+				copy_example_DB_CONFIG "$dbdir"/
+			fi
 		fi
 
 		capture_diagnostics slapadd -q -b "$suffix" -l "$file" \
@@ -1014,7 +1018,7 @@
 # Check if a path refers to an empty directory
 # Usage: if is_empty_dir "$dir"; then ... fi
 
-	output=`find "$1" -type d -maxdepth 0 -empty 2>/dev/null`
+	output=`find "$1" -maxdepth 0 -type d -empty 2>/dev/null`
   	if [ "$output" ]; then
     		return 0
   	else
@@ -1024,6 +1028,24 @@
 
 # }}}
 
+# }}}
+dir_only_contains_DB_CONFIG() {							# {{{
+# Check if a path refers to a directory
+# that is empty or contains only DB_CONFIG
+# Usage: if dir_only_contains_DB_CONFIG "$dir"; then ... fi
+
+	test -d "$1" || return 1
+
+	output=`find "$1" -mindepth 1 -maxdepth 1 2>/dev/null | grep -v /DB_CONFIG$`
+  	if [ "$output" ]; then
+    		return 1
+  	else
+    		return 0
+  	fi
+}
+
+# }}}
+
 # ===== Global variables ================================================ {{{
 #
 # At some points we need to know which version we are upgrading from if


More information about the Pkg-openldap-devel mailing list