pgpass file type restrictions

From: Desidero <desidero(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: pgpass file type restrictions
Date: 2017-10-19 02:45:50
Message-ID: CABvH9hXLDEhy8eGxLyXzaXMdPuQYd5_=f-u4VUZ4SQs_VMSe2Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I’m running into problems with the restriction on pgpass file types. When
attempting to use something like an anonymous pipe for a passfile, psql
throws an error stating that it only accepts plain files. If it matters,
I'm trying to use that so I can pass a decrypted pgpassfile into postgres
since my company is not allowed to have unencrypted credentials on disk
(yes, I know that it's kind of silly to add one layer of abstraction, but
it's an industry rule we can't avoid). I know that we can also just avoid
using psql, but there are benefits to using it for simple scripts, so if we
can make this work fairly easily we'd like to do that.

I looked around to see if I could figure out why that restriction was put
there in the first place, but the only reference I found was this entry in
the 8.2.6 release notes which I wasn’t able to trace back to anything in
particular:

Fix libpq crash when PGPASSFILE refers to a file that is not a plain file
(Martin Pitt)

I was also unable to find anything useful in the source code. There were no
comments around this snippet indicating why it was limited to plain files
(it was implemented this way back in 2005!):

https://github.com/postgres/postgres/blame/d3a0c8dce9380e77734e41becd9aa3
5618030352/src/interfaces/libpq/fe-connect.c#L3138

if (!S_ISREG(stat_buf.st_mode))

{

fprintf(stderr,

libpq_gettext("WARNING: Password file %s is not a plain file.\n"),

pgpassfile);

free(pgpassfile);

return NULL;

}

Does anyone know why it’s set up to avoid using things like anonymous pipes
(or anything but "plain files")?

Regards,

Matt

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-10-19 06:12:55 Re: pgpass file type restrictions
Previous Message Brent Wood 2017-10-18 23:04:50 Re: Divert triggers on materialized views