[Pkg-openldap-devel] [openldap] 03/07: r1646 at pulsar: torsten | 2005-04-01 18:01:04 +0200 * Another pass over the maintainer scripts to remove cruft and tidy up the code a bit. Fixed some bugs on the way. -- Torsten Landschoff <torsten at debian.org> Fri, 1 Apr 2005 17:41:36 +0200

Timo Aaltonen tjaalton-guest at alioth.debian.org
Thu Oct 10 05:35:01 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-1
in repository openldap.

commit d16429b436a0dae571fa88ef2a772429c3e6832a
Author: Torsten Landschoff <torsten at debian.org>
Date:   Fri Apr 1 16:46:54 2005 +0000

     r1646 at pulsar:  torsten | 2005-04-01 18:01:04 +0200
      * Another pass over the maintainer scripts to remove cruft and tidy up
        the code a bit. Fixed some bugs on the way.
     -- Torsten Landschoff <torsten at debian.org>  Fri,  1 Apr 2005 17:41:36 +0200
---
 debian/changelog            |    4 +-
 debian/slapd.config         |    2 +-
 debian/slapd.postinst       |    2 +-
 debian/slapd.scripts-common |  288 ++++++++++++++++++-------------------------
 4 files changed, 128 insertions(+), 168 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1b9d3ef..35a534d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,10 @@ openldap2.2 (2.2.23-1) unstable; urgency=low
 
   * debian/slapd.scripts-common: Move all shell functions of the maintainer 
     scripts here to have it all in one place.
+  * Another pass over the maintainer scripts to remove cruft and tidy up
+    the code a bit. Fixed some bugs on the way.
 
- --
+ -- Torsten Landschoff <torsten at debian.org>  Fri,  1 Apr 2005 17:41:36 +0200
 
 openldap2.2 (2.2.23-0.pre6) experimental; urgency=low
 
diff --git a/debian/slapd.config b/debian/slapd.config
index d4dbfa8..3995f92 100644
--- a/debian/slapd.config
+++ b/debian/slapd.config
@@ -22,7 +22,7 @@ configure_dumping
    
 # On upgrade from pre-2.1 we have to ask if we shall fix the config file (if
 # it exists anyway).
-if upgrading_version_pre21; then
+if previous_version_older 2.1; then
   if [ -e /etc/ldap/slapd.conf ]; then
     db_input medium slapd/autoconf_modules || true
     db_go || true
diff --git a/debian/slapd.postinst b/debian/slapd.postinst
index 932543f..5fd150e 100644
--- a/debian/slapd.postinst
+++ b/debian/slapd.postinst
@@ -26,7 +26,7 @@ fi
 # Update configuration files for new features				{{{
 
 configure_v2_protocol_support
-if upgrading_version_pre21; then
+if previous_version_older 2.1; then
 	autoconfigure_modules
 fi
 update_access_config_directives
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index 637459e..92e9648 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -1,18 +1,6 @@
 # This file can be included with #SCRIPTSCOMMON#
 
 
-# ===== Global variables ================================================ {{{
-#
-# At some points we need to know which version we are upgrading from if
-# any. More precisely we only care about the configuration and data we 
-# might have laying around. Some parts also want to know which mode the
-# script is running in.
-
-MODE="$1"		# install, upgrade, etc. - see debian-policy
-OLD_VERSION="$2"
-
-# }}}
-
 # ===== Dumping and reloading using LDIF files =========================  {{{
 #
 # If incompatible changes are done to the database underlying a LDAP 
