summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Vondra2017-07-05 23:30:04 +0000
committerTomas Vondra2017-07-05 23:30:04 +0000
commitce532e6cc507322c4909f641d57e6ba1dc9c858a (patch)
tree4285bbab85ed2283d91ca903033a8690a659da88
parent42bbbf4b165de49a25bdfd44f7a6fdcd143f57c7 (diff)
Correct simple_prompt calls in pgxc_ctl
Commit 9daec77e165de461fca9d5bc3ece86a91aba5804 simplified usage of simple_prompt, so that it's not necessary to free the string etc. This applies the call chage to pgxc_ctl.
-rw-r--r--contrib/pgxc_clean/pgxc_clean.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/contrib/pgxc_clean/pgxc_clean.c b/contrib/pgxc_clean/pgxc_clean.c
index d96cdf85fd..f6f3b98131 100644
--- a/contrib/pgxc_clean/pgxc_clean.c
+++ b/contrib/pgxc_clean/pgxc_clean.c
@@ -92,7 +92,8 @@ int pgxc_clean_node_count;
database_info *head_database_info;
database_info *last_database_info;
-static char *password = NULL;
+static bool have_password = false;
+static char password[100];
static char password_prompt[256];
/* Funcs */
@@ -198,7 +199,10 @@ int main(int argc, char *argv[])
else
sprintf(password_prompt, "Password for user %s: ", username);
if (try_password_opt == TRI_YES)
- password = simple_prompt(password_prompt, 100, false);
+ {
+ simple_prompt(password_prompt, password, sizeof(password), false);
+ have_password = true;
+ }
if (verbose_opt)
{
@@ -624,11 +628,12 @@ loginDatabase(char *host, int port, char *user, char *password, char *dbname, co
if (PQstatus(coord_conn) == CONNECTION_BAD &&
PQconnectionNeedsPassword(coord_conn) &&
- password == NULL &&
+ !have_password &&
try_password_opt != TRI_NO)
{
PQfinish(coord_conn);
- password = simple_prompt(password_prompt, 100, false);
+ simple_prompt(password_prompt, password, sizeof(password), false);
+ have_password = true;
new_pass = true;
}
} while (new_pass);