avoid password prompt if cluster owner can't connect without password

Bug #37640 reported by Murray Cumming
6
Affects Status Importance Assigned to Milestone
postgresql-common (Ubuntu)
Fix Released
Medium
Martin Pitt

Bug Description

When installing postgres-8.1, I am asked for a password. Here's what happens (the second time, after cancelling the first time, but the effect is the same):

murrayc@ubuntumurrayc:~$ sudo apt-get dist-upgrade
Password:
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade...Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0B of archives.
After unpacking 0B of additional disk space will be used.
Do you want to continue [Y/n]?
Setting up postgresql-8.1 (8.1.3-2build1) ...
 * Starting PostgreSQL 8.1 database server
Password:

I think it's asking for the password for the postgres user. I don't know what that is. I guess it should already have sudo rights to su to the postgres user if it needs to.

Revision history for this message
Martin Pitt (pitti) wrote :

Did you modify pg_hba.conf? I strongly assume that the password prompt is from psql, not from su. The postgres user must be able to access the cluster without a database, see the default pg_hba.conf:

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (autovacuum, daily cronjob, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local all postgres ident sameuser

Changed in postgresql-8.1:
status: Unconfirmed → Needs Info
Revision history for this message
Murray Cumming (murrayc) wrote :

I did comment out that line for a while, but then restored it when I found that psql did not work anymore. Well guessed. At the moment, I have removed all postgres versions (with apt-get remove), but I am asked for the password when I try to do
apt-get install postgresql-8.1

Is there a particular file I should be looking at?

Revision history for this message
Murray Cumming (murrayc) wrote :

This is indeed the problem, but it seems t be a problem with postgres 7.4, which I was _uninstalling_ at the same time. Closing, because this is my fault, though I wish that postgres didn't have a don't-push-this-button feature.

Thanks.

Revision history for this message
Murray Cumming (murrayc) wrote :

Well, I'd like to close it but I don't see how in Launchpad.

Revision history for this message
Martin Pitt (pitti) wrote :

If you merely remove (not purge) a package, all the clusters and their configuration will remain in place.

I see that the handling of this could be improved. The start scripts should check whether this line is still in place and complain loudly if not. In that case the checks for successful startup can just be inhibited, to avoid this password prompt, and instead there should be a meaningful error message.

Changed in postgresql-common:
assignee: nobody → pitti
status: Needs Info → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Fixed in my development version. Will upload in the near future.

Changed in postgresql-common:
status: Confirmed → Fix Committed
Revision history for this message
Martin Pitt (pitti) wrote :

 postgresql-common (51ubuntu1) dapper; urgency=low
 .
   * Synchronize to Debian. Closes: LP#37640
 .
 postgresql-common (51) unstable; urgency=low
 .
   * PgCommon.pm: Add function read_pg_hba() to parse pg_hba.conf.
   * Add t/005_PgCommon.t: Designated for testing PgCommon.pm library
     functions; test read_pg_hba() for now.
   * pg_ctlcluster: Check pg_hba.conf if the database superuser can connect
     locally without a password. If not, disable startup checks to avoid asking
     for the superuser password. (https://launchpad.net/bugs/37640)
   * t/030_errors.t: Test above pg_ctlcluster checks.

Changed in postgresql-common:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.