Browse Source

Use a login shell while using su (see: https://bugs.debian.org/858910)

Hendrik vom Lehn 5 years ago
parent
commit
1898a010bc
1 changed files with 3 additions and 3 deletions
  1. 3 3
      autopostgresqlbackup

+ 3 - 3
autopostgresqlbackup

@@ -356,9 +356,9 @@ dbdump () {
     for db in $1 ; do
         if [ -n "$SU_USERNAME" ]; then
             if [ "$db" = "$GLOBALS_OBJECTS" ]; then
-                su $SU_USERNAME -c "pg_dumpall $PGHOST --globals-only" >> $2
+                su $SU_USERNAME -l -c "pg_dumpall $PGHOST --globals-only" >> $2
             else
-                su $SU_USERNAME -c "pg_dump $PGHOST $OPT $db" >> $2
+                su $SU_USERNAME -l -c "pg_dump $PGHOST $OPT $db" >> $2
             fi
         else
             if [ "$db" = "$GLOBALS_OBJECTS" ]; then
@@ -449,7 +449,7 @@ fi
 # If backing up all DBs on the server
 if [ "$DBNAMES" = "all" ]; then
     if [ -n "$SU_USERNAME" ]; then
-        DBNAMES="$(su $SU_USERNAME -c "LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne '/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }'")"
+        DBNAMES="$(su $SU_USERNAME -l -c "LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne '/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }'")"
     else
         DBNAMES="`LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne "/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }"`"
     fi