From fb092feabcfd518239fa1464203e9d7c31e0e0f1 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 17 Jan 2022 15:12:12 +0900 Subject: [PATCH] Fix for "local" socket host name if -h local is set, be sure to never set -h flag so we use the socket and not host connection. Needed for trust with socket flow (sudo -u) --- pg_drop_restore.sh | 2 +- pg_restore_db_file.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pg_drop_restore.sh b/pg_drop_restore.sh index ec26604..e7a1e29 100755 --- a/pg_drop_restore.sh +++ b/pg_drop_restore.sh @@ -110,7 +110,7 @@ while getopts ":o:d:h:f:p:e:i:j:raqnms" opt; do fi; ;; h|hostname) - if [ -z "$host" ]; then + if [ -z "$_host" ]; then # if local it is socket if [ "$OPTARG" != "local" ]; then host='-h '$OPTARG; diff --git a/pg_restore_db_file.sh b/pg_restore_db_file.sh index 75fb97e..914949e 100755 --- a/pg_restore_db_file.sh +++ b/pg_restore_db_file.sh @@ -81,7 +81,10 @@ while getopts ":f:j:h:p:e:granm" opt; do ;; h|hostname) if [ -z "$host" ]; then - host='-h '$OPTARG; + # do not set if local name (uses socket) + if [ "$OPTARG" != "local" ]; then + host='-h '$OPTARG; + fi; _host=$OPTARG; HOST=$OPRTARG; fi;