From dfb796ca8fc96f4f80844241a04c1ca92f131a3a Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Thu, 31 Aug 2017 09:55:32 +0900 Subject: [PATCH] Check config file *before* checking command line parameters Validity of command line parameters may depened on settings in the configuration file. --- repmgr-client.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/repmgr-client.c b/repmgr-client.c index fb1bf316..67c31934 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -847,6 +847,18 @@ main(int argc, char **argv) item_list_append(&cli_errors, too_many_args.data); } + + /* + * The configuration file is not required for some actions (e.g. 'standby clone'), + * however if available we'll parse it anyway for options like 'log_level', + * 'use_replication_slots' etc. + */ + load_config(runtime_options.config_file, + runtime_options.verbose, + runtime_options.terse, + &config_file_options, + argv[0]); + check_cli_parameters(action); /* @@ -885,16 +897,6 @@ main(int argc, char **argv) runtime_options.output_mode = OM_OPTFORMAT; } - /* - * The configuration file is not required for some actions (e.g. 'standby clone'), - * however if available we'll parse it anyway for options like 'log_level', - * 'use_replication_slots' etc. - */ - load_config(runtime_options.config_file, - runtime_options.verbose, - runtime_options.terse, - &config_file_options, - argv[0]); /* check for conflicts between runtime options and configuration file */ @@ -2398,7 +2400,7 @@ get_standby_clone_mode(void) { standy_clone_mode mode; - if (strcmp(config_file_options.barman_host, "") != 0 && ! runtime_options.without_barman) + if (*config_file_options.barman_host != '\0' && runtime_options.without_barman == false) mode = barman; else mode = pg_basebackup;