@@ -727,7 +715,7 @@ update_access_config_directives() {					# {{{
 	echo -n "  Updating config access directives... " >&2
 	new_conf="`mktemp -q ${SLAPD_CONF}.XXXXXX`"
 
-	read_config < "$SLAPD_CONF" | perl -p \
+	merge_logical_lines < "$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"
@@ -792,28 +780,6 @@ manual_configuration_wanted() {
   return 1
 }
  
-# Create the password hash for the given password
-create_password_hash() {
-  perl -e '
-    sub GenRandom {
-      local ($len) = @_;
-      local ($char, $data, @chars);
-      @chars = split(//, "abcdefghijklmnopqrstuvwxyz"
-                       . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
-    
-      open(RD, "</dev/urandom") or die "Failed to open random source";
-      $data = "";
-      while ($len--) {
-        read(RD, $char, 1) == 1 or die "Failed to read random data";
-	$data .= $chars[ord($char) % @chars];
-      }
-    
-      close(RD);
-      return $data;
-    }
-    print crypt($ARGV[0], GenRandom(2));' "$1"
-}
-
 # Query the information we need to create an initial directory
 query_initial_config() {
   while true; do
@@ -890,63 +856,88 @@ validate_initial_config() {
   fi
 }
 
+crypt_admin_pass() {							# {{{
 # Store the encrypted admin password into the debconf db
-crypt_admin_pass() {
-  db_get slapd/password1
-  db_set slapd/internal/adminpw `create_password_hash "$RET"`
-}
+# Usage: crypt_admin_pass
+# XXX: This is the standard unix crypt. Maybe we can get something stronger?
 
-slave_databases_without_updateref() {
-  (read_slapd_conf < $SLAPD_CONF && echo database) | \
-    while read command data; do
-      case $command in
-      database)
-        if [ -n "$backend" ] && [ -n "$updatedn" ] && [ -z "$updateref" ]; then
-	  return 1
-	fi
-	backend="$data"
-        updatedn=""
-	updateref=""
-        ;;
-      updatedn)
-        updatedn="$data"
-        ;;
-      updateref)
-        updateref="$data"
-        ;;
-      esac
-    done || return 0
-  return 1
+  	db_get slapd/password1
+  	db_set slapd/internal/adminpw `create_password_hash "$RET"`
 }
 
+# }}}
+create_password_hash() {						# {{{
+# Create the password hash for the given password
+# Usage: hash=`create_password_hash "$password"`
+
+  	perl - "$1" <<'EOF'
+# ---------------
+sub GenRandom {
+	local ($len) = @_;
+      	local ($char, $data, @chars);
+      	@chars = split(//, "abcdefghijklmnopqrstuvwxyz"
+                         . "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+    
+      	open(RD, "</dev/urandom") or die "Failed to open random source";
+      	$data = "";
+      	while ($len--) {
+        	read(RD, $char, 1) == 1 or die "Failed to read random data";
+		$data .= $chars[ord($char) % @chars];
+      	}
+    
+      	close(RD);
+      	return $data;
+}
+print crypt($ARGV[0], GenRandom(2));
+EOF
+# --------------
+}
 
+# }}}
+slave_databases_without_updateref() {					# {{{
+# Read the configuration of the slapd server and check if there are any
+# slave backends without updateref specified.
+# Usage: if slave_databases_without_updateref; then ... fi
 
+	(read_slapd_conf < $SLAPD_CONF && echo database) | \
+    	while read command data; do
+      		case $command in
+      		database)
+        		if [ -n "$backend" ] && [ -n "$updatedn" ] \
+				    && [ -z "$updateref" ]; then
+		  		return 0
+			fi
+			backend="$data"
+        		updatedn=""
+			updateref=""
+        		;;
+      		updatedn)
+        		updatedn="$data"
+        		;;
+      		updateref)
+        		updateref="$data"
+        		;;
+      		esac
+    	done || return 0
 
-
-ANY_DATABASE_FORMAT_CHANGED="2.2.23-0.pre6"
-DATABASE_FORMAT_CHANGED_BDB="2.2.23-0.pre6"
-DATABASE_FORMAT_CHANGED_LDBM="2.2.23-0.pre6"
-
-
-# Source the init script configuration
-if [ -f "/etc/default/slapd" ]; then
-  . /etc/default/slapd
-fi
-
-# Load the default location of the slapd config file
-if [ -z "$SLAPD_CONF" ]; then
-  SLAPD_CONF="/etc/ldap/slapd.conf"
-fi
-
-# Check if we are upgrading from a version prior to OpenLDAP 2.1
-upgrading_version_pre21() {
-  if dpkg --compare-versions "$OLD_VERSION" lt-nl 2.1; then
-    return 0
-  else
-    return 1
-  fi
+  	return 1
 }
 
+# }}}
+previous_version_older() {						# {{{
+# 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" lt-nl "$1"; then
+		return 0
+	else
+		return 1
+	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
@@ -959,102 +950,69 @@ previous_version_newer() {						# {{{
 		return 1
 	fi
 } # }}}
+supported_backend() {							# {{{
+# Check if upgrading a database in the named backend is supported by
+# our scripts.
+# Usage: if supported_backend "backend"; then ... 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
-    return 0
-  else
-    return 1
-  fi
+	case "$1" in ldbm|bdb|hdb) return 0; esac
+	return 1
 }
 
