+diff -urpa postgresql-9.4.19.orig/contrib/pg_upgrade/option.c postgresql-9.4.19/contrib/pg_upgrade/option.c
+--- postgresql-9.4.19.orig/contrib/pg_upgrade/option.c 2018-08-23 18:44:23.000449908 +0000
++++ postgresql-9.4.19/contrib/pg_upgrade/option.c 2018-08-23 18:45:59.397448823 +0000
+@@ -422,6 +422,11 @@ get_sock_dir(ClusterInfo *cluster, bool
+ cluster->sockdir = pg_malloc(MAXPGPATH);
+ if (!getcwd(cluster->sockdir, MAXPGPATH))
+ pg_fatal("cannot find current directory\n");
++#ifndef UNIX_PATH_MAX
++#define UNIX_PATH_MAX 108
++#endif
++ if (strlen(cluster->sockdir) > UNIX_PATH_MAX - sizeof(".s.PGSQL.50432"))
++ strcpy(cluster->sockdir, "/tmp"); /* fall back to tmp */
+ }
+ else
+ {
+diff -urpa postgresql-9.4.19.orig/src/include/pg_config_manual.h postgresql-9.4.19/src/include/pg_config_manual.h
+--- postgresql-9.4.19.orig/src/include/pg_config_manual.h 2018-08-23 18:44:23.004449908 +0000
++++ postgresql-9.4.19/src/include/pg_config_manual.h 2018-08-23 18:46:23.657448550 +0000
+@@ -152,7 +152,7 @@
+ * here's where to twiddle it. You can also override this at runtime
+ * with the postmaster's -k switch.
+ */
+-#define DEFAULT_PGSOCKET_DIR "/tmp"
++#define DEFAULT_PGSOCKET_DIR "/var/run/postgresql"
+
+ /*
+ * The random() function is expected to yield values between 0 and