repmgr: set default user for -R/--remote-user

This commit is contained in:
Ian Barwick
2016-07-18 14:30:30 +09:00
parent eba0f1d7ae
commit e8fcc3d7a6

View File

@@ -285,6 +285,20 @@ main(int argc, char **argv)
PQconninfoFree(defs);
/* set default user for -R/--remote-user */
{
struct passwd *pw = NULL;
pw = getpwuid(geteuid());
if (pw == NULL)
{
fprintf(stderr, _("could not get current user name: %s\n"), strerror(errno));
exit(ERR_BAD_CONFIG);
}
strncpy(runtime_options.username, pw->pw_name, MAXLEN);
}
/*
* Though libpq will default to the username as dbname, PQconndefaults()
@@ -4321,7 +4335,7 @@ do_help(void)
printf(_(" -D, --data-dir=DIR local directory where the files will be\n" \
" copied to\n"));
printf(_(" -f, --config-file=PATH path to the configuration file\n"));
printf(_(" -R, --remote-user=USERNAME database server username for rsync\n"));
printf(_(" -R, --remote-user=USERNAME database server username for rsync (default: \"%s\")\n"), runtime_options.username);
printf(_(" -F, --force force potentially dangerous operations to happen\n"));
printf(_(" --check-upstream-config verify upstream server configuration\n"));
printf(_("\n"));