[Dbconfig-common-changes] [dbconfig-common] r246 - in trunk: .
debian dpkg examples/db-test-pgsql-2.0/debian internal
Sean Finney
seanius at costa.debian.org
Fri Jun 9 00:31:38 CEST 2006
Author: seanius
Date: 2006-06-08 22:31:33 +0000 (Thu, 08 Jun 2006)
New Revision: 246
Modified:
trunk/TODO
trunk/debian/changelog
trunk/debian/dbconfig-common.templates
trunk/dpkg/common
trunk/dpkg/config
trunk/dpkg/postinst
trunk/dpkg/prerm
trunk/examples/db-test-pgsql-2.0/debian/config
trunk/internal/mysql
trunk/internal/pgsql
Log:
1.8.16 ready to go
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/TODO 2006-06-08 22:31:33 UTC (rev 246)
@@ -2,15 +2,12 @@
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.
+- the code is "in the process of" getting a cleanup. there are still a
+ few globally scoped variables that ought to be removed and/or replaced
+ by local scoped variables.
+- testing various corner cases:
+ - errors dumping during upgrade
+ - errors dumping during purge
further ahead:
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/debian/changelog 2006-06-08 22:31:33 UTC (rev 246)
@@ -1,8 +1,19 @@
-dbconfig-common (1.8.16) UNRELEASED; urgency=low
+dbconfig-common (1.8.16) unstable; urgency=low
- * NOT RELEASED YET
+ * when determining the local user as which to interact with postgres,
+ additionally check that the account exists before attempting to
+ su/chown stuff to it. this should make postgres work "out of the box"
+ for both applications that use a system account and those that don't.
+ thanks to stephen gran for the suggestion. closes: #368854
+ * updated the pgsql password prommpt question to mention this.
+ * when reconfiguring a package, change the "install with dbconfig-common?"
+ question to "reinstall with dbconfig-common?", and default to false.
+ this should make dbconfig-common packages' maintainer scripts idempotent,
+ which could otherwise be considered a policy bug.
+ * bugfix in sql dumping logic (upgrades and purges) for both mysql
+ and pgsql.
- -- sean finney <sean at localhost.localdomain> Sun, 4 Jun 2006 19:16:05 +0200
+ -- sean finney <seanius at debian.org> Fri, 09 Jun 2006 02:31:09 +0200
dbconfig-common (1.8.15) unstable; urgency=low
Modified: trunk/debian/dbconfig-common.templates
===================================================================
--- trunk/debian/dbconfig-common.templates 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/debian/dbconfig-common.templates 2006-06-08 22:31:33 UTC (rev 246)
@@ -31,6 +31,17 @@
.
Otherwise, you should probably choose this option.
+Template: dbconfig-common/dbconfig-reinstall
+Type: boolean
+Default: false
+_Description: Re-install database for ${pkg}?
+ Since you are reconfiguring ${pkg}, you may also want to reinstall the
+ database which it uses.
+ .
+ If you wish to re-install the database for ${pkg}, you should select
+ this option. If you do not wish to do so (if you are reconfiguring
+ the package for unrelated reasons), you should not select this option.
+
Template: dbconfig-common/dbconfig-upgrade
Type: boolean
Default: true
@@ -255,8 +266,10 @@
_Description: PostgreSQL application password for ${pkg}:
Please provide a password for ${pkg} to register with the database
server. If left blank, a random password will be generated for you.
- PostgreSQL access may need to be reconfigured to allow
- password-authenticated access.
+ .
+ If you are using "ident" based authentication, the supplied password will
+ not be used and can be left blank. Otherwise, PostgreSQL access may
+ need to be reconfigured to allow password-authenticated access.
Template: dbconfig-common/pgsql/admin-user
Type: string
Modified: trunk/dpkg/common
===================================================================
--- trunk/dpkg/common 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/dpkg/common 2006-06-08 22:31:33 UTC (rev 246)
@@ -31,7 +31,7 @@
### some internal variables
###
# templates common to all database types
- dbc_standard_templates="database-type dbconfig-install dbconfig-upgrade dbconfig-remove password-confirm app-password-confirm purge upgrade-backup passwords-do-not-match install-error upgrade-error remove-error import-oldsettings internal/reconfiguring"
+ dbc_standard_templates="database-type dbconfig-install dbconfig-upgrade dbconfig-remove dbconfig-reinstall password-confirm app-password-confirm purge upgrade-backup passwords-do-not-match install-error upgrade-error remove-error import-oldsettings internal/reconfiguring"
# templates common to mysql database types
dbc_mysql_templates="mysql/method remote/host remote/newhost mysql/app-pass mysql/admin-user mysql/admin-pass remote/port db/dbname db/app-user"
Modified: trunk/dpkg/config
===================================================================
--- trunk/dpkg/config 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/dpkg/config 2006-06-08 22:31:33 UTC (rev 246)
@@ -3,7 +3,7 @@
###
dbc_go(){
- local db happy default_dbtype host newhost port oldhosts authmethod_user authmethod_admin do_config need_adminpw need_userpw f _preconf_list _s _t STATEiformat ifile
+ local f db happy default_dbtype host newhost port oldhosts authmethod_admin do_config _preconf_list _s _t STATEiformat ifile install_question
. /usr/share/dbconfig-common/dpkg/common
dbc_debug "(config) dbc_go() $@"
@@ -26,19 +26,30 @@
dbc_read_package_config
dbc_preseed_package_debconf
+ # the first question we ask will differ depending on how we're invoked
+ if [ "$dbc_command" = "configure" ]; then
+ install_question="$dbc_package/dbconfig-install"
+ else
+ install_question="$dbc_package/dbconfig-reinstall"
+ # if we are reconfiguring (via dpkg-reconfigure), also leave a hint
+ # for our future postinst selves so we know we *should* run the code
+ # that would otherwise think we were upgrading
+ db_set $dbc_package/internal/reconfiguring true
+ fi
+
# and start our beautiful state-machine
STATE=1
while true; do
case "$STATE" in
# state 1 - ask if they want our help at all
1)
- db_input high $dbc_package/dbconfig-install || true
+ db_input high $install_question || true
;;
# state 2 - check to see if they do.
# - see if this is an upgrade newly supporting dbc
# - multidb support step 1
2)
- db_get $dbc_package/dbconfig-install
+ db_get $install_question
if [ "$RET" != "true" ]; then
return 0;
fi
@@ -251,8 +262,11 @@
# state 8 - pgsql auth stuff, part 2
8)
if [ "$dbc_dbtype" = "pgsql" ]; then
- db_get $dbc_package/pgsql/authmethod-admin
- authmethod_admin="$RET"
+ db_get $dbc_package/pgsql/authmethod-admin && authmethod_admin="$RET"
+ # if we are using ident, we don't need passwords
+ if [ "$authmethod_admin" = "ident" ]; then
+ need_adminpw="false"
+ fi
# default the user auth method to the admin method
# ...but only if the answer hasn't already been specified.
if [ ! "${dbc_authmethod_user}" ]; then
@@ -261,22 +275,8 @@
db_input medium $dbc_package/pgsql/authmethod-user || true
fi
;;
- # state 9 - pgsql auth part 3, admin/app user, dbname
+ # state 9 - admin/app user/pass, dbname
9)
- if [ "$dbc_dbtype" = "pgsql" ]; then
- db_get $dbc_package/pgsql/authmethod-user
- authmethod_user="$RET"
-
- # if we are using ident, we don't need passwords
- if [ "$authmethod_admin" = "ident" ]; then
- need_adminpw="false"
- fi
-
- if [ "$authmethod_user" = "ident" ]; then
- need_userpw="false"
- fi
- fi
-
# who's the admin user (is there any reason to even ask this?)
# TODO: should there be a difference between the local and remote admin?
db_input low $dbc_package/$dbc_dbtype/admin-user || true
@@ -284,13 +284,9 @@
if [ "$need_adminpw" != "false" ]; then
dbc_get_admin_pass
fi
-
db_input low $dbc_package/db/app-user || true
+ dbc_get_app_pass
- if [ "$need_userpw" != "false" ]; then
- dbc_get_app_pass
- fi
-
# get the name of the database to use
db_input low $dbc_package/db/dbname || true
;;
@@ -309,11 +305,4 @@
exit 10
fi
done
-
- # finally, if we are reconfiguring (via dpkg-reconfigure), leave a hint
- # for our future postinst selves so we know we *should* run the code
- # that would otherwise think we were upgrading
- if [ "$dbc_command" = "reconfigure" ]; then
- db_set $dbc_package/internal/reconfiguring true
- fi
}
Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/dpkg/postinst 2006-06-08 22:31:33 UTC (rev 246)
@@ -2,7 +2,7 @@
### load up common variables and functions
###
dbc_go(){
- local prev_dbc_upgrade importing_from_non_dbc upgrading reconfiguring f tsubstfile upgrades_pending dumpfile _dbc_asuser
+ local prev_dbc_upgrade importing_from_non_dbc upgrading reconfiguring f tsubstfile upgrades_pending dumpfile _dbc_asuser reinstall
. /usr/share/dbconfig-common/dpkg/common
dbc_debug "(postinst) dbc_go() $@"
@@ -37,12 +37,17 @@
if [ "$dbc_oldversion" ]; then
# read that little crumb left in config if we're reconfiguring
db_get $dbc_package/internal/reconfiguring && reconfiguring="$RET"
+ # and set it back to false
+ db_reset $dbc_package/internal/reconfiguring
# if not, we're definitely upgrading
if [ "$reconfiguring" = "false" ]; then
upgrading="yes"
+ else
+ db_get $dbc_package/dbconfig-reinstall && reinstall=$RET
+ db_reset $dbc_package/dbconfig-reinstall
+ # if they've said they don't want to reinstall stuff...
+ if [ "$reinstall" = "false" ]; then return 0; fi
fi
- # and set it back to false
- db_reset $dbc_package/internal/reconfiguring
fi
# now, determine if we're upgrading from a non-dbc version. if so,
@@ -153,7 +158,7 @@
dbc_logline "creating database backup in $dumpfile"
# backup before we upgrade
_dbc_asuser=""
- $dbc_dump_cmd > $dumpfile
+ $dbc_dump_cmd $dumpfile
fi
# now perform the updates
Modified: trunk/dpkg/prerm
===================================================================
--- trunk/dpkg/prerm 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/dpkg/prerm 2006-06-08 22:31:33 UTC (rev 246)
@@ -62,7 +62,7 @@
dbc_remove_error "creating temporary file for database dump"
fi
dbc_logline "dbconfig-common: dumping $dbc_dbtype database $dbc_dbname to $dumpfile"
- $dbc_dump_cmd > $dumpfile || dbc_remove_error "dumping database"
+ $dbc_dump_cmd $dumpfile || dbc_remove_error "dumping database"
dbc_logline "dbconfig-common: dropping $dbc_dbtype database $dbc_dbname"
$dbc_dropdb_cmd || dbc_remove_error "dropping database"
[ "$dbc_tried_again" ] && return 0
Modified: trunk/examples/db-test-pgsql-2.0/debian/config
===================================================================
--- trunk/examples/db-test-pgsql-2.0/debian/config 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/examples/db-test-pgsql-2.0/debian/config 2006-06-08 22:31:33 UTC (rev 246)
@@ -6,5 +6,5 @@
. /usr/share/debconf/confmodule
. /usr/share/dbconfig-common/dpkg/config.pgsql
-dbc_authmethod_user="password"
+#dbc_authmethod_user="password"
dbc_go db-test-pgsql $@
Modified: trunk/internal/mysql
===================================================================
--- trunk/internal/mysql 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/internal/mysql 2006-06-08 22:31:33 UTC (rev 246)
@@ -345,12 +345,13 @@
## perform mysqldump
##
dbc_mysql_dump(){
- local mycnf dumperr db
+ local mycnf dumperr db dumpfile
_dbc_sanity_check dbname dbadmin mysql || return 1
_dbc_mysql_check_connect || return 1
+ dumpfile=$1
dumperr=0
mycnf=`_dbc_generate_mycnf`
- dbc_error=`mysqldump --defaults-file="$mycnf" $dbc_dbname` || dumperr=1
+ dbc_error=`mysqldump --defaults-file="$mycnf" $dbc_dbname 2>&1 >$dumpfile` || dumperr=1
rm -f $mycnf
return $dumperr
}
Modified: trunk/internal/pgsql
===================================================================
--- trunk/internal/pgsql 2006-06-08 22:28:45 UTC (rev 245)
+++ trunk/internal/pgsql 2006-06-08 22:31:33 UTC (rev 246)
@@ -10,20 +10,24 @@
_dbc_psql_local_username(){
# determine proper local system user as whom to run commands.
- # - if _dbc_asuser set and ident/localhost, $dbc_dbuser
+ # - if _dbc_asuser set and ident/localhost,
+ # - if $dbc_dbuser exists as a system account, use it
# - else ident/localhost: $dbc_dbadmin
# - all others: no change (root)
if [ "$_dbc_asuser" ]; then
if [ "$dbc_authmethod_user" = "ident" -a ! "$dbc_dbserver" ]; then
- echo $dbc_dbuser
- else
- echo root
+ if id $dbc_dbuser >/dev/null 2>&1; then
+ echo $dbc_dbuser
+ return 0
+ else
+ dbc_logline "warning: ident method specified but local account doesn't exist"
+ fi
fi
elif [ "$dbc_authmethod_admin" = "ident" -a ! "$dbc_dbserver" ]; then
echo $dbc_dbadmin
- else
- echo root
+ return 0
fi
+ echo root
}
_dbc_psql_remote_username(){
@@ -50,13 +54,11 @@
method="$dbc_authmethod_user"
remotepass="$dbc_dbpass"
fi
- if [ "$method" = "password" ]; then
- touch "${_dbc_pgsql_tmpdir}/.pgpass"
- chmod 600 ${_dbc_pgsql_tmpdir}/.pgpass
- cat << EOF > ${_dbc_pgsql_tmpdir}/.pgpass
+ touch "${_dbc_pgsql_tmpdir}/.pgpass"
+ chmod 600 ${_dbc_pgsql_tmpdir}/.pgpass
+ cat << EOF > ${_dbc_pgsql_tmpdir}/.pgpass
*:*:*:$remoteuser:$remotepass
EOF
- fi
if [ "$localuser" -a "$localuser" != "root" ]; then
chown -R "$localuser" $_dbc_pgsql_tmpdir
fi
@@ -134,16 +136,8 @@
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_authmethod_user" != "ident" ]; then
- dbc_dbname="template1"
- _dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"
- retval=$?
- else
- # 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_dbname="template1"
+ _dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'" || retval=$?
_dbc_psql_cmd_cleanup
return $retval
}
@@ -164,8 +158,11 @@
}
_dbc_pg_dump(){
- local extra retval PGSSLMODE localuser _dbc_asuser
+ local extra retval PGSSLMODE localuser _dbc_asuser dumpfile
+ dumpfile=$1
+ extra="-f $dumpfile"
localuser=`_dbc_psql_local_username`
+ chown $localuser $dumpfile
PGSSLMODE="prefer"
retval=0
_dbc_psql_cmd_setup
@@ -173,7 +170,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' PGPASSFILE='$_dbc_pgsql_tmpdir/.pgpass' 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 $dbc_dbname" 2>&1` || retval=$?
_dbc_psql_cmd_cleanup
return $retval
}
@@ -445,7 +442,9 @@
## perform pg_dump
##
dbc_pgsql_dump(){
+ local dumpfile
+ dumpfile=$1
_dbc_sanity_check dbuser dbname dbadmin pg_dump || return 1
_dbc_pgsql_check_connect || return 1
- _dbc_pg_dump $dbc_dbname
+ _dbc_pg_dump $dumpfile
}
More information about the Dbconfig-common-changes
mailing list