Re: Getting a DB password to work without editing pg_hba.conf,

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Madison Kelly <linux(at)alteeve(dot)com>
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting a DB password to work without editing pg_hba.conf,
Date: 2005-12-16 20:27:25
Message-ID: 28919.1134764845@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Madison Kelly <linux(at)alteeve(dot)com> writes:
> Oh shoot, I really wasn't very verbose, was I? Sorry about that.
> [ default pg_hba.conf with only "ident" lines ]

Ah, that explains your question about whether passwords were good for
anything at all. With this pg_hba.conf they aren't --- the server will
never ask for one. You'd want to replace some of the "ident sameuser"
entries with "password" (or more likely "md5") if you want password
challenges instead of checks on the user's Unix login identity. See
the PG administrator docs at
http://www.postgresql.org/docs/8.1/static/client-authentication.html
(adjust version as needed)

> So ultimately my question becomes; How can I prevent other valid
> postgres database users from connecting to the 'tle-bu' database
> ('postgres' being the obvious exception)? Can I do this with some
> combination of GRANT and/or REVOKE?

At the moment you have to do that by adjusting the pg_hba.conf entries.
One possibility is to use "sameuser" in the database field, eg,

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
# Database administrative login by UNIX sockets
local all postgres ident sameuser
#
# All other connections by UNIX sockets
local sameuser all ident sameuser

This will let "postgres" connect to anything but other users can only
connect to the database named after them. If you need more flexibility
that that, consider setting up groups named for databases and using
"samegroup" --- then you grant or revoke group membership to let people
into databases or not.

It'd be an obvious extension to provide a direct "LOGIN" privilege
on databases and grant or revoke that, but given the samegroup
workaround it's not a real high-priority feature ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-12-16 20:28:43 Re: 8.1 build on Solaris has LATIN9?
Previous Message Alvaro Herrera 2005-12-16 20:22:34 Re: [GENERAL] Transacciones Anidadas