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

62d2ae
Change the built-in default socket directory to be /var/run/postgresql.
62d2ae
For backwards compatibility with (probably non-libpq-based) clients that
62d2ae
might still expect to find the socket in /tmp, also create a socket in
62d2ae
/tmp.  This is to resolve communication problems with clients operating
62d2ae
under systemd's PrivateTmp environment, which won't be using the same
62d2ae
global /tmp directory as the server; see bug #825448.
62d2ae
62d2ae
Note that we apply the socket directory change at the level of the
62d2ae
hard-wired defaults in the C code, not by just twiddling the setting in
62d2ae
postgresql.conf.sample; this is so that the change will take effect on
62d2ae
server package update, without requiring any existing postgresql.conf
62d2ae
to be updated.  (Of course, a user who dislikes this behavior can still
62d2ae
override it via postgresql.conf.)
62d2ae
62d2ae
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
62d2ae
index 9481f2d..75532c7 100644
62d2ae
--- a/src/backend/utils/misc/guc.c
62d2ae
+++ b/src/backend/utils/misc/guc.c
62d2ae
@@ -3196,7 +3196,7 @@ static struct config_string ConfigureNamesString[] =
62d2ae
 		},
62d2ae
 		&Unix_socket_directories,
62d2ae
 #ifdef HAVE_UNIX_SOCKETS
62d2ae
-		DEFAULT_PGSOCKET_DIR,
62d2ae
+		DEFAULT_PGSOCKET_DIR ", /tmp",
62d2ae
 #else
62d2ae
 		"",
62d2ae
 #endif
62d2ae
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
62d2ae
index feeff9e..3e3d784 100644
62d2ae
--- a/src/bin/initdb/initdb.c
62d2ae
+++ b/src/bin/initdb/initdb.c
62d2ae
@@ -1234,7 +1234,7 @@ setup_config(void)
62d2ae
 
62d2ae
 #ifdef HAVE_UNIX_SOCKETS
62d2ae
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = '%s'",
62d2ae
-			 DEFAULT_PGSOCKET_DIR);
62d2ae
+			 DEFAULT_PGSOCKET_DIR ", /tmp");
62d2ae
 #else
62d2ae
 	snprintf(repltok, sizeof(repltok), "#unix_socket_directories = ''");
62d2ae
 #endif
62d2ae
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
62d2ae
index e278fa0..9ee15d4 100644
62d2ae
--- a/src/include/pg_config_manual.h
62d2ae
+++ b/src/include/pg_config_manual.h
62d2ae
@@ -201,7 +201,7 @@
62d2ae
  * support them yet.
62d2ae
  */
62d2ae
 #ifndef WIN32
62d2ae
-#define DEFAULT_PGSOCKET_DIR  "/tmp"
62d2ae
+#define DEFAULT_PGSOCKET_DIR  "/var/run/postgresql"
62d2ae
 #else
62d2ae
 #define DEFAULT_PGSOCKET_DIR ""
62d2ae
 #endif