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