diff --git a/src/bin/pg_probackup/configure.cpp b/src/bin/pg_probackup/configure.cpp index 24f977690..bf49c5c42 100644 --- a/src/bin/pg_probackup/configure.cpp +++ b/src/bin/pg_probackup/configure.cpp @@ -215,6 +215,11 @@ ConfigOption instance_options[] = &instance_config.remote.ssh_config, SOURCE_CMD, (OptionSource)0, OPTION_REMOTE_GROUP, 0, option_get_value }, + { + 's', 231, "remote-libpath", + &instance_config.remote.libpath, SOURCE_CMD, (OptionSource)0, + OPTION_REMOTE_GROUP, 0, option_get_value + }, { 0 } }; @@ -506,6 +511,10 @@ readInstanceConfigFile(const char *instance_name) 's', 230, "ssh-config", &instance->remote.ssh_config, SOURCE_CMD, (OptionSource)0, OPTION_REMOTE_GROUP, 0, option_get_value }, + { + 's', 231, "remote-libpath", &instance->remote.libpath, SOURCE_CMD, (OptionSource)0, + OPTION_REMOTE_GROUP, 0, option_get_value + }, { 0 } }; diff --git a/src/bin/pg_probackup/init.cpp b/src/bin/pg_probackup/init.cpp index a211152e1..2fb8fd8e1 100644 --- a/src/bin/pg_probackup/init.cpp +++ b/src/bin/pg_probackup/init.cpp @@ -116,6 +116,8 @@ do_add_instance(InstanceConfig *instance) SOURCE_DEFAULT); config_set_opt(instance_options, &instance_config.remote.path, SOURCE_DEFAULT); + config_set_opt(instance_options, &instance_config.remote.libpath, + SOURCE_DEFAULT); config_set_opt(instance_options, &instance_config.remote.user, SOURCE_DEFAULT); config_set_opt(instance_options, &instance_config.remote.ssh_options, diff --git a/src/bin/pg_probackup/remote.cpp b/src/bin/pg_probackup/remote.cpp index 95937cce3..0db9ea33e 100644 --- a/src/bin/pg_probackup/remote.cpp +++ b/src/bin/pg_probackup/remote.cpp @@ -113,6 +113,7 @@ bool launch_agent(void) { char cmd[MAX_CMDLINE_LENGTH]; char* ssh_argv[MAX_CMDLINE_OPTIONS]; + char libenv[MAX_CMDLINE_LENGTH] = {0}; int ssh_argc; int outfd[2]; int infd[2]; @@ -156,6 +157,19 @@ bool launch_agent(void) ssh_argv[ssh_argc++] = (char *)cmd; ssh_argv[ssh_argc] = NULL; + if (instance_config.remote.libpath) + { +#ifdef WIN32 + rc = snprintf_s(libenv, sizeof(libenv), sizeof(libenv) - 1, "set LD_LIBRARY_PATH=%s &&", + instance_config.remote.libpath); + securec_check_ss_c(rc, "\0", "\0"); +#else + rc = snprintf_s(libenv, sizeof(libenv), sizeof(libenv) - 1, "export LD_LIBRARY_PATH=%s &&", + instance_config.remote.libpath); + securec_check_ss_c(rc, "\0", "\0"); +#endif + } + if (instance_config.remote.path) { char const* probackup = PROGRAM_NAME_FULL; @@ -172,27 +186,27 @@ bool launch_agent(void) } if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL)) { - rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s\\%s\" agent", - instance_config.remote.path, probackup); + rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s %s\\%s\" agent", + libenv, instance_config.remote.path, probackup); securec_check_ss_c(rc, "\0", "\0"); } else { - rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s\\%s agent", - instance_config.remote.path, probackup); + rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s %s\\%s agent", + libenv, instance_config.remote.path, probackup); securec_check_ss_c(rc, "\0", "\0"); } #else if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL)) { - rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s/%s\" agent", - instance_config.remote.path, probackup); + rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "\"%s %s/%s\" agent", + libenv, instance_config.remote.path, probackup); securec_check_ss_c(rc, "\0", "\0"); } else { - rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s/%s agent", - instance_config.remote.path, probackup); + rc = snprintf_s(cmd, sizeof(cmd), sizeof(cmd) - 1, "%s %s/%s agent", + libenv, instance_config.remote.path, probackup); securec_check_ss_c(rc, "\0", "\0"); } #endif diff --git a/src/bin/pg_probackup/remote.h b/src/bin/pg_probackup/remote.h index dbc250755..81c2b1114 100644 --- a/src/bin/pg_probackup/remote.h +++ b/src/bin/pg_probackup/remote.h @@ -16,6 +16,7 @@ typedef struct RemoteConfig char* host; char* port; char* path; + char* libpath; char* user; char *ssh_config; char *ssh_options;