On Mon, Jan 20, 2020 at 09:17:47PM +0100, Alexander Kukushkin wrote: > Hi, > > I think I should add my two cents. > > On Mon, 20 Jan 2020 at 20:38, Tom Lane <t...@sss.pgh.pa.us> wrote: > > > > > I found another place that assumes 100 bytes and upped it to 2048. > > There one more place, in the code which is parsing .pgpass
What I found that seems like it might be related was on line 6900 of src/interfaces/libpq/fe-connect.c (passwordFromFile): #define LINELEN NAMEDATALEN*5 which is 315 (63*5) by default and isn't 100 on any sane setup. What did I miss? In any case, having the lengths be different in different places seems sub-optimal. PGPASSWORD is just a const char *, so could be quite long. The password prompted for by psql can be up to 100 bytes, and the one read from .pgpass is bounded from above by 315 - 4 (colons) - 4 (shortest possible hostname) - 4 (usual port number) - 1 (shortest db name) - 1 (shortest possible username) ------------------------------- 301 > > So this is pretty much exactly what I expected. And have you tried > > it with e.g. PAM, or LDAP? > > > > I think the AWS guys are fools to imagine that this will work in very > > many places, and I don't see why we should be leading the charge to > > make it work for them. What's the point of having a huge amount of > > data in a password, anyway? > > We at Zalando are using JWT tokens as passwords. JWT tokens are > self-contained and therefore quite huge (up to 700-800 bytes in our > case). Tokens have a limited lifetime (1 hour) and we are using PAM to > verify them. > Altogether the whole thing works like a charm. The only problem that > it is not possible to copy&paste the token into psql password prompt, > but there is a workaround, export PGPASSWORD=verylongtokenstring && > psql > > JWT: https://jwt.io/ > PAM module to verify OAuth tokens: https://github.com/CyberDem0n/pam-oauth2 This reminds me of a patch that implemented PGPASSCOMMAND. https://www.postgresql.org/message-id/flat/CAE35ztOGZqgwae3mBA%3DL97pSg3kvin2xycQh%3Dir%3D5NiwCApiYQ%40mail.gmail.com Discussion of that seems to have trailed off, though. My thought on that was that it was making a decision about the presence of both a .pgpass file and a PGPASSCOMMAND setting that it shouldn't have made, i.e. it decided which took precedence. I think it should fail when presented with both, as there's not a single right answer that will cover all cases. Best, David. -- David Fetter <david(at)fetter(dot)org> http://fetter.org/ Phone: +1 415 235 3778 Remember to vote! Consider donating to Postgres: http://www.postgresql.org/about/donate