[Pkg-openldap-devel] [openldap] 12/17: r1312 at pulsar: torsten | 2005-03-11 18:40:06 +0100 * slapd.postinst: Try to fix slapd.conf for syntactic and semantic changes introduced upstream into 2.2.x. -- Torsten Landschoff <torsten at debian.org> Fri, 11 Mar 2005 15:40:25 +0100

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:34:38 UTC 2013


This is an automated email from the git hooks/post-receive script.

tjaalton-guest pushed a commit to annotated tag 2.2.23-0.pre5
in repository openldap.

commit 11747787988e046b1c958af854d4ab09686cf406
Author: Torsten Landschoff <torsten at debian.org>
Date:   Fri Mar 11 17:51:07 2005 +0000

     r1312 at pulsar:  torsten | 2005-03-11 18:40:06 +0100
      * slapd.postinst: Try to fix slapd.conf for syntactic and semantic changes
        introduced upstream into 2.2.x.
     -- Torsten Landschoff <torsten at debian.org>  Fri, 11 Mar 2005 15:40:25 +0100
---
 debian/changelog            |    4 +++-
 debian/check_upgradepath    |   11 ++++++++---
 debian/slapd.postinst       |   46 ++++++++++++++++++++++++++++++++++++++-----
 debian/slapd.scripts-common |   24 ++++++++++++++++++++++
 4 files changed, 76 insertions(+), 9 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 88e4ff3..eb94ed7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,8 +9,10 @@ openldap2.2 (2.2.23-0.pre5) experimental; urgency=low
   * Make slapd.init idempotent by adding --oknodo to start-stop-daemon
     invocations (closes: #298741). Kudos to Bill Allombert for this
     patch.
+  * slapd.postinst: Try to fix slapd.conf for syntactic and semantic changes
+    introduced upstream into 2.2.x.
 
- --
+ -- Torsten Landschoff <torsten at debian.org>  Fri, 11 Mar 2005 15:40:25 +0100
 
 openldap2.2 (2.2.23-0.pre4) experimental; urgency=low
 
diff --git a/debian/check_upgradepath b/debian/check_upgradepath
index efd9239..a06126c 100644
--- a/debian/check_upgradepath
+++ b/debian/check_upgradepath
@@ -12,7 +12,9 @@ set -e
 unset LC_ALL
 unset LC_CTYPE
 unset LC_MESSAGES
-
+# XXX: comment out when testing new versions. Needed so libc6 does not
+# ask for restarting services.
+export DEBIAN_FRONTEND=noninteractive
 
 woodytar=$chroot_dir/woody_base.tar.gz
 
@@ -54,8 +56,9 @@ setup_chroot() {
 	# If there is a tar archive with a base system we use it
 	if [ -e $woodytar ]; then
 		mkdir $chroot_dir/woody
-		tar -C $chroot_dir/woody -xzvf $woodytar | \
-			shtool prop -p "Unpacking system from $woodytar"
+		echo -n "Unpacking system from $woodytar"
+		tar -C $chroot_dir/woody -xzf $woodytar
+		echo "done."
 	# Otherwise we need to create a new base system and save it
 	# to a tar for the next time
 	else
@@ -136,6 +139,8 @@ upgrade() {
 	# Tell our scripts to fix the config
 	debconf_set slapd/fix_directory true
 	debconf_set slapd/password1 foobar
+	debconf_set slapd/autoconf_modules true
+	debconf_set slapd/allow_ldap_v2
 
 	# Do an upgrade of our packages
 	in_target apt-get install -y `dh_listpackages`
diff --git a/debian/slapd.postinst b/debian/slapd.postinst
index d528214..ec3d399 100644
--- a/debian/slapd.postinst
+++ b/debian/slapd.postinst
@@ -49,7 +49,7 @@ move_old_database_away() {						# {{{
 		echo -n "  Moving $databasedir/* to $backupdir... " >&2
 		mkdir -p "$backupdir"
 		mv "$databasedir"/* "$backupdir"/
-		echo done >&2
+		echo done. >&2
 	else
 		cat >&2 <<EOF
   There are leftover files in $databasedir. This will probably break 
@@ -127,7 +127,7 @@ create_new_slapd_conf() {						# {{{
 		assign_permissions "$SLAPD_CONF" "$conf_new"
 	fi
 	mv $conf_new $SLAPD_CONF
-	echo "done" >&2
+	echo "done." >&2
 } 
 # }}}
 noisy_slapadd() {							# {{{
@@ -178,7 +178,7 @@ create_new_directory() {						# {{{
 		userPassword: {crypt}$adminpass
 	EOF
 
-	echo "done" >&2
+	echo "done." >&2
 } 
 # }}}
 autoconfigure_modules() {						# {{{
@@ -216,7 +216,7 @@ autoconfigure_modules() {						# {{{
 	cat $SLAPD_CONF >>$new_conf
 	assign_permissions "$SLAPD_CONF" "$new_conf"
 	mv $new_conf $SLAPD_CONF
-	echo done >&2
+	echo done. >&2
 }
 # }}}
 configure_v2_protocol_support() {					# {{{
@@ -228,7 +228,7 @@ configure_v2_protocol_support() {					# {{{
 	db_get slapd/allow_ldap_v2
 	if [ "$RET" != "true" ]; then return 0; fi
 
-	echo -n "Enabling LDAPv2 support... " >&2
+	echo -n "  Enabling LDAPv2 support... " >&2
 
 	# Check if already enabled
 	if read_slapd_conf < $SLAPD_CONF | \
@@ -365,7 +365,42 @@ import_database() {							# {{{
 	fi
 }
 # }}}
+update_access_config_directives() {					# {{{
+# Update the config file for some changes done for 2.2.x (vs. 2.1.x):
+# access to attribute=<attr> becomes access to attrs=<attr>
+# access to dn=".*,..." becomes access to dn.regex=".*,..."
 
+# For now only the main configuration file is fixed, includes are not 
+# handled.
+
+	local new_conf
+
+	# Check if we have to apply these changes
+	# First changed in Debian release 2.2.23, better update if we are
+	# upgrading something older.
+	if previous_version_newer 2.2.23; then
+		return 0
+	fi
+
+	# Without a configuration we have nothing to update
+	if [ ! -e "$SLAPD_CONF" ]; then
+		echo >&2 \
+		  "  Did not find slapd.conf to update access directives."
+		return 0
+	fi
+
+	echo -n "  Updating config access directives... " >&2
+	new_conf="`mktemp -q ${SLAPD_CONF}.XXXXXX`"
+
+	read_config < "$SLAPD_CONF" | perl -p \
+		-e 'next if not m/^access\s+to/;' \
+		-e 's/dn=/dn.regex=/g;' \
+		-e 's/attribute=/attrs=/g;' >"$new_conf"
+	assign_permissions "$SLAPD_CONF" "$new_conf"
+	mv "$new_conf" "$SLAPD_CONF"
+	echo done. >&2
+
+} # }}}
 
 . /usr/share/debconf/confmodule
 
@@ -385,6 +420,7 @@ configure_v2_protocol_support
 if upgrading_version_pre21; then
 	autoconfigure_modules
 fi
+update_access_config_directives
 # }}}
 
 # BROKEN - please fix the following mess!!  -- Torsten
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index b5f6ac1..6fbc204 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -26,6 +26,19 @@ upgrading_version_pre21() {
   fi
 }
 
+previous_version_newer() {						# {{{
+# Check if the previous version is newer than the reference version passed.
+# If we are not upgrading the previous version is assumed to be newer than
+# any reference version.
+# Usage: previous_version_newer <package version>
+	
+	if dpkg --compare-versions "$OLD_VERSION" gt-nl "$1"; then
+		return 0
+	else
+		return 1
+	fi
+} # }}}
+
 # Check if any database backend would require a reload
 database_might_need_reload() {
   if dpkg --compare-versions "$OLD_VERSION" lt-nl "$ANY_DATABASE_FORMAT_CHANGED"; then
@@ -62,6 +75,7 @@ merge_logical_lines() {
   perl -pe 'BEGIN { undef $/ }; s/\n(?!\n)\s+/ /g;' 
 }
 
+
 # read slapd.conf file and evaluate include statements
 # FIXME: circular loops will cause this to block forever
 # FIXME: handling of relative file names
@@ -76,6 +90,13 @@ read_slapd_conf() {
   done
 }
 
+read_config() {								# {{{
+# Read a config file from stdin merging logical lines and output the result
+# on stdout.
+
+	merge_logical_lines
+} # }}}
+
 # Directory names are whitespace-sensitive, but suffixes are not.  Discard
 # whitespace, so we can create cleaner backup directory names.
 canonical_suffix() {
@@ -179,3 +200,6 @@ is_empty_dir() {
     return 1
   fi
 }
+
+# vim: set sw=8 foldmethod=marker: 
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git



More information about the Pkg-openldap-devel mailing list