[Dbconfig-common-changes] [dbconfig-common] r212 - in trunk: . debian dpkg examples/db-test-pgsql-2.0/debian internal

Sean Finney seanius at costa.debian.org
Fri May 12 17:23:06 UTC 2006


Author: seanius
Date: 2006-05-12 17:23:04 +0000 (Fri, 12 May 2006)
New Revision: 212

Added:
   trunk/TODO
Modified:
   trunk/debian/changelog
   trunk/dpkg/config
   trunk/dpkg/postinst
   trunk/dpkg/prerm
   trunk/examples/db-test-pgsql-2.0/debian/postinst
   trunk/internal/pgsql
Log:
next version, w00t!


Added: trunk/TODO
===================================================================
--- trunk/TODO	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/TODO	2006-05-12 17:23:04 UTC (rev 212)
@@ -0,0 +1,31 @@
+- in the long run, hardcoding the question priorities isn't ideal.  for
+  example, if a something goes wrong and the user selects "retry", they
+  should get all questions in case they needed to change something that
+  they missed.
+- provide a way for pgsql dbapp maintainers to specify whether their
+  package should default to using a specific (and pre-created) unix
+  id, or whether it should use a "password" database account
+- related to the above, a way to automatically detect which will work
+  would be nice.
+- the code could use a major cleanup.  much of it was written before
+  i new of the wonder of "local" in shell functions, and there are a
+  lot of global variables that could/should be removed in favor of 
+  something else.
+
+further ahead:
+
+- test suite for testing new versions of dbconfig-common.  ideally it
+  could just be a shell script that:
+	- builds the dbc package
+	- creates a chroot, chroots into it and:
+		- installs the dbc package + deps + db servers, 
+		- creates the examples out of /usr/share/doc/dbconfig-common/examples
+		- installs the examples in various ways to test functionality.
+
+- multiple instance support for many databases from one package.  the
+  idea is to create seperate "package configurations" that are derived
+  from the main configuration, using something to keep them in a namespace
+  that won't conflict with the standard package configurations.  something
+  like /etc/dbconfig-common/package_instance.conf etc.  most of dbconfig's
+  code could escape needing a rewrite then, as we could internally "trick"
+  the code into thinking that was the actual package name.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/debian/changelog	2006-05-12 17:23:04 UTC (rev 212)
@@ -1,4 +1,4 @@
-dbconfig-common (1.8.12.1) unreleased; urgency=low
+dbconfig-common (1.8.13) unstable; urgency=low
 
   [sean finney]
   * now support a dbc_pgsql_createdb_encoding hint option in the postinst
