From 5e04ab6eaeaed8ea01bc806694dde533c0f943c8 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Thu, 19 Dec 2013 00:58:10 -0500 Subject: [PATCH] Add a ssh_options parameter to allow ssh checking to consider non-default values (ie: a different port) Patch by Jay Taylor --- config.c | 4 ++++ config.h | 1 + repmgr.c | 6 +++--- repmgr.conf.sample | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 7c4e4ca0..03b2e1c2 100644 --- a/config.c +++ b/config.c @@ -41,6 +41,7 @@ parse_config(const char *config_file, t_configuration_options *options) memset(options->promote_command, 0, sizeof(options->promote_command)); memset(options->follow_command, 0, sizeof(options->follow_command)); memset(options->rsync_options, 0, sizeof(options->rsync_options)); + memset(options->ssh_options, 0, sizeof(options->ssh_options)); /* if nothing has been provided defaults to 60 */ options->master_response_timeout = 60; @@ -78,6 +79,8 @@ parse_config(const char *config_file, t_configuration_options *options) strncpy (options->conninfo, value, MAXLEN); else if (strcmp(name, "rsync_options") == 0) strncpy (options->rsync_options, value, QUERY_STR_LEN); + else if (strcmp(name, "ssh_options") == 0) + strncpy (options->ssh_options, value, QUERY_STR_LEN); else if (strcmp(name, "loglevel") == 0) strncpy (options->loglevel, value, MAXLEN); else if (strcmp(name, "logfacility") == 0) @@ -283,6 +286,7 @@ reload_configuration(char *config_file, t_configuration_options *orig_options) strcpy(orig_options->promote_command, new_options.promote_command); strcpy(orig_options->follow_command, new_options.follow_command); strcpy(orig_options->rsync_options, new_options.rsync_options); + strcpy(orig_options->ssh_options, new_options.ssh_options); orig_options->master_response_timeout = new_options.master_response_timeout; orig_options->reconnect_attempts = new_options.reconnect_attempts; orig_options->reconnect_intvl = new_options.reconnect_intvl; diff --git a/config.h b/config.h index 4e4cdaf3..9e4d3c67 100644 --- a/config.h +++ b/config.h @@ -36,6 +36,7 @@ typedef struct char loglevel[MAXLEN]; char logfacility[MAXLEN]; char rsync_options[QUERY_STR_LEN]; + char ssh_options[QUERY_STR_LEN]; int master_response_timeout; int reconnect_attempts; int reconnect_intvl; diff --git a/repmgr.c b/repmgr.c index 111b4e5e..ea97358e 100644 --- a/repmgr.c +++ b/repmgr.c @@ -86,7 +86,7 @@ bool require_password = false; /* Initialization of runtime options */ t_runtime_options runtime_options = { "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, "", "", 0 }; -t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", -1 }; +t_configuration_options options = { "", -1, "", MANUAL_FAILOVER, -1, "", "", "", "", "", "", "", -1 }; static char *server_mode = NULL; static char *server_cmd = NULL; @@ -1786,9 +1786,9 @@ test_ssh_connection(char *host, char *remote_user) /* Check if we have ssh connectivity to host before trying to rsync */ if (!remote_user[0]) - maxlen_snprintf(script, "ssh -o Batchmode=yes %s %s", host, TRUEBIN_PATH); + maxlen_snprintf(script, "ssh -o Batchmode=yes %s %s %s", options.ssh_options, host, TRUEBIN_PATH); else - maxlen_snprintf(script, "ssh -o Batchmode=yes %s -l %s %s", host, remote_user, TRUEBIN_PATH); + maxlen_snprintf(script, "ssh -o Batchmode=yes %s %s -l %s %s", options.ssh_options, host, remote_user, TRUEBIN_PATH); log_debug(_("command is: %s"), script); r = system(script); diff --git a/repmgr.conf.sample b/repmgr.conf.sample index 9daaf3f4..86378b46 100644 --- a/repmgr.conf.sample +++ b/repmgr.conf.sample @@ -11,7 +11,8 @@ node_name=standby2 # Connection information conninfo='host=192.168.204.104' -rsync_options=--archive --checksum --compress --progress --rsh=ssh +rsync_options=--archive --checksum --compress --progress --rsh="ssh -o \"StrictHostKeyChecking no\"" +ssh_options=-o "StrictHostKeyChecking no" # How many seconds we wait for master response before declaring master failure master_response_timeout=60