Add an option to suppress passwords in recovery.conf/primary_conninfo

This commit is contained in:
Abhijit Menon-Sen
2016-12-07 11:49:15 +05:30
committed by Ian Barwick
parent a21b16f960
commit 402e02f4b7
2 changed files with 10 additions and 1 deletions

View File

@@ -242,6 +242,7 @@ main(int argc, char **argv)
{"local-port", required_argument, NULL, 'l'},
{"initdb-no-pwprompt", no_argument, NULL, OPT_INITDB_NO_PWPROMPT},
{"ignore-external-config-files", no_argument, NULL, OPT_IGNORE_EXTERNAL_CONFIG_FILES},
{"no-conninfo-password", no_argument, NULL, OPT_NO_CONNINFO_PASSWORD},
{NULL, 0, NULL, 0}
};
@@ -528,6 +529,9 @@ main(int argc, char **argv)
case OPT_UPSTREAM_CONNINFO:
strncpy(runtime_options.upstream_conninfo, optarg, MAXLEN);
break;
case OPT_NO_CONNINFO_PASSWORD:
runtime_options.no_conninfo_password = true;
break;
case OPT_REGISTER_WAIT:
runtime_options.wait_register_sync = true;
if (optarg != NULL)
@@ -6361,6 +6365,7 @@ do_help(void)
printf(_(" --no-upstream-connection (standby clone) when using Barman, do not connect to upstream node\n"));
printf(_(" --upstream-conninfo (standby clone) 'primary_conninfo' value to write in recovery.conf\n" \
" when the intended upstream server does not yet exist\n"));
printf(_(" --no-conninfo-password (standby clone) do not write passwords into primary_conninfo\n"));
printf(_(" --without-barman (standby clone) do not use Barman even if configured\n"));
printf(_(" --recovery-min-apply-delay=VALUE (standby clone, follow) set recovery_min_apply_delay\n" \
" in recovery.conf (PostgreSQL 9.4 and later)\n"));
@@ -6543,6 +6548,8 @@ write_primary_conninfo(char *line, t_conninfo_param_list *param_list)
*/
if (strcmp(param_list->keywords[c], "dbname") == 0 ||
strcmp(param_list->keywords[c], "replication") == 0 ||
(runtime_options.no_conninfo_password &&
strcmp(param_list->keywords[c], "password") == 0) ||
(param_list->values[c] == NULL) ||
(param_list->values[c] != NULL && param_list->values[c][0] == '\0'))
continue;