[Dbconfig-common-devel] dbconfig-common/internal common,1.1,1.2 pgsql,1.1,1.2
seanius@haydn.debian.org
seanius@haydn.debian.org
- Previous message: [Dbconfig-common-devel] dbconfig-common/debian/po de.po,1.2,1.3 templates.pot,1.4,1.5
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/dbconfig-common/dbconfig-common/internal
In directory haydn:/org/alioth.debian.org/chroot/home/users/seanius/tmp/cvs-serv31239/internal
Modified Files:
common pgsql
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/internal/common,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- common 25 Jan 2005 14:48:20 -0000 1.1
+++ common 4 Feb 2005 06:26:07 -0000 1.2
@@ -39,6 +39,38 @@
_dbc_sanity_check(){
while [ "$1" ]; do
case "$1" in
+ "package")
+ if [ -z "$dbc_package" ]; then
+ dbc_error="dbconfig-common can not determine the
+ name of the package it is configuring."
+ dbc_logline "sanity check failed for dbc_package"
+ return 1
+ fi
+ ;;
+ "packageconfig")
+ if [ -z "$dbc_packageconfig" ]; then
+ dbc_error="dbconfig-common can not determine the
+ name of the package configuration file."
+ dbc_logline "sanity check failed for dbc_packageconfig"
+ return 1
+ fi
+ ;;
+ "dbtype")
+ if [ -z "$dbc_dbtype" ]; then
+ dbc_error="dbconfig-common can not determine the
+ database type."
+ dbc_logline "sanity check failed for dbc_dbtype"
+ return 1
+ fi
+ ;;
+ "command")
+ if [ -z "$dbc_command" ]; then
+ dbc_error="dbconfig-common can not determine the
+ maintainer script running it."
+ dbc_logline "sanity check failed for dbc_command"
+ return 1
+ fi
+ ;;
"dbname")
if [ -z "$dbc_dbname" ]; then
dbc_error="No database name specified. Have
@@ -126,6 +158,7 @@
fi
;;
*)
+ dbc_error="don't know how to sanity check for $1"
dbc_logline "don't know how to sanity check for $1"
return 1
;;
Index: pgsql
===================================================================
RCS file: /cvsroot/dbconfig-common/dbconfig-common/internal/pgsql,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pgsql 25 Jan 2005 14:48:20 -0000 1.1
+++ pgsql 4 Feb 2005 06:26:07 -0000 1.2
@@ -8,46 +8,95 @@
# get some common functions
. /usr/share/dbconfig-common/internal/common
+_dbc_psql_cmd_setup(){
+ _dbc_pgsql_tmpdir=`mktemp -dt dbconfig-common.psql_home.XXXXXX`
+ if [ $? -ne 0 ]; then return 1; fi
+ if [ "$dbc_authmethod_admin" = "password" ]; then
+ cat << EOF > ${_dbc_pgsql_tmpdir}/.pgpass
+*:*:*:$dbc_dbadmin:$dbc_dbadmpass
+EOF
+ chown postgres $_dbc_pgsql_tmpdir
+ chown postgres ${_dbc_pgsql_tmpdir}/.pgpass
+ chmod 600 ${_dbc_pgsql_tmpdir}/.pgpass
+ fi
+}
+
+_dbc_psql_cmd_cleanup(){
+ if [ "$_dbc_pgsql_tmpdir" -a -d "$_dbc_pgsql_tmpdir" ]; then
+ rm -f ${_dbc_pgsql_tmpdir}/.pgpass
+ rmdir $_dbc_pgsql_tmpdir
+ fi
+}
+
_dbc_psql(){
- local extra
+ local extra retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "psql -q $extra $*"
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' psql -q $extra $*"
+ retval=$?
+ _dbc_psql_cmd_cleanup
+ return $retval
}
_dbc_createdb(){
- local extra
+ local extra retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "createdb -q -O $dbc_dbuser $extra $*"
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' createdb -q -O $dbc_dbuser $extra $*"
+ retval=$?
+ _dbc_psql_cmd_cleanup
+ return $retval
}
_dbc_dropdb(){
- local extra
+ local extra retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "dropdb -q $extra $*"
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' dropdb -q $extra $*"
+ retval=$?
+ _dbc_psql_cmd_cleanup
+ return $retval
}
_dbc_createuser(){
- local extra
+ local extra dbc_dbname retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "createuser -A -D -q $extra $*"
+ if [ "$dbc_authmethod_user" != "ident" ]; then
+ dbc_dbname="template1" _dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"
+ retval=$?
+ else
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' createuser -A -D -q $extra $dbc_dbuser"
+ retval=$?
+ fi
+ _dbc_psql_cmd_cleanup
+ return $retval
}
_dbc_dropuser(){
- local extra
+ local extra retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "dropuser -q $extra $*"
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' dropuser -q $extra $*"
+ retval=$?
+ _dbc_psql_cmd_cleanup
+ return $retval
}
_dbc_pg_dump(){
- local extra
+ local extra retval
+ _dbc_psql_cmd_setup
if [ "$dbc_dbserver" ]; then extra="$extra -h '$dbc_dbserver'"; fi
if [ "$dbc_dbport" ]; then extra="$extra -p '$dbc_dbport'"; fi
- su - postgres -c "pg_dump $extra $*"
+ su - postgres -c "env HOME='$_dbc_pgsql_tmpdir' pg_dump $extra $*"
+ retval=$?
+ _dbc_psql_cmd_cleanup
+ return $retval
}
##
@@ -92,14 +141,16 @@
## including the sql command itself
##
_dbc_pgsql_exec_command(){
- local statement l_sqlfile
+ local statement l_sqlfile retval
statement=$@
l_sqlfile=`mktemp -t dbconfig-common_sqlfile.XXXXXX`
cat << EOF > $l_sqlfile
$statement
EOF
_dbc_psql $dbc_dbname < $l_sqlfile
+ retval=$?
rm -f $l_sqlfile
+ return $retval
}
##
@@ -120,7 +171,7 @@
##
_dbc_pgsql_check_user(){
local extra dbc_dbname
- dbc_dbname=template1 extra="-A" _dbc_pgsql_exec_command "select usename from pg_shadow where usename='$dbc_dbuser'" | grep -q "^$dbc_dbuser\$"
+ dbc_dbname=template1 extra="-A" _dbc_pgsql_exec_command "select usename from pg_user where usename='$dbc_dbuser'" | grep -q "^$dbc_dbuser\$"
return $?
}
@@ -169,6 +220,7 @@
dbc_logline "failed"
fi
fi
+
}
# File: pgsql-dropdb.sh
@@ -223,12 +275,13 @@
# $dbc_error = error message (if $dbc_status = error)
dbc_pgsql_createuser(){
- local l_dballow
+ local l_dballow dbc_dbname
+ dbc_dbname=template1
dbc_status=error
dbc_error=""
- _dbc_sanity_check dbuser dbname dbadmin createuser || return 1
+ _dbc_sanity_check dbuser dbadmin createuser || return 1
_dbc_pgsql_check_connect || return 1
if [ ! "$dbc_dballow" ]; then
@@ -246,12 +299,23 @@
if _dbc_pgsql_check_user; then
dbc_status=nothing
dbc_logline "already exists"
- elif _dbc_createuser $dbc_dbuser; then
+ if [ "$dbc_dbpass" ]; then
+ dbc_logpart "resetting password: "
+ if _dbc_pgsql_exec_command "ALTER USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"; then
+ dbc_logline "success"
+ else
+ dbc_error="unable to reset pass for $dbc_dbuser"
+ dbc_logline "failed"
+ return 1
+ fi
+ fi
+ elif _dbc_createuser; then
dbc_logline "success"
dbc_logpart "verifying creation of user:"
if ! _dbc_pgsql_check_user ; then
- dbc_error="unable to grant privileges to user $dbc_dbuser."
+ dbc_error="unable to create user $dbc_dbuser."
dbc_logline "failed"
+ return 1
else
dbc_status=create
dbc_logline "success"
@@ -259,6 +323,7 @@
else
dbc_error="unable to grant privileges to $dbc_dbuser, createuser error $?"
dbc_logline "failed"
+ return 1
fi
}
- Previous message: [Dbconfig-common-devel] dbconfig-common/debian/po de.po,1.2,1.3 templates.pot,1.4,1.5
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]