summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2022-03-01 22:37:07 +0000
committerMichael Paquier2022-03-01 22:37:07 +0000
commitdc57366c583685c4b2901f2ba69943f596b974ec (patch)
treeb99f063a829919fb9efbecf7aac0b7ca6a7c681d
parent9028cce426ba6e08ee5ef8fcaedb2445e6c08c75 (diff)
Fix check for PGHOST[ADDR] in pg_upgrade with Windows and temporary paths
The checks currently done at the startup of pg_upgrade on PGHOST and PGHOSTADDR to avoid any attempts to access to an external cluster fail setting those parameters to Windows paths or even temporary paths prefixed by an '@', as it only considers as a valid path strings beginning with a slash. As mentioned by Andres, is_unixsock_path() is designed to detect such cases, so, like any other code paths dealing with the same problem (psql and libpq), use it rather than assuming that all valid paths are prefixed with just a slash. This issue has been found while testing the TAP tests of pg_upgrade through the CI on Windows. This is a bug, but nobody has complained about it since pg_upgrade exists so no backpatch is done, at least for now. Analyzed-by: Andres Freund, Michael Paquier Discussion: https://postgr.es/m/YeYj4DU5qY/[email protected]
-rw-r--r--src/bin/pg_upgrade/server.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c
index 7878d233de..265137e86b 100644
--- a/src/bin/pg_upgrade/server.c
+++ b/src/bin/pg_upgrade/server.c
@@ -11,6 +11,7 @@
#include "common/connect.h"
#include "fe_utils/string_utils.h"
+#include "libpq/pqcomm.h"
#include "pg_upgrade.h"
static PGconn *get_db_conn(ClusterInfo *cluster, const char *db_name);
@@ -368,7 +369,7 @@ check_pghost_envvar(void)
if (value && strlen(value) > 0 &&
/* check for 'local' host values */
(strcmp(value, "localhost") != 0 && strcmp(value, "127.0.0.1") != 0 &&
- strcmp(value, "::1") != 0 && value[0] != '/'))
+ strcmp(value, "::1") != 0 && !is_unixsock_path(value)))
pg_fatal("libpq environment variable %s has a non-local server value: %s\n",
option->envvar, value);
}