Skip to content

Commit

Permalink
Add a ssh_options parameter to allow ssh checking
Browse files Browse the repository at this point in the history
to consider non-default values (ie: a different port)

Patch by Jay Taylor
  • Loading branch information
Jaime Casanova authored and Jaime Casanova committed Dec 19, 2013
1 parent a1f4285 commit 5e04ab6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions config.h
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions repmgr.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion repmgr.conf.sample
Expand Up @@ -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
Expand Down

0 comments on commit 5e04ab6

Please sign in to comment.