Re: Comments in .pgpass file...

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>, Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Comments in .pgpass file...
Date: 2024-05-21 01:44:02
Message-ID: de5e88f7-6baf-4f2f-906d-2a5146a0a085@ewie.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On 2024-05-21 03:24 +0200, David G. Johnston wrote:
> On Monday, May 20, 2024, Erik Wienhold <ewie(at)ewie(dot)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

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Ron Johnson 2024-05-21 02:10:45 Re: Comments in .pgpass file...
Previous Message David G. Johnston 2024-05-21 01:24:07 Re: Comments in .pgpass file...