[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using debconf to notify of serious postinst problems

Colin Turner <ct@piglets.com> writes:

> 2. Using debconf to notify in postinst

> Part of the install is to create a database with given credentials and
> import a schema. I have debconf prompting for values and I'm
> successfully using these in the postinst script.

> My problem/worry is this. I am asking for the root MySQL password - if
> it is known - and letting the user know I'll purge this value straight
> after database creation and so on.

> Then, in postinst, I try to test the credentials before I go further

> -=-

>   if [ "$have_password" = "yes" ]
>     then
>     set +e
>     # try a trivial query, logging in as MySQL root
>     command_result=`echo "SELECT VERSION()" | mysql -h $data_hostname -u
> root --password=$root_db_password 2>&1`
>     if [ "$?" -ne 0 ]
>     then
>       # We don't have valid root credentials
>       have_password="no"
>       # Warn the user it's all gone fubar - but this makes lintian mad,
> remove for now
>       echo "WARNING! Invalid MySQL root credentials ..."
>       #db_input high opus/invalid_root_password || true
>       #db_go
>     fi
>   fi

> -=-

> The problem is, as indicated in the comments, I wanted to use a "note"
> template to warn / email the user if the credentials were wrong, before
> trying to do what I could. Adding the input causes a lintian warning.

Other people have given you good suggestions, but I did want to mention
that the lintian warning is just because lintian can't easily tell the
difference between valid uses of debconf in postinst and prompting in
postinst instead of config.  For cases where one is intentionally
prompting in postinst on the basis of information that isn't available
before that point, a lintian override is appropriate.

Russ Allbery (rra@debian.org)               <http://www.eyrie.org/~eagle/>

Reply to: