From: Heikki Linnakangas Date: Wed, 30 Apr 2014 07:34:15 +0000 (+0300) Subject: Add missing SYSTEMQUOTEs X-Git-Tag: REL9_2_9~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2558e016ea389501dc0aa96aa9db632d4649d87;p=postgresql Add missing SYSTEMQUOTEs Some popen() calls were missing SYSTEMQUOTEs, which caused initdb and pg_upgrade to fail on Windows, if the installation path contained both spaces and @ signs. Patch by Nikhil Deshpande. Backpatch to all supported versions. --- diff --git a/contrib/pg_upgrade/check.c b/contrib/pg_upgrade/check.c index 32b9bb998a..9cc0a10673 100644 --- a/contrib/pg_upgrade/check.c +++ b/contrib/pg_upgrade/check.c @@ -936,7 +936,7 @@ get_bin_version(ClusterInfo *cluster) int pre_dot, post_dot; - snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir); + snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s/pg_ctl\" --version" SYSTEMQUOTE, cluster->bindir); if ((output = popen(cmd, "r")) == NULL || fgets(cmd_output, sizeof(cmd_output), output) == NULL) diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index cb0f021aac..13f093bb49 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1247,7 +1247,7 @@ bootstrap_template1(void) unsetenv("PGCLIENTENCODING"); snprintf(cmd, sizeof(cmd), - "\"%s\" --boot -x1 %s %s", + SYSTEMQUOTE "\"%s\" --boot -x1 %s %s" SYSTEMQUOTE, backend_exec, boot_options, talkargs); PG_CMD_OPEN; @@ -1286,7 +1286,7 @@ setup_auth(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1364,7 +1364,7 @@ get_set_pwd(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1464,7 +1464,7 @@ setup_depend(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1497,7 +1497,7 @@ setup_sysviews(void) * We use -j here to avoid backslashing stuff in system_views.sql */ snprintf(cmd, sizeof(cmd), - "\"%s\" %s -j template1 >%s", + SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1528,7 +1528,7 @@ setup_description(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1635,7 +1635,7 @@ setup_collation(void) #if defined(HAVE_LOCALE_T) && !defined(WIN32) snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1774,7 +1774,7 @@ setup_conversion(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1812,7 +1812,7 @@ setup_dictionary(void) * We use -j here to avoid backslashing stuff */ snprintf(cmd, sizeof(cmd), - "\"%s\" %s -j template1 >%s", + SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1863,7 +1863,7 @@ setup_privileges(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1926,7 +1926,7 @@ setup_schema(void) * We use -j here to avoid backslashing stuff in information_schema.sql */ snprintf(cmd, sizeof(cmd), - "\"%s\" %s -j template1 >%s", + SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1943,7 +1943,7 @@ setup_schema(void) PG_CMD_CLOSE; snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -1977,7 +1977,7 @@ load_plpgsql(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -2002,7 +2002,7 @@ vacuum_db(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -2058,7 +2058,7 @@ make_template0(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL); @@ -2090,7 +2090,7 @@ make_postgres(void) fflush(stdout); snprintf(cmd, sizeof(cmd), - "\"%s\" %s template1 >%s", + SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE, backend_exec, backend_options, DEVNULL);