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