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