Thread: .ini support for .pgpass

.ini support for .pgpass

From
"Joshua D. Drake"
Date:
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



Re: .ini support for .pgpass

From
Josh Berkus
Date:
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


Re: .ini support for .pgpass

From
"David E. Wheeler"
Date:
On Apr 5, 2011, at 3:34 PM, Joshua D. Drake wrote:

> boom, I am in. 
> 
> Thoughts?

boom, you have patch?

David



Re: .ini support for .pgpass

From
"Joshua D. Drake"
Date:
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



Re: .ini support for .pgpass

From
Aidan Van Dyk
Date:
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.


Re: .ini support for .pgpass

From
"Joshua D. Drake"
Date:
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



Re: .ini support for .pgpass

From
Peter Eisentraut
Date:
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.




Re: .ini support for .pgpass

From
"Joshua D. Drake"
Date:
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



Re: .ini support for .pgpass

From
Martijn van Oosterhout
Date:
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/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
>                                       - Charles de Gaulle

Re: .ini support for .pgpass

From
Marko Kreen
Date:
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


Re: .ini support for .pgpass

From
Tom Lane
Date:
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


Re: .ini support for .pgpass

From
"Joshua D. Drake"
Date:
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



Re: .ini support for .pgpass

From
Peter Eisentraut
Date:
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.




Re: .ini support for .pgpass

From
Fujii Masao
Date:
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