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

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