Issues with building snap packages and psql - Mailing list pgsql-hackers

From Joshua D. Drake
Subject Issues with building snap packages and psql
Date
Msg-id 2db4f9df-fc9e-14a3-9fc8-5318283f0937@commandprompt.com
Whole thread Raw
Responses Re: Issues with building snap packages and psql  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Issues with building snap packages and psql  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hello,

CMD has been working on building snap packages. It has been an adventure 
and we are very close to having them complete. In fact they are complete 
enough that we have published them in the snap repo.

jd@jd-wks:~$ snap find postgres
Name            Version  Developer  Notes  Summary
postgresql96    9.6.0    cmd        -      PostgreSQL is a powerful, 
open source object-relational database system.
postgresql95    9.5.3    cmd        -      PostgreSQL is a powerful, 
open source object-relational database system.
postgresql94    9.4.9    cmd        -      PostgreSQL is a powerful, 
open source object-relational database system.
postgresql93    9.3.14   cmd        -      PostgreSQL is a powerful, 
open source object-relational database system.

However, we have found a problem with permissions that we haven't been 
able to overcome. The error presents as a simple:

could not save history to file "/home/jd/.psql_history": Permission denied

We tried the work around as presented here:

https://www.commandprompt.com/blog/psql_tip_change_history_location/

It didn't work and I couldn't figure out why. It was especially 
confusing because if you are in psql via snap $HOME is set correctly:

postgres=# \! export
export HOME='/home/jd/snap/postgresql96/1'

Then I traced it and saw this:

open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 7
lseek(7, 0, SEEK_CUR)                   = 0
fstat(7, {st_mode=S_IFREG|0644, st_size=2581, ...}) = 0
mmap(NULL, 2581, PROT_READ, MAP_SHARED, 7, 0) = 0x7f1f9e5fc000
lseek(7, 2581, SEEK_SET)                = 2581
munmap(0x7f1f9e5fc000, 2581)            = 0
close(7)                                = 0
[...]
futex(0x1096088, FUTEX_WAIT, 0, NULL)   = 0
futex(0x1096088, FUTEX_WAIT, 0, NULL/home/jd/.psqlrc: Permission denied
psql (9.6.0)
Type "help" for help.

postgres=# \q
could not save history to file "/home/jd/.psql_history": Permission denied <unfinished ...>
+++ exited with 0 +++

Is psql getting the home directory from /etc/passwd? If so what can we 
do about that?

Sincerely,

JD

-- 
Command Prompt, Inc.                  http://the.postgres.company/                        +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.
Unless otherwise stated, opinions are my own.



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Improving RLS planning
Next
From: Tom Lane
Date:
Subject: Re: Issues with building snap packages and psql