@@ -6,8 +6,23 @@
   * updated czech translation from Miroslav Kure (closes: #366261).
   * a third fix for GRANT command construction hiding in the prerm
     support script.  thanks again to Radu (closes: #362571).
+  * added a check for the version of createuser to prevent the
+    createuser cmd from stopping the install question with a
+    prompt about roles (defaulting to not giving users the
+    role granting privs).
+  * change the authmethod-user question to medium priority, but
+    we really need a way to let the maintainers specify the default
+    authentication method.
+  * fix typo in postinst support code that always logs "administrative
+    sql" even when it's doing normal sql.
+  * error checking when dumping the database in prerm.  needs a bit
+    more work still as we end up going back through the postinst/configure
+    code again which isn't smart enough to realize what's going on sometimes.
+  * fix some internal pgsql code where $extra was tossed around too much
+    in the wrong scope.
+  * support for postgresql-8.1.
 
- -- sean finney <seanius at debian.org>  Thu, 11 May 2006 08:53:37 +0200
+ -- sean finney <seanius at debian.org>  Fri, 12 May 2006 19:21:48 +0200
 
 dbconfig-common (1.8.12) unstable; urgency=low
 

Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/dpkg/config	2006-05-12 17:23:04 UTC (rev 212)
@@ -274,7 +274,7 @@
 			if [ ! "$dbc_authmethod_user" ]; then
 				db_set $dbc_package/pgsql/authmethod-user "$authmethod_admin"
 			fi
-			db_input low $dbc_package/pgsql/authmethod-user || true
+			db_input medium $dbc_package/pgsql/authmethod-user || true
 		fi
 	;;
 	# state 9 - pgsql auth part 3, admin/app user, dbname

Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/dpkg/postinst	2006-05-12 17:23:04 UTC (rev 212)
@@ -104,7 +104,7 @@
 			fi
 			
 			if [ -f "$dbc_sqlfile" ]; then
-				dbc_logpart "populating database via administrative sql... "
+				dbc_logpart "populating database via sql... "
 				_dbc_asuser="yes"
 				$dbc_sqlfile_cmd $dbc_sqlfile || dbc_install_error "populating database"
 				_dbc_asuser=""

Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/dpkg/prerm	2006-05-12 17:23:04 UTC (rev 212)
@@ -91,7 +91,7 @@
 			_dbc_dbfile=`mktemp /var/tmp/$dbc_package.$dbc_dbname.$_dbc_now.$dbc_dbtype.XXXXXX`
 			# XXX error checking here
 			echo dbconfig-common: dumping $dbc_dbtype database $dbc_dbname to $_dbc_dbfile >&2
-			$dbc_dump_cmd > $_dbc_dbfile
+			$dbc_dump_cmd > $_dbc_dbfile || dbc_remove_error "dumping database"
 			echo dbconfig-common: dropping $dbc_dbtype database $dbc_dbname >&2
 			$dbc_dropdb_cmd || dbc_remove_error "dropping database"
 			[ "$dbc_tried_again" ] && return 0

Modified: trunk/examples/db-test-pgsql-2.0/debian/postinst
===================================================================
--- trunk/examples/db-test-pgsql-2.0/debian/postinst	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/examples/db-test-pgsql-2.0/debian/postinst	2006-05-12 17:23:04 UTC (rev 212)
@@ -5,6 +5,9 @@
 
 . /usr/share/debconf/confmodule
 . /usr/share/dbconfig-common/dpkg/postinst.pgsql 
+
+# you can set the default database encoding to something else
+dbc_pgsql_createdb_encoding="UTF8"
 dbc_go db-test-pgsql $@
 
 #DEBHELPER#

Modified: trunk/internal/pgsql
===================================================================
--- trunk/internal/pgsql	2006-05-11 06:59:40 UTC (rev 211)
+++ trunk/internal/pgsql	2006-05-12 17:23:04 UTC (rev 212)
@@ -80,13 +80,13 @@
 	if [ "$dbc_ssl" ]; then PGSSLMODE="require"; fi
 	if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
 	if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
-	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' psql --set "ON_ERROR_STOP=1" -q $extra $*" 2>&1` || retval=$?
+	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' PGSSLMODE='$PGSSLMODE' psql --set "ON_ERROR_STOP=1" -q $extra $*" 2>&1` || retval=$?
 	_dbc_psql_cmd_cleanup
 	return $retval
 }
 
 _dbc_createdb(){
-	local extra retval PGSSLMODE localuser _dbc_asuser
+	local extra extrasql retval PGSSLMODE localuser _dbc_asuser
 	localuser=`_dbc_psql_local_username`
 	PGSSLMODE="prefer"
 	retval=0
@@ -95,8 +95,12 @@
 	if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
 	if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
 	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
-	if [ "$dbc_pgsql_createdb_encoding" ]; then extra="$extra -E '$dbc_pgsql_createdb_encoding'"; fi
-	dbc_error=`su -s /bin/sh  $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' createdb -q -O $dbc_dbuser $extra $*" 2>&1` || retval=$?
+	if [ "$dbc_pgsql_createdb_encoding" ]; then 
+		extrasql=" WITH ENCODING = '$dbc_pgsql_createdb_encoding'"; 
+	fi
+	extra="$extra template1"
+	_dbc_pgsql_exec_command "CREATE DATABASE \"$dbc_dbname\"$extrasql"
+	retval=$?
 	_dbc_psql_cmd_cleanup
 	return $retval
 }
@@ -111,11 +115,15 @@
 	if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
 	if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
 	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
-	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' dropdb -q $extra $*" 2>&1` || retval=$?
+	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' PGSSLMODE='$PGSSLMODE' dropdb -q $extra $*" 2>&1` || retval=$?
 	_dbc_psql_cmd_cleanup
 	return $retval
 }
 
