diff -urpa postgresql-9.3.24.orig/contrib/pg_upgrade/option.c postgresql-9.3.24/contrib/pg_upgrade/option.c --- postgresql-9.3.24.orig/contrib/pg_upgrade/option.c 2018-08-23 19:56:17.181401335 +0000 +++ postgresql-9.3.24/contrib/pg_upgrade/option.c 2018-08-23 19:59:38.729399066 +0000 @@ -411,6 +411,11 @@ get_sock_dir(ClusterInfo *cluster, bool cluster->sockdir = pg_malloc(MAXPGPATH); if (!getcwd(cluster->sockdir, MAXPGPATH)) pg_log(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.3.24.orig/src/include/pg_config_manual.h postgresql-9.3.24/src/include/pg_config_manual.h --- postgresql-9.3.24.orig/src/include/pg_config_manual.h 2018-08-23 19:56:17.195401335 +0000 +++ postgresql-9.3.24/src/include/pg_config_manual.h 2018-08-23 19:59:34.340399115 +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