.ini support for .pgpass

Started by Joshua D. Drakeabout 15 years ago14 messageshackers
Jump to latest
#1Joshua D. Drake
jd@commandprompt.com

The current structure of .pgpass is:

hostname:port:database:username:password

Bare, useful, but not really friendly nor flexible. I would love to be
able to do this:

If no ini block:

hostname:port:database:username:password

else:

[ecom]
hostname=
port=
database=
username=
password=

[drupal]
hostname=
port=
database=
username=
password=

psql ecom

boom, I am in.

Thoughts?

JD

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

#2Josh Berkus
josh@agliodbs.com
In reply to: Joshua D. Drake (#1)
Re: .ini support for .pgpass

On 4/5/11 3:34 PM, Joshua D. Drake wrote:

Bare, useful, but not really friendly nor flexible. I would love to be
able to do this:

I'll second that I help people troubleshoot a lot of .pgpass files where
the basic issue is getting the fields out of order.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

#3David E. Wheeler
david@kineticode.com
In reply to: Joshua D. Drake (#1)
Re: .ini support for .pgpass

On Apr 5, 2011, at 3:34 PM, Joshua D. Drake wrote:

boom, I am in.

Thoughts?

boom, you have patch?

David

#4Joshua D. Drake
jd@commandprompt.com
In reply to: David E. Wheeler (#3)
Re: .ini support for .pgpass

On Tue, 2011-04-05 at 15:38 -0700, David E. Wheeler wrote:

On Apr 5, 2011, at 3:34 PM, Joshua D. Drake wrote:

boom, I am in.

Thoughts?

boom, you have patch?

I'll write it, if I am not going to be tied up for months arguing about
it :P. Thus, I wanted to see if the community was interested first.

Sincerely,

Joshua D. Drake

David

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

#5Aidan Van Dyk
aidan@highrise.ca
In reply to: Joshua D. Drake (#1)
Re: .ini support for .pgpass

On Tue, Apr 5, 2011 at 6:34 PM, Joshua D. Drake <jd@commandprompt.com> wrote:

Bare, useful, but not really friendly nor flexible. I would love to be
able to do this:

[ecom]
hostname=
port=
database=
username=
password=

That looks a lot like a pg_service file.

psql ecom

boom, I am in.

Thoughts?

So you're really looking to make psql use "service" connection
definitions more easily, not just retrieve the password associated
with the given (maybe defaulted) host:port:database:user, right?

a.

--
Aidan Van Dyk                                             Create like a god,
aidan@highrise.ca                                       command like a king,
http://www.highrise.ca/                                   work like a slave.

#6Joshua D. Drake
jd@commandprompt.com
In reply to: Aidan Van Dyk (#5)
Re: .ini support for .pgpass

On Tue, 2011-04-05 at 18:52 -0400, Aidan Van Dyk wrote:

On Tue, Apr 5, 2011 at 6:34 PM, Joshua D. Drake <jd@commandprompt.com> wrote:

Bare, useful, but not really friendly nor flexible. I would love to be
able to do this:

[ecom]
hostname=
port=
database=
username=
password=

That looks a lot like a pg_service file.

psql ecom

boom, I am in.

Thoughts?

So you're really looking to make psql use "service" connection
definitions more easily, not just retrieve the password associated
with the given (maybe defaulted) host:port:database:user, right?

Well any libpq app but yes. I actually wonder as to the legitmacy of
having both a pgpass and a pg_service. Why not just one of them?

JD

a.

--
Aidan Van Dyk Create like a god,
aidan@highrise.ca command like a king,
http://www.highrise.ca/ work like a slave.

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

#7Peter Eisentraut
peter_e@gmx.net
In reply to: Joshua D. Drake (#6)
Re: .ini support for .pgpass

On tis, 2011-04-05 at 16:04 -0700, Joshua D. Drake wrote:

Well any libpq app but yes. I actually wonder as to the legitmacy of
having both a pgpass and a pg_service. Why not just one of them?

So you can keep passwords in a safer place (= less permissions) than the
rest of the connection information.

Note also that .pgpass is a mapping from connection information to
password, whereas pg_service.conf is a mapping from service name to
connection information. So they operate on different levels.

It's not actually clear from your syntax example what semantics you are
trying to achieve.

#8Joshua D. Drake
jd@commandprompt.com
In reply to: Peter Eisentraut (#7)
Re: .ini support for .pgpass

On Wed, 2011-04-06 at 07:47 +0300, Peter Eisentraut wrote:

On tis, 2011-04-05 at 16:04 -0700, Joshua D. Drake wrote:

Well any libpq app but yes. I actually wonder as to the legitmacy of
having both a pgpass and a pg_service. Why not just one of them?

So you can keep passwords in a safer place (= less permissions) than the
rest of the connection information.

Note also that .pgpass is a mapping from connection information to
password, whereas pg_service.conf is a mapping from service name to
connection information. So they operate on different levels.

It's not actually clear from your syntax example what semantics you are
trying to achieve.

I want to achieve two things:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

2. psql foo, gets me into foo. A macro for connections if you will.

JD

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

#9Martijn van Oosterhout
kleptog@svana.org
In reply to: Joshua D. Drake (#8)
Re: .ini support for .pgpass

On Tue, Apr 05, 2011 at 11:55:04PM -0700, Joshua D. Drake wrote:

I want to achieve two things:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

This I understand.

2. psql foo, gets me into foo. A macro for connections if you will.

But this is precisely what the service file achieves, right? ISTM what
you d like is to be able to specify the password in the service file,
in which case pgpass is not consulted.

Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

Patriotism is when love of your own people comes first; nationalism,
when hate for people other than your own comes first.
- Charles de Gaulle

#10Marko Kreen
markokr@gmail.com
In reply to: Joshua D. Drake (#8)
Re: .ini support for .pgpass

On Wed, Apr 6, 2011 at 9:55 AM, Joshua D. Drake <jd@commandprompt.com> wrote:

I want to achieve two things:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

How about allowing '#'-comments there and putting field
list into all templates, examples and manpages?

man 5 pgpass?

pgpass.sample?

IOW, do we need to change format or are we having documentation problem?

--
marko

#11Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marko Kreen (#10)
Re: .ini support for .pgpass

Marko Kreen <markokr@gmail.com> writes:

On Wed, Apr 6, 2011 at 9:55 AM, Joshua D. Drake <jd@commandprompt.com> wrote:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

How about allowing '#'-comments there and putting field
list into all templates, examples and manpages?

man 5 pgpass?

pgpass.sample?

IOW, do we need to change format or are we having documentation problem?

+1 for seeing this as a documentation problem. I don't think that
converting the file to .ini style is going to somehow make it
magically easier to use --- people still have to understand it,
and frankly .ini format is just another format that not everyone knows.

#-comments seem like a fine idea.

regards, tom lane

#12Joshua D. Drake
jd@commandprompt.com
In reply to: Martijn van Oosterhout (#9)
Re: .ini support for .pgpass

On Wed, 2011-04-06 at 09:10 +0200, Martijn van Oosterhout wrote:

On Tue, Apr 05, 2011 at 11:55:04PM -0700, Joshua D. Drake wrote:

I want to achieve two things:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

This I understand.

2. psql foo, gets me into foo. A macro for connections if you will.

But this is precisely what the service file achieves, right? ISTM what
you d like is to be able to specify the password in the service file,
in which case pgpass is not consulted.

Right, as I said (I thought) earlier, after reviewing pg_service it
seems that pgpass is (or pg_service is) redundant. It should be one
file.

JD

Have a nice day,

--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 509.416.6579
Consulting, Training, Support, Custom Development, Engineering
http://twitter.com/cmdpromptinc | http://identi.ca/commandprompt

#13Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#11)
Re: .ini support for .pgpass

On ons, 2011-04-06 at 09:47 -0400, Tom Lane wrote:

Marko Kreen <markokr@gmail.com> writes:

On Wed, Apr 6, 2011 at 9:55 AM, Joshua D. Drake <jd@commandprompt.com> wrote:

1. More understandable .pgpass format. Yes, I understand our standard
format, most people won't. Like JoshB said, hard to debug.

How about allowing '#'-comments there and putting field
list into all templates, examples and manpages?

man 5 pgpass?

pgpass.sample?

IOW, do we need to change format or are we having documentation problem?

+1 for seeing this as a documentation problem. I don't think that
converting the file to .ini style is going to somehow make it
magically easier to use --- people still have to understand it,
and frankly .ini format is just another format that not everyone knows.

#-comments seem like a fine idea.

But it would have to be the user that would put the comment in there,
since we can't really install a default file.

I think a man page would be the best documentation method for
in-the-moment reference.

#14Fujii Masao
masao.fujii@gmail.com
In reply to: Peter Eisentraut (#13)
Re: .ini support for .pgpass

On Thu, Apr 7, 2011 at 2:38 AM, Peter Eisentraut <peter_e@gmx.net> wrote:

#-comments seem like a fine idea.

But it would have to be the user that would put the comment in there,
since we can't really install a default file.

What about preparing something like pgpass.sample and installing it
into $PREFIX/share, like recovery.conf?

I think a man page would be the best documentation method for
in-the-moment reference.

This would be also helpful.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center