+_dbc_createuser_majorversion(){
+	createuser --version | sed -e 's,.* ,,g' | sed -e 's,\..*,,g'
+}
+
 _dbc_createuser(){
 	local extra dbc_dbname retval PGSSLMODE localuser _dbc_asuser
 	localuser=`_dbc_psql_local_username`
@@ -128,10 +136,13 @@
 	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
 	if [ "$dbc_authmethod_user" != "ident" ]; then 
 		dbc_dbname="template1"
-		extra="$extra" _dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"
+		_dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"
 		retval=$?
 	else
-		dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' createuser -A -D -q $extra $dbc_dbuser" 2>&1` || retval=$?
+		# postgres 8 and later also defines roles, which we disable in
+		# the users that we create.
+		if [ `_dbc_createuser_majorversion` -ge 8 ]; then extra="$extra -R"; fi
+		dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' PGSSLMODE='$PGSSLMODE' createuser -A -D -q $extra $dbc_dbuser" 2>&1` || retval=$?
 	fi
 	_dbc_psql_cmd_cleanup
 	return $retval
@@ -147,7 +158,7 @@
 	if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
 	if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
 	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
-	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' dropuser -q $extra $*" 2>&1` || retval=$?
+	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' PGSSLMODE='$PGSSLMODE' dropuser -q $extra $*" 2>&1` || retval=$?
 	_dbc_psql_cmd_cleanup
 	return $retval
 }
@@ -162,7 +173,7 @@
 	if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
 	if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
 	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
-	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGSSLMODE='$PGSSLMODE' pg_dump $extra $*" 2>&1` || retval=$?
+	dbc_error=`su -s /bin/sh $localuser -c "env HOME='$_dbc_pgsql_tmpdir' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' PGSSLMODE='$PGSSLMODE' pg_dump $extra $*" 2>&1` || retval=$?
 	_dbc_psql_cmd_cleanup
 	return $retval
 }
@@ -172,7 +183,7 @@
 ##
 _dbc_pgsql_check_connect(){
 	local constat extra _dbc_asuser
-	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
+	if [ "$dbc_dbadmin" ]; then extra="-U '$dbc_dbadmin'"; fi
 	constat="bad"
 	if ! _dbc_psql $extra template1 < /dev/null; then
 		dbc_logline "unable to connect to postgresql server"
@@ -222,9 +233,9 @@
 ## check for the existance of a specified database
 ##
 _dbc_pgsql_check_database(){
-	local dbc_dbname _dbc_asuser
+	local dbc_dbname _dbc_asuser extra
 	dbc_dbname=$1
-	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
+	if [ "$dbc_dbadmin" ]; then extra="-U '$dbc_dbadmin'"; fi
 	_dbc_psql $extra $dbc_dbname </dev/null 2>/dev/null
 	return $?
 }
@@ -236,10 +247,10 @@
 ##	not only does the user exist, but that it should be able to connect
 ##
 dbc_pgsql_check_user(){
-	local dbc_dbname l_retval _dbc_asuser
+	local dbc_dbname l_retval _dbc_asuser extra
 	dbc_dbname="template1"
-	if [ "$dbc_dbadmin" ]; then extra="$extra -U '$dbc_dbadmin'"; fi
-	extra="$extra" _dbc_pgsql_exec_command "ALTER USER \"$dbc_dbuser\""
+	if [ "$dbc_dbadmin" ]; then extra="-U '$dbc_dbadmin'"; fi
+	_dbc_pgsql_exec_command "ALTER USER \"$dbc_dbuser\""
 	l_retval=$?
 	return $l_retval
 }
@@ -284,6 +295,7 @@
 			fi
 		else
 			dbc_logline "failed"
+			return 1
 		fi
 	fi
 
@@ -350,7 +362,7 @@
 		if [ ! "$dbc_dbserver" -o "$dbc_dbserver" = "localhost" ]; then
 			l_dballow=localhost
 		else
-			l_dballow=`hostname`
+			l_dballow=`hostname -f`
 		fi
 	else
 		l_dballow="$dbc_dballow" 
@@ -409,7 +421,7 @@
 		if [ ! "$dbc_dbserver" -o "$dbc_dbserver" = "localhost" ]; then
 			l_dballow=localhost
 		else
-			l_dballow=`hostname`
+			l_dballow=`hostname -f`
 		fi
 	else
 		l_dballow="$dbc_dballow"




More information about the Dbconfig-common-changes mailing list