Document spaces in .pgpass need to be escaped

Started by James Colemanover 4 years ago3 messages
#1James Coleman
jtc331@gmail.com
1 attachment(s)

A coworker has a space in a Postgres password and noticed .pgpass
didn't work; escaping it fixed the issue. That requirement wasn't
documented (despite other escaping requirements being documented), so
I've attached a patch to add that comment.

Thanks,
James Coleman

Attachments:

v1-0001-Document-spaces-in-.pgpass-need-to-be-escaped.patchapplication/octet-stream; name=v1-0001-Document-spaces-in-.pgpass-need-to-be-escaped.patchDownload
From 46ca159bf5a65f80ecbae07e762f0cb637a562aa Mon Sep 17 00:00:00 2001
From: James Coleman <jtc331@gmail.com>
Date: Tue, 28 Sep 2021 10:13:49 -0400
Subject: [PATCH v1] Document spaces in .pgpass need to be escaped.

A coworker has a space in a Postgres password and noticed .pgpass didn't
work; escaping it fixed the issue. That requirement wasn't documented
(despite other escaping requirements being documented), so add that
comment now.
---
 doc/src/sgml/libpq.sgml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index b449c83..ecce0bd 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -8091,8 +8091,9 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
    <literal>*</literal>, which matches anything.  The password field from
    the first line that matches the current connection parameters will be
    used.  (Therefore, put more-specific entries first when you are using
-   wildcards.) If an entry needs to contain <literal>:</literal> or
-   <literal>\</literal>, escape this character with <literal>\</literal>.
+   wildcards.) If an entry needs to contain <literal>:</literal>,
+   <literal> </literal>,
+   or <literal>\</literal>, escape this character with <literal>\</literal>.
    The host name field is matched to the <literal>host</literal> connection
    parameter if that is specified, otherwise to
    the <literal>hostaddr</literal> parameter if that is specified; if neither
-- 
2.10.1

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: James Coleman (#1)
Re: Document spaces in .pgpass need to be escaped

James Coleman <jtc331@gmail.com> writes:

A coworker has a space in a Postgres password and noticed .pgpass
didn't work; escaping it fixed the issue. That requirement wasn't
documented (despite other escaping requirements being documented), so
I've attached a patch to add that comment.

I looked at passwordFromFile() and I don't see any indication that
it treats spaces specially. Nor does a quick test here confirm
this report. So I'm pretty certain that this proposed doc change
is wrong. Perhaps there's some other issue to investigate, though?

regards, tom lane

#3James Coleman
jtc331@gmail.com
In reply to: Tom Lane (#2)
Re: Document spaces in .pgpass need to be escaped

On Wed, Sep 29, 2021 at 12:13 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

James Coleman <jtc331@gmail.com> writes:

A coworker has a space in a Postgres password and noticed .pgpass
didn't work; escaping it fixed the issue. That requirement wasn't
documented (despite other escaping requirements being documented), so
I've attached a patch to add that comment.

I looked at passwordFromFile() and I don't see any indication that
it treats spaces specially. Nor does a quick test here confirm
this report. So I'm pretty certain that this proposed doc change
is wrong. Perhaps there's some other issue to investigate, though?

regards, tom lane

Thanks for taking a look.

I'm honestly not sure what happened here. I couldn't reproduce again
either, and on another box with this coworker we could reproduce, but
then realized the pgpass entry was missing a field. I imagine it must
have been similar on the original box we observed the error on, but
both of our memories were of just adding teh escape characters...

I'll mark the CF entry as withdrawn.

Thanks,
James Coleman