summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorVladimir Kirillov <proger@wilab.org.ua>2014-03-31 17:53:00 +0800
committerVladimir Kirillov <proger@wilab.org.ua>2014-03-31 18:06:06 +0800
commitc66be6378d8bbcea271b2d2102741fdda87ec8fe (patch)
tree67925f185c5547152671e497e734a6e6fa816f5f /nixos
parent6167da54ea35b78ec93daffaa1bb1033d2ac1a67 (diff)
downloadnixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar.gz
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar.bz2
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar.lz
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar.xz
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.tar.zst
nixlib-c66be6378d8bbcea271b2d2102741fdda87ec8fe.zip
postgresql: properly fix permissions issue by in postStart
as per postgresql manual, interactions with psql should be carried
out with the postgresql system user and postgresql db user by default.

ensure it happens in postStart.
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/databases/postgresql.nix4
1 files changed, 2 insertions, 2 deletions
diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix
index a83b1a110fed..33ee7244e3f4 100644
--- a/nixos/modules/services/databases/postgresql.nix
+++ b/nixos/modules/services/databases/postgresql.nix
@@ -225,14 +225,14 @@ in
         # Wait for PostgreSQL to be ready to accept connections.
         postStart =
           ''
-            while ! psql postgres -c "" 2> /dev/null; do
+            while ! su -s ${pkgs.stdenv.shell} postgres -c 'psql postgres -c ""' 2> /dev/null; do
                 if ! kill -0 "$MAINPID"; then exit 1; fi
                 sleep 0.1
             done
 
             if test -e "${cfg.dataDir}/.first_startup"; then
               ${optionalString (cfg.initialScript != null) ''
-                cat "${cfg.initialScript}" | psql postgres
+                cat "${cfg.initialScript}" | su -s ${pkgs.stdenv.shell} postgres -c 'psql postgres'
               ''}
               rm -f "${cfg.dataDir}/.first_startup"
             fi