[Pkg-zenoss-team] Bug#429841: avoid empty substitution for _DBC_DBSERVER_ (patch included)
Stefano Zacchiroli
zack at debian.org
Wed Jun 20 15:18:15 UTC 2007
Package: dbconfig-common
Version: 1.8.34
Severity: normal
Tags: patch
I'm using the templating mechanism for .sql files which is enabled by
dbc_sql_substitutions. According to the code it should support the
substitution of the _DBC_DBSERVER_ variable.
Unfortunately, the $dbc_dbserver variable of dbconfig-common has a
special value of "" (empty string) to mean "use the best method to
connect to the localhost server". Still, it's unlikely that one desire
an empty substitution for _DBC_DBSERVER_ in templates. My argument for
that is that variable would be needed to set access permissions in
statements like
GRANT bla bla bla ON bla TO _DBC_DBUSER_ at _DBC_DBSERVER_
^^^^^^^^^^^^^^
At least in mysql the resulting statement when substituting
_DBC_DBSERVER_ with "" is still valid but generates strange access
permission for "user@" which is definitely what one want.
The same kind of patching which is applied to $dbc_dbserver in other
dbconfig-common scripts (that is replacing it with "localhost" if it is
the empty string) should be applied in dbconfig-generate-include as
well.
The attached patch does precisely that, can you pleas attach it?
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.21-1-686 (SMP w/1 CPU core)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages dbconfig-common depends on:
ii debconf [debconf-2.0] 1.5.13 Debian configuration management sy
ii ucf 3.001 Update Configuration File: preserv
dbconfig-common recommends no packages.
-- debconf information:
* dbconfig-common/remote-questions-default: false
dbconfig-common/pgsql/revertconf: false
dbconfig-common/internal/skip-preseed: false
dbconfig-common/db/dbname:
dbconfig-common/pgsql/manualconf:
dbconfig-common/dbconfig-remove: true
dbconfig-common/mysql/method: unix socket
dbconfig-common/upgrade-backup: true
dbconfig-common/pgsql/authmethod-admin: ident
dbconfig-common/upgrade-error: abort
dbconfig-common/purge: false
dbconfig-common/db/basepath:
dbconfig-common/install-error: abort
dbconfig-common/pgsql/no-empty-passwords:
dbconfig-common/pgsql/admin-user: postgres
dbconfig-common/dbconfig-install: true
dbconfig-common/dbconfig-reinstall: false
dbconfig-common/remote/host:
dbconfig-common/pgsql/changeconf: false
dbconfig-common/remote/newhost:
dbconfig-common/dbconfig-upgrade: true
dbconfig-common/pgsql/no-user-choose-other-method:
dbconfig-common/internal/reconfiguring: false
dbconfig-common/passwords-do-not-match:
dbconfig-common/remove-error: abort
* dbconfig-common/remember-admin-pass: false
dbconfig-common/mysql/admin-user: root
dbconfig-common/pgsql/method: unix socket
dbconfig-common/pgsql/authmethod-user:
dbconfig-common/database-type:
dbconfig-common/db/app-user:
dbconfig-common/remote/port:
-------------- next part --------------
--- /usr/sbin/dbconfig-generate-include 2007-05-20 22:18:43.000000000 +0100
+++ ./dbconfig-generate-include.zack 2007-06-20 16:08:33.000000000 +0100
@@ -381,12 +381,20 @@
echo "unable to create temporary file $sedtmp" >&2
exit 1
fi
+ # we do not want _DBC_DBSERVER_ to be expanded to "" (which means "use
+ # the best available method to connect to the local db): expand it to
+ # "localhost" if needed
+ if [ -z "$dbc_dbserver" ] ; then
+ dbc_dballow="localhost"
+ else
+ dbc_dballow="$dbc_dbserver"
+ fi
cat << EOF > "$sedtmp"
s/^\(.*\)_DBC_DBUSER_/${comment_dbuser}\1`sed_rhs_escape $dbc_dbuser`/g
s/^\(.*\)_DBC_DBPASS_/${comment_dbpass}\1`sed_rhs_escape $dbc_dbpass`/g
s/^\(.*\)_DBC_BASEPATH_/${comment_basepath}\1`sed_rhs_escape $dbc_basepath`/g
s/^\(.*\)_DBC_DBNAME_/${comment_dbname}\1`sed_rhs_escape $dbc_dbname`/g
-s/^\(.*\)_DBC_DBSERVER_/${comment_dbserver}\1`sed_rhs_escape $dbc_dbserver`/g
+s/^\(.*\)_DBC_DBSERVER_/${comment_dbserver}\1`sed_rhs_escape $dbc_dballow`/g
s/^\(.*\)_DBC_DBPORT_/${comment_dbport}\1`sed_rhs_escape $dbc_dbport`/g
s/^\(.*\)_DBC_DBTYPE_/${comment_dbtype}\1`sed_rhs_escape $dbc_dbtype`/g
EOF
More information about the Pkg-zenoss-team
mailing list