Blame SOURCES/postgresql-var-run-socket.patch

582c4b
Change the built-in default socket directory to be /var/run/postgresql.
582c4b
For backwards compatibility with (probably non-libpq-based) clients that
582c4b
might still expect to find the socket in /tmp, also create a socket in
582c4b
/tmp.  This is to resolve communication problems with clients operating
582c4b
under systemd's PrivateTmp environment, which won't be using the same
582c4b
global /tmp directory as the server; see bug #825448.
582c4b
582c4b
Note that we apply the socket directory change at the level of the
582c4b
hard-wired defaults in the C code, not by just twiddling the setting in
582c4b
postgresql.conf.sample; this is so that the change will take effect on
582c4b
server package update, without requiring any existing postgresql.conf
582c4b
to be updated.  (Of course, a user who dislikes this behavior can still
582c4b
override it via postgresql.conf.)
582c4b
582c4b
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
582c4b
index 2b6527f..8e178d4 100644
582c4b
--- a/src/backend/utils/misc/guc.c
582c4b
+++ b/src/backend/utils/misc/guc.c
582c4b
@@ -2971,7 +2971,7 @@ static struct config_string ConfigureNamesString[] =
582c4b
 		},
582c4b
 		&Unix_socket_directories,
582c4b
 #ifdef HAVE_UNIX_SOCKETS
582c4b
-		DEFAULT_PGSOCKET_DIR,
582c4b
+		DEFAULT_PGSOCKET_DIR ", /tmp",
582c4b
 #else
582c4b
 		"",
582c4b
 #endif
582c4b
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
582c4b
index abf1586..8c01d48 100644
582c4b
--- a/src/bin/initdb/initdb.c
582c4b
+++ b/src/bin/initdb/initdb.c
582c4b
@@ -1204,7 +1204,7 @@ setup_config(void)
582c4b
 
582c4b
 #ifdef HAVE_UNIX_SOCKETS
582c4b
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
582c4b
-			 DEFAULT_PGSOCKET_DIR);
582c4b
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
582c4b
 #else
582c4b
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
582c4b
 #endif
582c4b
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
582c4b
index 24c5069..aeec705 100644
582c4b
--- a/src/include/pg_config_manual.h
582c4b
+++ b/src/include/pg_config_manual.h
582c4b
@@ -144,7 +144,7 @@
582c4b
  * here's where to twiddle it.  You can also override this at runtime
582c4b
  * with the postmaster's -k switch.
582c4b
  */
582c4b
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
582c4b
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
582c4b
 
582c4b
 /*
582c4b
  * The random() function is expected to yield values between 0 and