pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Comments in .pgpass file...
9+ messages / 4 participants
[nested] [flat]

* Comments in .pgpass file...
@ 2024-05-21 01:01  Ron Johnson <ronljohnsonjr@gmail.com>
  0 siblings, 3 replies; 9+ messages in thread

From: Ron Johnson @ 2024-05-21 01:01 UTC (permalink / raw)
  To: Pgsql-admin <pgsql-admin@lists.postgresql.org>

It seems that psql (or maybe libpq) doesn't like trailing comments.

This works:
10.143.170.206:5432:*:11026270:Blarge

But this does not:
10.143.170.206:5432:*:11026270:Blarge # Host name: fubar

(Don't tell me to use DNS.  I would if the servers would stay in DNS.)

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 01:07  David G. Johnston <david.g.johnston@gmail.com>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  2 siblings, 0 replies; 9+ messages in thread

From: David G. Johnston @ 2024-05-21 01:07 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Monday, May 20, 2024, Ron Johnson <ronljohnsonjr@gmail.com> wrote:

> It seems that psql (or maybe libpq) doesn't like trailing comments.
>
> This works:
> 10.143.170.206:5432:*:11026270:Blarge
>
> But this does not:
> 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar
>
> (Don't tell me to use DNS.  I would if the servers would stay in DNS.)
>

.pgpass is a libpq thing.

https://www.postgresql.org/docs/current/libpq-pgpass.html

The docs in a bit round-a-bout way state that a comment line begins with
the hashtag.  No other mention of comment formats are given.

David J.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 01:09  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  2 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-05-21 01:09 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

Ron Johnson <ronljohnsonjr@gmail.com> writes:
> It seems that psql (or maybe libpq) doesn't like trailing comments.

Why would you think it would take that?  The manual says that lines
beginning with '#' are comments, but not more than that.

> But this does not:
> 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar

If that acted as a comment, it'd be impossible to use passwords
containing '#'.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 01:18  Erik Wienhold <ewie@ewie.name>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  2 siblings, 1 reply; 9+ messages in thread

From: Erik Wienhold @ 2024-05-21 01:18 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On 2024-05-21 03:01 +0200, Ron Johnson wrote:
> It seems that psql (or maybe libpq) doesn't like trailing comments.
> 
> This works:
> 10.143.170.206:5432:*:11026270:Blarge
> 
> But this does not:
> 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar

How should libpq know where the password ends and the comment begins
while still accepting passwords that contain "#"?  The password is
everything between the 4th unescaped colon and the end of line.

This could be made explicit in the docs.  But the docs don't even say
that you can put entries and comments one the same line.

-- 
Erik





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 01:24  David G. Johnston <david.g.johnston@gmail.com>
  parent: Erik Wienhold <ewie@ewie.name>
  0 siblings, 1 reply; 9+ messages in thread

From: David G. Johnston @ 2024-05-21 01:24 UTC (permalink / raw)
  To: Erik Wienhold <ewie@ewie.name>; +Cc: Ron Johnson <ronljohnsonjr@gmail.com>; Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Monday, May 20, 2024, Erik Wienhold <ewie@ewie.name> wrote:

> On 2024-05-21 03:01 +0200, Ron Johnson wrote:
> > It seems that psql (or maybe libpq) doesn't like trailing comments.
> >
> > This works:
> > 10.143.170.206:5432:*:11026270:Blarge
> >
> > But this does not:
> > 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar
>
> How should libpq know where the password ends and the comment begins
> while still accepting passwords that contain "#"?  The password is
> everything between the 4th unescaped colon and the end of line.
>
> This could be made explicit in the docs.  But the docs don't even say
> that you can put entries and comments one the same line.
>

As written the docs say if your password contain : or \ you should escape
that character with a \ …

I’m not that surprised that a reader expected the password to end at the
first space.

David J.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 01:44  Erik Wienhold <ewie@ewie.name>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Erik Wienhold @ 2024-05-21 01:44 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Ron Johnson <ronljohnsonjr@gmail.com>; Pgsql-admin <pgsql-admin@lists.postgresql.org>

On 2024-05-21 03:24 +0200, David G. Johnston wrote:
> On Monday, May 20, 2024, Erik Wienhold <ewie@ewie.name> wrote:
> 
> > On 2024-05-21 03:01 +0200, Ron Johnson wrote:
> > > It seems that psql (or maybe libpq) doesn't like trailing comments.
> > >
> > > This works:
> > > 10.143.170.206:5432:*:11026270:Blarge
> > >
> > > But this does not:
> > > 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar
> >
> > How should libpq know where the password ends and the comment begins
> > while still accepting passwords that contain "#"?  The password is
> > everything between the 4th unescaped colon and the end of line.
> >
> > This could be made explicit in the docs.  But the docs don't even say
> > that you can put entries and comments one the same line.
> >
> 
> As written the docs say if your password contain : or \ you should escape
> that character with a \ …

Oh, I misread the code, now that you mention it.  libpq reads the
password up to the first unescaped colon.  So one could write:

    10.143.170.206:5432:*:11026270:Blarge: # Host name: fubar

Note the colon right after "Blarge".  But that will very likely clash
with fields that may be added in the future.

-- 
Erik





^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 02:10  Ron Johnson <ronljohnsonjr@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Ron Johnson @ 2024-05-21 02:10 UTC (permalink / raw)
  To: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Mon, May 20, 2024 at 9:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Ron Johnson <ronljohnsonjr@gmail.com> writes:
> > It seems that psql (or maybe libpq) doesn't like trailing comments.
>
> Why would you think it would take that?  The manual says that lines
> beginning with '#' are comments, but not more than that.
>

https://www.postgresql.org/docs/current/libpq-pgpass.html

I searched the man page for "#" and "comment".  The only mention is in this
sentence:

[quote]

*hostname*:*port*:*database*:*username*:*password*

(You can add a reminder comment to the file by copying the line above and
preceding it with #.)
[/quote]

That one sentence can easily be read as only referring to the
"hostname:port..." line.

Since postgresql.conf and pg_hba.conf (I don't use pg_ident.conf) allow
trailing comments,  it seems reasonable that .pgpass should too, for
consistency.

It also seems reasonable that hostnames in .pgpass should be
case-insensitive, since they're case-insensitive everywhere else in the
network world.

> But this does not:
> > 10.143.170.206:5432:*:11026270:Blarge # Host name: fubar
>
> If that acted as a comment, it'd be impossible to use passwords
> containing '#'.
>

Escapes.  It escapes ":" and "\", so should be able to escape "#".

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 03:04  David G. Johnston <david.g.johnston@gmail.com>
  parent: Ron Johnson <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: David G. Johnston @ 2024-05-21 03:04 UTC (permalink / raw)
  To: Ron Johnson <ronljohnsonjr@gmail.com>; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Monday, May 20, 2024, Ron Johnson <ronljohnsonjr@gmail.com> wrote:

> On Mon, May 20, 2024 at 9:10 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> Ron Johnson <ronljohnsonjr@gmail.com> writes:
>> > It seems that psql (or maybe libpq) doesn't like trailing comments.
>>
>> Why would you think it would take that?  The manual says that lines
>> beginning with '#' are comments, but not more than that.
>>
>
> https://www.postgresql.org/docs/current/libpq-pgpass.html
>
> I searched the man page for "#" and "comment".  The only mention is in
> this sentence:
>
> [quote]
>
> *hostname*:*port*:*database*:*username*:*password*
>
> (You can add a reminder comment to the file by copying the line above and
> preceding it with #.)
> [/quote]
>
> That one sentence can easily be read as only referring to the
> "hostname:port..." line.
>

That would seem oddly specific and easily falsifiable.  Which is probably
why no one else has pointed out the odd wording.  They actually try the
generalization and it works.

But I agree the docs could use some improvement.


> Since postgresql.conf and pg_hba.conf (I don't use pg_ident.conf) allow
> trailing comments,  it seems reasonable that .pgpass should too, for
> consistency.
>

Reasonable but probably not worth the hassle to figure out the details.
Though I’d be tempted to formalize the existing behavior and just add an
optional field after password to hold a description.  If we do ever extend
off the end to specify yet more fields we’d make all the preceding optional
fields mandatory.


>
> Escapes.  It escapes ":" and "\", so should be able to escape "#".
>

Frankly it probably shouldn’t escape anything in the password field,
including colons.  But since that ship has sailed, see the preceding idea.

David J.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Comments in .pgpass file...
@ 2024-05-21 03:13  Ron Johnson <ronljohnsonjr@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Ron Johnson @ 2024-05-21 03:13 UTC (permalink / raw)
  To: ; +Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>

On Mon, May 20, 2024 at 11:04 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:
[snip]

> That would seem oddly specific and easily falsifiable.  Which is probably
> why no one else has pointed out the odd wording.
>

Or people grumble silently.


> Reasonable but probably not worth the hassle to figure out the details.
> Though I’d be tempted to formalize the existing behavior and just add an
> optional field after password to hold a description.  If we do ever extend
> off the end to specify yet more fields we’d make all the preceding optional
> fields mandatory.
>

I like that idea.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2024-05-21 03:13 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-05-21 01:01 Comments in .pgpass file... Ron Johnson <ronljohnsonjr@gmail.com>
2024-05-21 01:07 ` David G. Johnston <david.g.johnston@gmail.com>
2024-05-21 01:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2024-05-21 02:10   ` Ron Johnson <ronljohnsonjr@gmail.com>
2024-05-21 03:04     ` David G. Johnston <david.g.johnston@gmail.com>
2024-05-21 03:13       ` Ron Johnson <ronljohnsonjr@gmail.com>
2024-05-21 01:18 ` Erik Wienhold <ewie@ewie.name>
2024-05-21 01:24   ` David G. Johnston <david.g.johnston@gmail.com>
2024-05-21 01:44     ` Erik Wienhold <ewie@ewie.name>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox