Minor issues in .pgpass

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Minor issues in .pgpass
Date: 2020-01-21 06:27:50
Message-ID: c0f0c01c-fa74-9749-2084-b73882fd5465@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

When I was researching the maximum length of password in PostgreSQL
to answer the question from my customer, I found that there are two
minor issues in .pgpass file.

(1) If the length of a line in .pgpass file is larger than 319B,
libpq silently treats each 319B in the line as a separate
setting line.

(2) The document explains that a line beginning with # is treated
as a comment in .pgpass. But as far as I read the code,
there is no code doing such special handling. Whether a line
begins with # or not, libpq just checks that the first token
in the line match with the host. That is, if you try to connect
to the host with the hostname beginning with #,
it can match to the line beginning with # in .pgpass.

Also if the length of that "comment" line is larger than 319B,
the latter part of the line can be treated as valid setting.

You may think that these unexpected behaviors are not so harmful
in practice because "usually" the length of password setting line is
less than 319B and the hostname beginning with # is less likely to be
used. But the problem exists. And there are people who want to use
large password or to write a long comment (e.g., with multibyte
characters like Japanese) in .pgass, so these may be more harmful
in the near future.

For (1), I think that we should make libpq warn if the length of a line
is larger than 319B, and throw away the remaining part beginning from
320B position. Whether to enlarge the length of a line should be
a separate discussion, I think.

For (2), libpq should treat any lines beginning with # as comments.

I've not created the patch yet, but will do if we reach to
the consensus.

Regards,

--
Fujii Masao
NTT DATA CORPORATION
Advanced Platform Technology Group
Research and Development Headquarters

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-01-21 06:34:58 Re: [HACKERS] Block level parallel vacuum
Previous Message tsunakawa.takay@fujitsu.com 2020-01-21 06:24:29 RE: SLRU statistics