sqitchers / docker-sqitch

Docker Image packaging for Sqitch
MIT License
36 stars 39 forks source link

sqitch looks for .pgpass in /root instead of /home #2

Closed nugget closed 5 years ago

nugget commented 5 years ago

Environment

Summary

When running docker-ized sqitch against db:pg: targets, sqitch is unable to pull credentials from the .pgpass file mounted in /home. Sqitch aborts with the message fe_sendauth: no password supplied.

Sqitch ignores the value of the $HOME environment variable and instead relies on root's passwd entry to locate the .pgpassfile.

Symptoms

Overriding the entrypoint in the image and running /bin/dash exhibits the same behavior. Trying to use sqitch pointing to a postgresql target behaves the same way.

root@linuxkit-025000000001:/repo# sqitch status targetname
# On database targetname
fe_sendauth: no password supplied

The target is configured as:

[target "targetname"]
    uri = db:pg://dbuser@dbhost.example.com/dbname

Curiously, the pg tools in the image have the same problem

root@linuxkit-025000000001:/repo# psql --Udbuser -h dbhost.example.com dbname
Password for user dbuser:

Workaround

nugget commented 5 years ago

Proposed solution

Changing the mountpoint for home in docker-sqitch.sh fixes the glitch. I don't know if /home is referenced anywhere else which might have troubles with this change.

docker run -it --rm --network host \
    --mount "type=bind,src=$(pwd),dst=/repo" \
    --mount "type=bind,src=$HOME,dst=/root" \
    "${passenv[@]}" "$SQITCH_IMAGE" "$@"
theory commented 5 years ago

3 seems like a no-brainer. Thank you.

theory commented 5 years ago

BTW, as of 984e4f5, I've changed it to create a user named sqitch, using /home for the home directory. LMK if that causes any problems for you.

nugget commented 5 years ago

Confirmed working with the latest image/changes. Thanks!