27aa74
Change the built-in default socket directory to be /var/run/postgresql.
27aa74
For backwards compatibility with (probably non-libpq-based) clients that
27aa74
might still expect to find the socket in /tmp, also create a socket in
27aa74
/tmp.  This is to resolve communication problems with clients operating
27aa74
under systemd's PrivateTmp environment, which won't be using the same
27aa74
global /tmp directory as the server; see bug #825448.
27aa74
27aa74
Note that we apply the socket directory change at the level of the
27aa74
hard-wired defaults in the C code, not by just twiddling the setting in
27aa74
postgresql.conf.sample; this is so that the change will take effect on
27aa74
server package update, without requiring any existing postgresql.conf
27aa74
to be updated.  (Of course, a user who dislikes this behavior can still
27aa74
override it via postgresql.conf.)
27aa74
27aa74
This patch must be applied after postgresql-multi-sockets.patch, at
27aa74
least until 9.3 when that will be part of the upstream package.
27aa74
27aa74
27aa74
diff -Naur postgresql-9.2.2.sockets/contrib/pg_upgrade/test.sh postgresql-9.2.2/contrib/pg_upgrade/test.sh
27aa74
--- postgresql-9.2.2.sockets/contrib/pg_upgrade/test.sh	2013-01-03 17:33:45.581567466 -0500
27aa74
+++ postgresql-9.2.2/contrib/pg_upgrade/test.sh	2013-01-03 17:40:22.923364917 -0500
27aa74
@@ -78,6 +78,12 @@
27aa74
 rm -rf "$logdir"
27aa74
 mkdir "$logdir"
27aa74
 
27aa74
+# we want the Unix sockets in $temp_root
27aa74
+PGHOST=$temp_root
27aa74
+export PGHOST
27aa74
+
27aa74
+POSTMASTER_OPTS="$POSTMASTER_OPTS -c unix_socket_directories='$PGHOST'"
27aa74
+
27aa74
 # enable echo so the user can see what is being executed
27aa74
 set -x
27aa74
 
27aa74
diff -Naur postgresql-9.2.2.sockets/src/backend/utils/misc/guc.c postgresql-9.2.2/src/backend/utils/misc/guc.c
27aa74
--- postgresql-9.2.2.sockets/src/backend/utils/misc/guc.c	2013-01-03 17:37:56.632977951 -0500
27aa74
+++ postgresql-9.2.2/src/backend/utils/misc/guc.c	2013-01-03 17:38:30.183271588 -0500
27aa74
@@ -2901,7 +2901,7 @@
27aa74
 		},
27aa74
 		&Unix_socket_directories,
27aa74
 #ifdef HAVE_UNIX_SOCKETS
27aa74
-		DEFAULT_PGSOCKET_DIR,
27aa74
+		DEFAULT_PGSOCKET_DIR ", /tmp",
27aa74
 #else
27aa74
 		"",
27aa74
 #endif
27aa74
diff -Naur postgresql-9.2.2.sockets/src/bin/initdb/initdb.c postgresql-9.2.2/src/bin/initdb/initdb.c
27aa74
--- postgresql-9.2.2.sockets/src/bin/initdb/initdb.c	2013-01-03 17:37:56.633977974 -0500
27aa74
+++ postgresql-9.2.2/src/bin/initdb/initdb.c	2013-01-03 17:38:30.185271611 -0500
27aa74
@@ -1007,7 +1007,7 @@
27aa74
 
27aa74
 #ifdef HAVE_UNIX_SOCKETS
27aa74
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
27aa74
-			 DEFAULT_PGSOCKET_DIR);
27aa74
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
27aa74
 #else
27aa74
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
27aa74
 #endif
27aa74
diff -Naur postgresql-9.2.2.sockets/src/include/pg_config_manual.h postgresql-9.2.2/src/include/pg_config_manual.h
27aa74
--- postgresql-9.2.2.sockets/src/include/pg_config_manual.h	2012-12-03 15:16:10.000000000 -0500
27aa74
+++ postgresql-9.2.2/src/include/pg_config_manual.h	2013-01-03 17:38:30.185271611 -0500
27aa74
@@ -144,7 +144,7 @@
27aa74
  * here's where to twiddle it.  You can also override this at runtime
27aa74
  * with the postmaster's -k switch.
27aa74
  */
27aa74
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
27aa74
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
27aa74
 
27aa74
 /*
27aa74
  * The random() function is expected to yield values between 0 and
27aa74
diff -Naur postgresql-9.2.2.sockets/src/test/regress/pg_regress.c postgresql-9.2.2/src/test/regress/pg_regress.c
27aa74
--- postgresql-9.2.2.sockets/src/test/regress/pg_regress.c	2012-12-03 15:16:10.000000000 -0500
27aa74
+++ postgresql-9.2.2/src/test/regress/pg_regress.c	2013-01-03 17:38:30.186271622 -0500
27aa74
@@ -772,7 +772,7 @@
27aa74
 		if (hostname != NULL)
27aa74
 			doputenv("PGHOST", hostname);
27aa74
 		else
27aa74
-			unsetenv("PGHOST");
27aa74
+			doputenv("PGHOST", "/tmp");
27aa74
 		unsetenv("PGHOSTADDR");
27aa74
 		if (port != -1)
27aa74
 		{
27aa74
@@ -2246,7 +2246,7 @@
27aa74
 		 */
27aa74
 		header(_("starting postmaster"));
27aa74
 		snprintf(buf, sizeof(buf),
27aa74
-				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
27aa74
+				 SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" -c \"unix_socket_directories=/tmp\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
27aa74
 				 bindir, temp_install,
27aa74
 				 debug ? " -d 5" : "",
27aa74
 				 hostname ? hostname : "",