Compare commits

...

5 Commits

Author SHA1 Message Date
Jaime Casanova
e479ef4bd1 Add "--checksum" in rsync when using "--force"
If the user don't put that option in rsync_options using of "--force"
could be unsafe.
While the probability of failures because of this are low they aren't
zero.
2015-02-10 20:44:34 -05:00
Jaime Casanova
6390a41953 Options -F -I -v doesn't accept arguments, which means that on
getopt_long shouldn't be marked with the colon (:) character.

This has been wrong since day one, so backpatching all the way until
1.1
2013-01-13 16:40:08 -05:00
Jaime Casanova
d7d91e1c12 Formatting using astyle 2012-12-11 11:54:35 -05:00
Jaime Casanova
d5ec394c54 Make repmgr compatible with FreeBSD.
We need to add an #include and make it use a different path for the
"true" binary.

Maybe we need to make this changes for all BSD systems but having no
evidence of that i prefer to make this only for systems with __FreeBSD__
2012-09-15 17:44:03 -05:00
Jaime Casanova
f6093386a8 When we have more command-line arguments than we should have we
need to show that last value and we should use only optind for that
instead of optind+1
2012-09-15 17:41:42 -05:00
3 changed files with 53 additions and 41 deletions

View File

@@ -28,6 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/wait.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@@ -125,7 +126,7 @@ main(int argc, char **argv)
} }
while ((c = getopt_long(argc, argv, "d:h:p:U:D:f:R:w:k:F:I:v", long_options, while ((c = getopt_long(argc, argv, "d:h:p:U:D:f:R:w:k:FIv", long_options,
&optindex)) != -1) &optindex)) != -1)
{ {
switch (c) switch (c)
@@ -255,7 +256,7 @@ main(int argc, char **argv)
break; break;
default: default:
log_err(_("%s: too many command-line arguments (first extra is \"%s\")\n"), log_err(_("%s: too many command-line arguments (first extra is \"%s\")\n"),
progname, argv[optind + 1]); progname, argv[optind]);
usage(); usage();
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
@@ -1603,11 +1604,18 @@ test_ssh_connection(char *host, char *remote_user)
char script[MAXLEN]; char script[MAXLEN];
int r; int r;
/* On some OS, true is located in a different place than in Linux */
#ifdef __FreeBSD__
#define TRUEBIN_PATH "/usr/bin/true"
#else
#define TRUEBIN_PATH "/bin/true"
#endif
/* Check if we have ssh connectivity to host before trying to rsync */ /* Check if we have ssh connectivity to host before trying to rsync */
if (!remote_user[0]) if (!remote_user[0])
maxlen_snprintf(script, "ssh -o Batchmode=yes %s /bin/true", host); maxlen_snprintf(script, "ssh -o Batchmode=yes %s %s", host, TRUEBIN_PATH);
else else
maxlen_snprintf(script, "ssh -o Batchmode=yes %s -l %s /bin/true", host, remote_user); maxlen_snprintf(script, "ssh -o Batchmode=yes %s -l %s %s", host, remote_user, TRUEBIN_PATH);
log_debug(_("command is: %s"), script); log_debug(_("command is: %s"), script);
r = system(script); r = system(script);
@@ -1633,7 +1641,7 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
maxlen_snprintf(rsync_flags, "%s", options.rsync_options); maxlen_snprintf(rsync_flags, "%s", options.rsync_options);
if (runtime_options.force) if (runtime_options.force)
strcat(rsync_flags, " --delete"); strcat(rsync_flags, " --delete --checksum");
if (!remote_user[0]) if (!remote_user[0])
{ {
@@ -1832,20 +1840,24 @@ write_primary_conninfo(char* line)
/* Environment variable for password (UGLY, please use .pgpass!) */ /* Environment variable for password (UGLY, please use .pgpass!) */
const char *password = getenv("PGPASSWORD"); const char *password = getenv("PGPASSWORD");
if (password != NULL) { if (password != NULL)
{
maxlen_snprintf(password_buf, " password=%s", password); maxlen_snprintf(password_buf, " password=%s", password);
} }
else if (require_password) { else if (require_password)
{
log_err(_("%s: PGPASSWORD not set, but having one is required\n"), log_err(_("%s: PGPASSWORD not set, but having one is required\n"),
progname); progname);
exit(ERR_BAD_PASSWORD); exit(ERR_BAD_PASSWORD);
} }
if (runtime_options.host[0]) { if (runtime_options.host[0])
{
maxlen_snprintf(host_buf, " host=%s", runtime_options.host); maxlen_snprintf(host_buf, " host=%s", runtime_options.host);
} }
if (runtime_options.username[0]) { if (runtime_options.username[0])
{
maxlen_snprintf(user_buf, " user=%s", runtime_options.username); maxlen_snprintf(user_buf, " user=%s", runtime_options.username);
} }