[Dbconfig-common-devel] Forgotten dbc_dbname

sean finney seanius at debian.org
Sun Sep 11 14:07:34 UTC 2005


hey miguel,

On Sun, Sep 11, 2005 at 11:00:57AM +0200, Miguel Gea Milvaques wrote:
> It seems there are a problem with postgres packages with
> dbconfig-common. In /usr/share/dbconfig-common/dpkg/postinst, you could see:
> ...
>    ### now, create the app user account
>    ###
>    $dbc_createuser_cmd || dbc_install_error "creating user"
>    [ "$dbc_tried_again" ] && return 0
> 
>    ###
>    ### create the database
>    ###
>    $dbc_createdb_cmd || dbc_install_error "creating database"
>    [ "$dbc_tried_again" ] && return 0
> ...
> 
> if debug the dbc_dbname in this file before and after app user account
> creation, you could see it changes the dbc_dbname variable to template1.

hmm..  

> I've been looking for the error in dbc_pgsql_createuser function and
> others, but I don't found it. I've solved it modifying those lines to:
<snip>
> I don't think this is the best form to solve it, because there are a bug
> in dbc_createuser_cmd funtion, so I don't uploaded it to the cvs.

right.  in dbc_pgsql_create_user, dbc_dbname is set as a local variable,
so any change made to it shouldn't trickle back to the postinst script.
there, it's set to template1, before _dbc_createuser is called.

in _dbc_createuser, it's also declared as local, and then passed to
_dbc_pgsql_exec_command via:

	extra="$extra" dbc_dbname="template1" _dbc_pgsql_exec_command "CREATE USER \"$dbc_dbuser\" WITH PASSWORD '$dbc_dbpass'"

and then _dbc_pgsql_exec passes it on to _dbc_psql, but doesn't do any
kind of modifications/assignments to the variable after that point.  i'm
not sure how it could happen, but my guess if it's being permanently
changed that it's with the above call to _dbc_pgsql_exec_command,
though i wouldn't know why.  so the only thing i can think of that might
fix the problem is to then remove that assignment and pass it as a
parameter instead.  if you have some time, could you see if the following
works?  

- modify _dbc_pgsql_exec_command to treat "$1" as the statement instead
  of "$@".
- modify _dbc_pgsql_exec_command to declare dbc_dbname as local, and
  take a database name as a second argument



thanks,
	sean

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/dbconfig-common-devel/attachments/20050911/b57918ca/attachment.pgp


More information about the Dbconfig-common-devel mailing list