Change the built-in default socket directory to be /var/run/postgresql. For backwards compatibility with (probably non-libpq-based) clients that might still expect to find the socket in /tmp, also create a socket in /tmp. This is to resolve communication problems with clients operating under systemd's PrivateTmp environment, which won't be using the same global /tmp directory as the server; see bug #825448. Note that we apply the socket directory change at the level of the hard-wired defaults in the C code, not by just twiddling the setting in postgresql.conf.sample; this is so that the change will take effect on server package update, without requiring any existing postgresql.conf to be updated. (Of course, a user who dislikes this behavior can still override it via postgresql.conf.) This patch must be applied after postgresql-multi-sockets.patch, at least until 9.3 when that will be part of the upstream package. diff -Naur postgresql-9.2.0.sockets/contrib/pg_upgrade/test.sh postgresql-9.2.0/contrib/pg_upgrade/test.sh --- postgresql-9.2.0.sockets/contrib/pg_upgrade/test.sh 2012-09-06 17:26:17.000000000 -0400 +++ postgresql-9.2.0/contrib/pg_upgrade/test.sh 2012-09-06 18:13:18.178092176 -0400 @@ -62,10 +62,14 @@ rm -rf "$logdir" mkdir "$logdir" +# we want the Unix sockets in $temp_root +PGHOST=$temp_root +export PGHOST + set -x $oldbindir/initdb -$oldbindir/pg_ctl start -l "$logdir/postmaster1.log" -w +$oldbindir/pg_ctl start -l "$logdir/postmaster1.log" -o "-c unix_socket_directories='$PGHOST'" -w if "$MAKE" -C "$oldsrc" installcheck; then pg_dumpall -f "$temp_root"/dump1.sql || pg_dumpall1_status=$? if [ "$newsrc" != "$oldsrc" ]; then @@ -108,7 +112,7 @@ pg_upgrade -d "${PGDATA}.old" -D "${PGDATA}" -b "$oldbindir" -B "$bindir" -pg_ctl start -l "$logdir/postmaster2.log" -w +pg_ctl start -l "$logdir/postmaster2.log" -o "-c unix_socket_directories='$PGHOST'" -w if [ $testhost = Msys ] ; then cmd /c analyze_new_cluster.bat diff -Naur postgresql-9.2.0.sockets/src/backend/utils/misc/guc.c postgresql-9.2.0/src/backend/utils/misc/guc.c --- postgresql-9.2.0.sockets/src/backend/utils/misc/guc.c 2012-09-06 18:12:36.458693394 -0400 +++ postgresql-9.2.0/src/backend/utils/misc/guc.c 2012-09-06 18:13:18.181092327 -0400 @@ -2901,7 +2901,7 @@ }, &Unix_socket_directories, #ifdef HAVE_UNIX_SOCKETS - DEFAULT_PGSOCKET_DIR, + DEFAULT_PGSOCKET_DIR ", /tmp", #else "", #endif diff -Naur postgresql-9.2.0.sockets/src/bin/initdb/initdb.c postgresql-9.2.0/src/bin/initdb/initdb.c --- postgresql-9.2.0.sockets/src/bin/initdb/initdb.c 2012-09-06 18:12:36.460693488 -0400 +++ postgresql-9.2.0/src/bin/initdb/initdb.c 2012-09-06 18:13:18.183092471 -0400 @@ -1003,7 +1003,7 @@ #ifdef HAVE_UNIX_SOCKETS snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'", - DEFAULT_PGSOCKET_DIR); + DEFAULT_PGSOCKET_DIR ", /tmp"); #else snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''"); #endif diff -Naur postgresql-9.2.0.sockets/src/include/pg_config_manual.h postgresql-9.2.0/src/include/pg_config_manual.h --- postgresql-9.2.0.sockets/src/include/pg_config_manual.h 2012-09-06 17:26:17.000000000 -0400 +++ postgresql-9.2.0/src/include/pg_config_manual.h 2012-09-06 18:13:18.183092471 -0400 @@ -144,7 +144,7 @@ * here's where to twiddle it. You can also override this at runtime * with the postmaster's -k switch. */ -#define DEFAULT_PGSOCKET_DIR "/tmp" +#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql" /* * The random() function is expected to yield values between 0 and diff -Naur postgresql-9.2.0.sockets/src/test/regress/pg_regress.c postgresql-9.2.0/src/test/regress/pg_regress.c --- postgresql-9.2.0.sockets/src/test/regress/pg_regress.c 2012-09-06 17:26:17.000000000 -0400 +++ postgresql-9.2.0/src/test/regress/pg_regress.c 2012-09-06 18:13:18.184092537 -0400 @@ -772,7 +772,7 @@ if (hostname != NULL) doputenv("PGHOST", hostname); else - unsetenv("PGHOST"); + doputenv("PGHOST", "/tmp"); unsetenv("PGHOSTADDR"); if (port != -1) { @@ -2233,7 +2233,7 @@ */ header(_("starting postmaster")); snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE, + SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" -c \"unix_socket_directories=/tmp\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE, bindir, temp_install, debug ? " -d 5" : "", hostname ? hostname : "",