Thread: [GENERAL] Preventing psql from attempting to access ~/.pgpass file.

[GENERAL] Preventing psql from attempting to access ~/.pgpass file.

From
Allan Kamau
Date:
Hi,

I am executing many "COPY" commands via psql serially from a bash script from a compute node that accesses a mounted home directory located on a remote server.
After about a thousand or so executions of the "COPY" command I get the error "psql: could not get home directory to locate password file".
for each subsequent attempt to connect to PostgreSQL using psql so as to issue the next "COPY" command.

I have configured pg_hba.conf to trust connections coming from the specific network which contains both the PostgreSQL server and the node which I am executing the psql commands from.

Is there a way to instruct psql not to try reading ~/.pgpass file?

Both server and client (psql) are PostgreSQL 10.0 built from source, the OS environment is Linux Centos 7.3.1611 (Core). 


Allan.

Re: [GENERAL] Preventing psql from attempting to access ~/.pgpassfile.

From
Justin Pryzby
Date:
On Tue, Oct 17, 2017 at 09:06:59AM +0300, Allan Kamau wrote:
> Is there a way to instruct psql not to try reading ~/.pgpass file?

https://www.postgresql.org/docs/current/static/libpq-envars.html
PGPASSFILE behaves the same as the passfile connection parameter.
passfile
Specifies the name of the file used to store passwords (see Section 33.15). Defaults to ~/.pgpass, or
%APPDATA%\postgresql\pgpass.confon Microsoft Windows. (No error is reported if this file does not exist.)
 

https://www.postgresql.org/docs/9.6/static/libpq-envars.html
PGPASSFILE specifies the name of the password file to use for lookups. If not set, it defaults to ~/.pgpass (see
Section31.15).
 

verifying it doesn't access the default:
pryzbyj@pryzbyj:~$ echo quit |PGPASSFILE=/nonextant strace psql 2>&1 |grep -E 'nonex|pgpass'
stat("/nonextant", 0x7fffbd13c9f0)      = -1 ENOENT (No such file or directory)
pryzbyj@pryzbyj:~$ 


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Preventing psql from attempting to access ~/.pgpass file.

From
Murtuza Zabuawala
Date:
​It is not psql but libpq which uses ​.pgpass file, as per my knowledge there is no way of preventing it unless you have your own customize version of libpq which do not have such option in it. But there is a workaround to prevent libpg from using default .pgpass file is to set 'PGPASSFILE' environment variable to something like '/dev/null'.

--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


On Tue, Oct 17, 2017 at 11:36 AM, Allan Kamau <kamauallan@gmail.com> wrote:
Hi,

I am executing many "COPY" commands via psql serially from a bash script from a compute node that accesses a mounted home directory located on a remote server.
After about a thousand or so executions of the "COPY" command I get the error "psql: could not get home directory to locate password file".
for each subsequent attempt to connect to PostgreSQL using psql so as to issue the next "COPY" command.

I have configured pg_hba.conf to trust connections coming from the specific network which contains both the PostgreSQL server and the node which I am executing the psql commands from.

Is there a way to instruct psql not to try reading ~/.pgpass file?

Both server and client (psql) are PostgreSQL 10.0 built from source, the OS environment is Linux Centos 7.3.1611 (Core). 


Allan.