#656018 davical: create-database.sh fails with strict pg_hba.conf settings

Package:
src:davical
Source:
davical
Submitter:
Christoph Anton Mitterer
Date:
2015-12-09 19:30:23 UTC
Severity:
normal
#656018#5
Date:
2012-01-15 21:43:06 UTC
From:
To:
Hi.

Running create-database.sh when creating the DBs with a pg_hab.conf that
doesn't use trust-mode, but allows just some users ends up in an error,
even though the user is currectly authorised.

pg_hba.conf:
local   davical         davical_dba,davical_app                 peer    map=davical

pg_ident.conf:
davical         cgi-davical             davical_dba
davical         cgi-davical             davical_app

Creating the DB with:
su postgres -c /usr/share/davical/dba/create-database.sh

At some point it seems to try accessing the DB, but this fails of course
as one is user postgres, and not cgi-davical.

Not sure whether this can be easily fixed in code, but then at least
the documentation should state, that during installation, you'll need both,
being a user that is allowed to create DBs (=> postgres) and to access
davical (in my case cgi-davical)... or one should just add the "trust"-rules
during installation.


What about updates? Is it also required there?

Cheers,
Chris.

#656018#10
Date:
2013-02-26 07:29:37 UTC
From:
To:
I have the same problem. Allowing a "trust" type connection is out of the question
so this is how my /etc/postgresql/8.4/main/pg_hba.conf looks like.

# Database administrative login by UNIX sockets
local   all         postgres                          ident
# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   all         root                               md5
# "local" is for Unix domain socket connections only
local   all         all                               md5
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5


When I run /usr/share/davical/dba/create-database.sh this happens:
postgres@mail:/tmp$ /usr/share/davical/dba/create-database.sh
Password for user davical_dba:
Password for user davical_dba:
Password for user davical_dba:
Password for user davical_dba:

Password for user davical_dba:

Using database: davical_dba%@dbi:Pg:dbname=davical
DBI connect('dbname=davical','davical_dba',...) failed: fe_sendauth: no password supplied at /usr/share/davical/dba/update-davical-database line 245
Can't connect to database davical at /usr/share/davical/dba/update-davical-database line 245.
* * * * ERROR * * * *
The database administration utility failed.  This may be due to database
permissions for the davical_dba user, or because the Perl DBD::Pg or YAML
libraries are not available.

Check that your pg_hba.conf allows the davical_dba user to connect to the
database (and make sure you've reloaded PostgreSQL since changing that).

Also see:  http://wiki.davical.org/w/Install_Errors/No_Perl_YAML

For above output debuging in /usr/share/davical/dba/update-davical-database was activated.
I can workaround the problem by editing /usr/share/davical/dba/update-davical-database on line 19 and changing
my $dbpass = "";
to
my $dbpass = "PASSWORD_FOR_USER_davical_dba";
during installation. I am not finished with the setup so I don't know if it will work later without the workaround.
I guess somehow the script doesn't use the password it asks from the user. I don't know perl so I can't debug it further.