-# Check if database with backend passed needs to be reloaded
-database_needs_reload() {
-  backend="$1"
-  format_changed=$(eval echo '$DATABASE_FORMAT_CHANGED_'`echo "$backend"|tr a-z A-Z`)
-  if dpkg --compare-versions "$OLD_VERSION" lt-nl "$format_changed"; then
-    return 0
-  else
-    return 1
-  fi
-}
+# }}}
+is_initial_configuration() {						# {{{
+# Check if this is the initial configuration and not an upgrade of an 
+# existing configuration
+# Usage: if is_initial_configuration "$@"; then ... fi from top level
 
-database_needs_fixing() {
-  if dpkg --compare-versions "$OLD_VERSION" lt-nl "2.1"; then
-    return 0
-  else
-    return 1
-  fi
+	# Plain installation
+	if [ "$1" = configure ] && [ -z "$2" ]; then
+		return 0
+  	fi
+	# Configuration via dpkg-reconfigure
+	if [ "$1" = reconfigure ] || [ "$DEBCONF_RECONFIGURE" ]; then
+    		return 0
+  	fi
+  	return 1
 }
 
-read_config() {								# {{{
-# Read a config file from stdin merging logical lines and output the result
-# on stdout.
-
-	merge_logical_lines
-} # }}}
+# }}}
+is_empty_dir() {							# {{{
+# Check if a path refers to an empty directory
+# Usage: if is_empty_dir "$dir"; then ... fi
 
-# Directory names are whitespace-sensitive, but suffixes are not.  Discard
-# whitespace, so we can create cleaner backup directory names.
-canonical_suffix() {
-  eval echo $1 | sed -e 's/[[:space:]]+//g'
+	output=`find "$1" -type d -maxdepth 0 -empty 2>/dev/null`
+  	if [ "$output" ]; then
+    		return 0
+  	else
+    		return 1
+  	fi
 }
 
-# Check if upgrading a database in the named backend is supported by
-# our scripts.
-supported_backend() {
-  case "$1" in ldbm|bdb|hdb) return 0; esac
-  return 1
-}
+# }}}
 
-# Check if this is the initial configuration and not an upgrade of an 
-# existing configuration
-is_initial_configuration() {
-  # Plain installation
-  if [ "$1" = configure ] && [ -z "$2" ]; then
-    return 0
-  fi
-  # Configuration via dpkg-reconfigure
-  if [ "$1" = reconfigure ] || [ "$DEBCONF_RECONFIGURE" ]; then
-    return 0
-  fi
-  return 1
-}
+# ===== Global variables ================================================ {{{
+#
+# At some points we need to know which version we are upgrading from if
+# any. More precisely we only care about the configuration and data we 
+# might have laying around. Some parts also want to know which mode the
+# script is running in.
 
-# Check, if the user wants an LDIF dump of the directory
-# XXX: Currently dumps unconditionally
-ldif_dump_wanted() {
-  return 0
-}
+MODE="$1"		# install, upgrade, etc. - see debian-policy
+OLD_VERSION="$2"
 
-# Ask for the filename of the dump file
-# XXX: Currently just uses /var/backups/ldap/$OLD_VERSION/slapd-${suffix}-slapcat.ldif
-ldif_dump_location() {
-  local suffix=$1
-  echo "/var/backups/ldap/$OLD_VERSION/slapd-${suffix}-slapcat.ldif"
-}
+# Source the init script configuration
+# See example file debian/slapd.default for variables defined here
+if [ -f "/etc/default/slapd" ]; then
+  	. /etc/default/slapd
+fi
 
-# Create directory for dump file
-create_ldif_dump_location() {
-  # Make our backup directory if it does not exist already
-  if [ -d /var/backups/ldap ]; then
-    chmod 700 /var/backups/ldap
-  else
-    mkdir -p -m 700 /var/backups/ldap
-  fi
-  mkdir -p -m 700 /var/backups/ldap/$OLD_VERSION/
-}
+# Load the default location of the slapd config file
+if [ -z "$SLAPD_CONF" ]; then
+  	SLAPD_CONF="/etc/ldap/slapd.conf"
+fi
 
-# Check if a path refers to an empty directory
-is_empty_dir() {
-  output=`find "$1" -type d -maxdepth 0 -empty 2>/dev/null`
-  if [ -n "$output" ]; then
-    return 0
-  else
-    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