Test: skip inaccessible Unix socket directories.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 1 Apr 2025 06:45:40 +0000 (15:45 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 1 Apr 2025 06:45:40 +0000 (15:45 +0900)
Commit 182b65bfc allows to use multiple Unix socket directories: /tmp
and /var/run/postgresql.  However if the system does not have
accessible /var/run/postgresql, pgpool_setup fails unless
$PGSOCKET_DIR is explicitly set. Instead of failing, this commit
allows pgpool_setup to skip inaccessible directories.

Backpatch-through: v4.5

src/test/pgpool_setup.in

index 00510037f768ce462f480af0c1af2273526ae4aa..4eff7dd73e786decfd6d5316534afd2df5cecbde 100644 (file)
@@ -76,8 +76,24 @@ PGPOOLDIR=${PGPOOLDIR:-"@@PGPOOL_CONFIG_DIR@@"}
 PGBIN=${PGBIN:-"@@PGSQL_BIN_DIR@@"}
 # LD_LIBRARY_PATH 
 LPATH=${PGLIB:-"@@PGSQL_LIB_DIR@@"}
-# unix socket directory
+# unix socket directories
 PGSOCKET_DIR=${PGSOCKET_DIR:-"/tmp,/var/run/postgresql"}
+# remove inaccessible diretories from PGSOCKET_DIR
+tmp=`echo $PGSOCKET_DIR|sed "s/,/ /"`
+dir=""
+first=true
+for i in $tmp
+do
+    if [ -w $i ];then
+       if [ $first != "true" ];then
+           dir="$dir,$i"
+       else
+           dir=$i
+       fi
+    fi
+    first=false
+done
+PGSOCKET_DIR=$dir
 # initdb args
 INITDBARG="--no-locale -E UTF_8"
 # Use replication slot