[Dbconfig-common-devel] dbconfig-common/dpkg common,1.5,1.6 config,1.4,1.5 postinst,1.3,1.4 preinst,1.2,1.3 prerm,1.3,1.4
seanius@haydn.debian.org
seanius@haydn.debian.org
- Previous message: [Dbconfig-common-devel] dbconfig-common/internal common,1.1,1.2 pgsql,1.1,1.2
- Next message: [Dbconfig-common-devel] dbconfig-common/debian README.pgsql,NONE,1.1 TODO,1.6,1.7 changelog,1.8,1.9 control,1.3,1.4 dbconfig-common.docs,1.1.1.1,1.2 dbconfig-common.postinst,1.3,1.4 dbconfig-common.templates,1.7,1.8 rules,1.5,1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/dbconfig-common/dbconfig-common/dpkg
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv31239/dpkg
Modified Files:
common config postinst preinst prerm
Log Message:
another load of work done.
the pgsql support now includes support for both ident (local, remote)
and password (password, crypt, md5, some pam) based authentication.
there's still a couple lurking bugs which i'll be fixing in 1.3:
- dpkg-reconfigure with multi-dbtype applications remembers some values
that perhaps it shouldn't.
- the pgsql support always asks the admin about modifying the configuration,
even if it doesn't need to.
- the pgsql support doesn't have a way of modifying the config
what i'm working on next:
- the above
- hitting at what's left in TODO (esp. verifying updates and script support)
- ssl support to pgsql
- dbconfig-generate-include
if anyone is interested, i can upload the current version to experimental.
just let me know!
sean
Index: common
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/common,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- common 25 Jan 2005 14:48:20 -0000 1.5
+++ common 4 Feb 2005 06:26:07 -0000 1.6
@@ -6,6 +6,9 @@
#set -x
+# get some internal helper functions, like _dbc_sanity_check
+. /usr/share/dbconfig-common/internal/common
+
dbc_config(){
###
### some global variables
@@ -14,16 +17,16 @@
dbc_package="$1"
dbc_command="$2"
dbc_oldversion="$3"
+
+ if ! _dbc_sanity_check package command; then
+ dbc_install_error "determining package or command";
+ fi
+
dbc_confdir="/etc/dbconfig-common"
dbc_globalconfig="$dbc_confdir/config"
dbc_packageconfig="$dbc_confdir/$dbc_package.conf"
###
- ### get some internal functions
- ###
- . /usr/share/dbconfig-common/internal/common
-
- ###
### some internal variables
###
# templates common to all database types
@@ -33,7 +36,7 @@
dbc_mysql_templates="mysql/dbname mysql/method mysql/host mysql/newhost mysql/app-user mysql/app-pass mysql/app-pass2 mysql/admin-user mysql/admin-pass mysql/admin-pass2 mysql/port"
# templates common to postgresql database types
- dbc_pgsql_templates="pgsql/dbname pgsql/method pgsql/host pgsql/newhost pgsql/app-user pgsql/app-pass pgsql/app-pass2 pgsql/admin-user pgsql/admin-pass pgsql/admin-pass2 pgsql/port"
+ dbc_pgsql_templates="pgsql/dbname pgsql/method pgsql/host pgsql/newhost pgsql/app-user pgsql/app-pass pgsql/app-pass2 pgsql/admin-user pgsql/admin-pass pgsql/admin-pass2 pgsql/port pgsql/authmethod-admin pgsql/authmethod-user pgsql/changeconf pgsql/manualconf"
# all dbtypes supported by dbconfig-common
dbc_all_supported_dbtypes="mysql pgsql"
@@ -44,9 +47,8 @@
if [ -f $dbc_globalconfig ]; then
. $dbc_globalconfig
fi
- if [ -f $dbc_packageconfig ]; then
- . $dbc_packageconfig
- fi
+ # and the package config
+ dbc_read_package_config
###
### dbtype-specific variable section
@@ -120,10 +122,71 @@
EOF
}
+dbc_read_package_config(){
+ _dbc_sanity_check package packageconfig || dbc_install_error
+ if [ -f $dbc_packageconfig ]; then
+ . $dbc_packageconfig
+ fi
+}
+
+###
+### this function is responsible for reading in everything
+### with respect to the package's configuration and dbconfig-common.
+###
+dbc_read_package_debconf(){
+ _dbc_sanity_check package || dbc_install_error
+
+ # gracefully fetch this to support multi-dbtype packages
+ db_get $dbc_package/database-type && dbc_prompted_dbtype="$RET"
+ # dbconfig needs to be reloaded at this point for multi-dbtype apps
+ dbc_config $@
+
+ # just to make sure...
+ _dbc_sanity_check dbtype || dbc_install_error
+
+ # get app user
+ db_get $dbc_package/$dbc_dbtype/app-user && dbc_dbuser="$RET"
+
+ # get the db server
+ db_get $dbc_package/$dbc_dbtype/host && dbc_dbserver="$RET"
+
+ # get the name of the database to be created
+ db_get $dbc_package/$dbc_dbtype/dbname && dbc_dbname="$RET"
+
+ # get the database administrator name
+ db_get $dbc_package/$dbc_dbtype/admin-user && dbc_dbadmin="$RET"
+
+ # a few db-specific things
+ case $dbc_dbtype in
+ "mysql")
+ # get the database administrator pass
+ db_get $dbc_package/$dbc_dbtype/admin-pass && dbc_dbadmpass="$RET"
+ # get the app user password
+ db_get $dbc_package/$dbc_dbtype/app-pass && dbc_dbpass="$RET"
+ ;;
+ "pgsql")
+ # get the psql authentication method
+ db_get $dbc_package/pgsql/authmethod-admin && dbc_authmethod_admin="$RET"
+ db_get $dbc_package/pgsql/authmethod-user && dbc_authmethod_user="$RET"
+
+ # ident based auth doesn't need a password
+ if [ "$dbc_authmethod_admin" != "ident" ]; then
+ # get the database administrator pass
+ db_get $dbc_package/pgsql/admin-pass && dbc_dbadmpass="$RET"
+ fi
+ if [ "$dbc_authmethod_user" != "ident" ]; then
+ # get the database user pass
+ db_get $dbc_package/pgsql/app-pass && dbc_dbpass="$RET"
+ fi
+ ;;
+ esac
+}
+
###
### dump package configuration to a config file
###
dbc_write_package_config(){
+ _dbc_sanity_check packageconfig || dbc_install_error
echo "dbconfig-common: writing config to $dbc_packageconfig" >&2
# a quick check if this is a multi-dbtype app
@@ -180,7 +243,24 @@
# this is the name of your application's database.
dbc_dbname="$dbc_dbname"
+##
+## postgresql specific settings. if you don't use postgresql,
+## you can safely ignore all of these
+##
+
+# dbc_authmethod_admin: authentication method for admin
+# dbc_authmethod_user: authentication method for dbuser
+# see the section titled "AUTHENTICATION METHODS" in
+# /usr/share/doc/dbconfig-common/README.pgsql for more info
+dbc_authmethod_admin="$dbc_authmethod_admin"
+dbc_authmethod_user="$dbc_authmethod_user"
+
+##
+## end postgresql specific settings
+##
+
EOF
+ cp $dbc_packageconfig `mktemp -t dbconfig-foo.XXXXXX`
}
##
Index: config
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/config,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- config 25 Jan 2005 14:48:20 -0000 1.4
+++ config 4 Feb 2005 06:26:07 -0000 1.5
@@ -1,14 +1,14 @@
###
-### source common for variables, functions, et c
+### config hook
###
dbc_go(){
+ local db happy default_dbtype host newhost port oldhosts authmethod_user authmethod_admin do_config need_adminpw need_userpw
. /usr/share/dbconfig-common/dpkg/common
dbc_config $@
if [ "$dbc_command" = "configure" -o "$dbc_command" = "reconfigure" ];
then
- local db happy default_dbtype host newhost port oldhosts
##
## register all the dbconfig-common questions
##
@@ -30,8 +30,8 @@
###
# check to see if there's an answer in debconf
db_get $dbc_package/database-type && dbc_prompted_dbtype="$RET"
-
- # if the dbtype is hardcoded (config.mysql, etc), use that
+
+ # if the dbtype is hardcoded (using config.mysql, etc), use that
if [ "$dbc_hardcoded_dbtype" ]; then
dbc_dbtype=$dbc_hardcoded_dbtype
# if the dbtype is already set, don't bother
@@ -40,8 +40,10 @@
# else see if they've already told us what to use, use that
elif [ "$dbc_prompted_dbtype" ]; then
dbc_dbtype=$dbc_prompted_dbtype
- # else if the package supports multiple dbtypes, help them pick one
- elif [ "$dbc_dbtypes" ]; then
+ fi
+
+ # if the package supports multiple dbtypes, help them pick one
+ if [ "$dbc_dbtypes" ]; then
# loop through all available dbtypes
for db in $dbc_all_supported_dbtypes; do
# check to see $db is supported
@@ -71,9 +73,11 @@
dbc_prompted_dbtype="$RET"
# now that we have a dbtype, reload common to set other defaults
- . /usr/share/dbconfig-common/dpkg/common
dbc_config $@
fi
+ ###
+ ### end multi-db support section
+ ###
# there's a bit more to do with client/server rdbms
if [ "$dbc_dbtype" = "mysql" -o "$dbc_dbtype" = "pgsql" ]; then
@@ -95,13 +99,13 @@
fi
if [ "$dbc_remove" ]; then
db_set $dbc_package/dbconfig-remove "$dbc_remove"
- fi
- if [ "$dbc_dbuser" ]; then
+ fi
+ if [ "$dbc_dbuser" ]; then
db_set $dbc_package/$dbc_dbtype/app-user "$dbc_dbuser"
- fi
- if [ "$dbc_dbname" ]; then
+ fi
+ if [ "$dbc_dbname" ]; then
db_set $dbc_package/$dbc_dbtype/dbname "$dbc_dbname"
- fi
+ fi
if [ "$dbc_dbserver" ]; then
db_set $dbc_package/$dbc_dbtype/host "$dbc_dbserver"
fi
@@ -117,11 +121,8 @@
db_go || true
db_get $dbc_package/$dbc_dbtype/method
- if [ "$RET" = "unix socket" ]; then
- # TODO: check for non-existant database server
- true
- # else if package/method == tcp/ip or tcp/ip + ssl
- else
+ # if package/method == tcp/ip
+ if [ "$RET" != "unix socket" ]; then
# if no hosts have ever been selected,
# this would be set to '${hosts}' (literally)
db_metaget $dbc_package/$dbc_dbtype/host hosts
@@ -157,15 +158,66 @@
fi
fi
+ # postgresql provides multiple auth types
+ if [ "$dbc_dbtype" = "pgsql" ]; then
+ # get the admin auth method
+ db_input low $dbc_package/$dbc_dbtype/authmethod-admin || true
+
+ # default the user auth method to the admin method
+ db_go || true
+ db_get $dbc_package/$dbc_dbtype/authmethod-admin
+ authmethod_admin="$RET"
+
+ db_set $dbc_package/$dbc_dbtype/authmethod-user "$authmethod_admin"
+ db_input low $dbc_package/$dbc_dbtype/authmethod-user || true
+ db_go || true
+ db_get $dbc_package/$dbc_dbtype/authmethod-admin
+ authmethod_user="$RET"
+
+ # if we're connecting to localhost and the method is
+ # not ident, we need to change config.
+ if [ ! "$dbc_dbserver" -o "$dbc_dbserver" = "localhost" ] && [ "$authmethod_user" != "ident" -o "$authmethod_admin" != "ident" ]; then
+ db_input high $dbc_package/$dbc_dbtype/changeconf || true
+
+ # if they don't want us to muck with their
+ # config give them a pointer.
+ db_go || true
+ db_get $dbc_package/$dbc_dbtype/changeconf
+ do_config="$RET"
+
+ if [ "$do_config" != "true" ]; then
+ db_input high $dbc_package/$dbc_dbtype/manualconf || true
+ fi
+ fi
+
+ # 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
+
# get the name of the database to use
db_input low $dbc_package/$dbc_dbtype/dbname || true
# 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
+ dbc_dbadmin="$RET"
- dbc_dbadmpass=`dbc_get_admin_pass $dbc_package $dbc_dbtype`
- dbc_dbpass=`dbc_get_app_pass $dbc_package $dbc_dbtype`
+ db_input low $dbc_package/$dbc_dbtype/app-user || true
+ dbc_dbuser="$RET"
+
+ if [ "$need_adminpw" != "false" ]; then
+ dbc_dbadmpass=`dbc_get_admin_pass $dbc_package $dbc_dbtype`
+ fi
+
+ if [ "$need_userpw" != "false" ]; then
+ dbc_dbpass=`dbc_get_app_pass $dbc_package $dbc_dbtype`
+ fi
db_go || true
fi
Index: postinst
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/postinst,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- postinst 25 Jan 2005 14:48:20 -0000 1.3
+++ postinst 4 Feb 2005 06:26:07 -0000 1.4
@@ -4,6 +4,9 @@
dbc_go(){
. /usr/share/dbconfig-common/dpkg/common
dbc_config $@
+ # read in debconf responses (which are seeded from the config)
+ dbc_read_package_debconf $@
+ dbc_write_package_config
###
### begin main code execution
@@ -19,28 +22,8 @@
# we need to remember this, so synchronize this to disk before anything
dbc_write_package_config
- # gracefully fetch this to support multi-dbtype packages
- db_get $dbc_package/database-type && dbc_prompted_dbtype="$RET"
- # reload the common config to set some extra defaults
- dbc_config $@
-
- # get app user
- db_get $dbc_package/$dbc_dbtype/app-user && dbc_dbuser="$RET"
-
- # get the db server
- db_get $dbc_package/$dbc_dbtype/host && dbc_dbserver="$RET"
-
- # get the name of the database to be created
- db_get $dbc_package/$dbc_dbtype/dbname && dbc_dbname="$RET"
-
- # get the app user password
- db_get $dbc_package/$dbc_dbtype/app-pass && dbc_dbpass="$RET"
-
- # get the database administrator name
- db_get $dbc_package/$dbc_dbtype/admin-user && dbc_dbadmin="$RET"
-
- # get the database administrator pass
- db_get $dbc_package/$dbc_dbtype/admin-pass && dbc_dbadmpass="$RET"
+ # read in admin input from debconf
+ dbc_read_package_debconf $@
###
### perform a few sanity checks on the data
@@ -152,18 +135,6 @@
# and if they don't want our help, we'll go away
if [ "$dbc_upgrade" != "true" ]; then exit 0; fi
-
- # get app user
- db_get $dbc_package/$dbc_dbtype/app-user && dbc_dbuser="$RET"
-
- # get the app user password
- db_get $dbc_package/$dbc_dbtype/app-pass && dbc_dbpass="$RET"
-
- # get the db server
- db_get $dbc_package/$dbc_dbtype/host && dbc_dbserver="$RET"
-
- # get the name of the database to be backed up
- db_get $dbc_package/$dbc_dbtype/dbname && dbc_dbname="$RET"
###
### perform a few sanity checks on the data
Index: preinst
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/preinst,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- preinst 25 Jan 2005 14:48:20 -0000 1.2
+++ preinst 4 Feb 2005 06:26:07 -0000 1.3
@@ -1,7 +1,22 @@
###
-### get some common functions / variables
+### what happens in this script:
###
+### the debconf settings aquired in the previous config run
+### are written out to the package configuration file. this
+### way when the config script is re-run before postinst it
+### doesn't overwrite debconf variables that may have changed from
+### the first config run. otherwise the contents of the configuration
+### file will never be changed.
+###
dbc_go(){
. /usr/share/dbconfig-common/dpkg/common
+ set -x
dbc_config $@
+
+ case $dbc_command in
+ "upgrade"|"install")
+ dbc_read_package_debconf $@
+ dbc_write_package_config
+ ;;
+ esac
}
Index: prerm
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/dpkg/prerm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- prerm 25 Jan 2005 14:48:20 -0000 1.3
+++ prerm 4 Feb 2005 06:26:07 -0000 1.4
@@ -2,9 +2,13 @@
### some global variables etc
###
dbc_go(){
+ local need_admin_pw
+
. /usr/share/dbconfig-common/dpkg/common
dbc_config $@
+ need_admin_pw="yup"
+
if [ "$dbc_command" = "remove" ]; then
###
### ask the admin if we should help with removal
@@ -59,12 +63,17 @@
db_get $dbc_package/purge
dbc_purge="$RET"
+ if [ "$dbc_dbtype" = "pgsql" ] && \
+ [ "$dbc_authmethod_admin" = "ident" ];
+ then
+ need_admin_pw=""
+ fi
+
if [ "$dbc_purge" = "true" ]; then
# get the admin user password
- dbc_dbadmpass=`dbc_get_admin_pass "$dbc_package" "$dbc_dbtype"`
-
- # get the app user password
- # dbc_dbpass=`dbc_get_app_pass "$dbc_package" "$dbc_dbtype"`
+ if [ "$need_admin_pw" ]; then
+ dbc_dbadmpass=`dbc_get_admin_pass "$dbc_package" "$dbc_dbtype"`
+ fi
# dump the database into a temporary file
_dbc_now=`date +%Y-%m-%d-%H.%M`
- Previous message: [Dbconfig-common-devel] dbconfig-common/internal common,1.1,1.2 pgsql,1.1,1.2
- Next message: [Dbconfig-common-devel] dbconfig-common/debian README.pgsql,NONE,1.1 TODO,1.6,1.7 changelog,1.8,1.9 control,1.3,1.4 dbconfig-common.docs,1.1.1.1,1.2 dbconfig-common.postinst,1.3,1.4 dbconfig-common.templates,1.7,1.8 rules,1.5,1.6
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]