mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06:29 +00:00
node service: enable provision of the -S/--superuser option
This is required to be able to execute a CHECKPOINT if the normal repmgr user is not a superuser.
This commit is contained in:
@@ -2028,10 +2028,44 @@ do_node_service(void)
|
||||
{
|
||||
PGconn *conn = NULL;
|
||||
|
||||
if (strlen(config_file_options.conninfo))
|
||||
conn = establish_db_connection(config_file_options.conninfo, true);
|
||||
if (config_file_options.conninfo[0] != '\0')
|
||||
{
|
||||
t_conninfo_param_list node_conninfo = T_CONNINFO_PARAM_LIST_INITIALIZER;
|
||||
char *errmsg = NULL;
|
||||
bool parse_success = false;
|
||||
|
||||
initialize_conninfo_params(&node_conninfo, false);
|
||||
|
||||
parse_success = parse_conninfo_string(config_file_options.conninfo,
|
||||
&node_conninfo,
|
||||
&errmsg, false);
|
||||
|
||||
if (parse_success == false)
|
||||
{
|
||||
log_error(_("unable to parse conninfo string \"%s\" for local node"),
|
||||
config_file_options.conninfo);
|
||||
log_detail("%s", errmsg);
|
||||
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
/*
|
||||
* If --superuser option provided, attempt to connect as the specified user
|
||||
*/
|
||||
|
||||
if (runtime_options.superuser[0] != '\0')
|
||||
{
|
||||
param_set(&node_conninfo,
|
||||
"user",
|
||||
runtime_options.superuser);
|
||||
}
|
||||
|
||||
conn = establish_db_connection_by_params(&node_conninfo, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||
}
|
||||
|
||||
if (is_superuser_connection(conn, NULL) == false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user