diff --git a/src/pg_probackup.c b/src/pg_probackup.c index 2cf6e0ed..b32f72af 100644 --- a/src/pg_probackup.c +++ b/src/pg_probackup.c @@ -20,7 +20,9 @@ #include "utils/thread.h" #include -const char *PROGRAM_NAME = NULL; +const char *PROGRAM_NAME = NULL; /* PROGRAM_NAME_FULL without .exe suffix + * if any */ +const char *PROGRAM_NAME_FULL = NULL; const char *PROGRAM_FULL_PATH = NULL; const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup"; const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues"; @@ -45,8 +47,6 @@ typedef enum ProbackupSubcmd } ProbackupSubcmd; -char *pg_probackup; /* Program name (argv[0]) */ - /* directory options */ char *backup_path = NULL; /* @@ -235,7 +235,7 @@ main(int argc, char *argv[]) struct stat stat_buf; int rc; - pg_probackup = argv[0]; + PROGRAM_NAME_FULL = argv[0]; /* Initialize current backup */ pgBackupInit(¤t); diff --git a/src/pg_probackup.h b/src/pg_probackup.h index 53ae515e..42002829 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -36,6 +36,7 @@ /* pgut client variables and full path */ extern const char *PROGRAM_NAME; +extern const char *PROGRAM_NAME_FULL; extern const char *PROGRAM_FULL_PATH; extern const char *PROGRAM_URL; extern const char *PROGRAM_EMAIL; @@ -412,7 +413,6 @@ typedef struct BackupPageHeader #define IsSshProtocol() (instance_config.remote.host && strcmp(instance_config.remote.proto, "ssh") == 0) /* directory options */ -extern char *pg_probackup; extern char *backup_path; extern char backup_instance_path[MAXPGPATH]; extern char arclog_path[MAXPGPATH]; @@ -472,7 +472,7 @@ extern const char *pgdata_exclude_dir[]; /* in backup.c */ extern int do_backup(time_t start_time, bool no_validate); -extern void do_checkdb(bool need_amcheck, ConnectionOptions conn_opt, +extern void do_checkdb(bool need_amcheck, ConnectionOptions conn_opt, char *pgdata); extern BackupMode parse_backup_mode(const char *value); extern const char *deparse_backup_mode(BackupMode mode); diff --git a/src/utils/remote.c b/src/utils/remote.c index bf0bac10..681d8fb8 100644 --- a/src/utils/remote.c +++ b/src/utils/remote.c @@ -91,7 +91,7 @@ bool launch_agent(void) ssh_argc = 0; #ifdef WIN32 - ssh_argv[ssh_argc++] = pg_probackup; + ssh_argv[ssh_argc++] = PROGRAM_NAME_FULL; ssh_argv[ssh_argc++] = "ssh"; ssh_argc += 2; /* reserve space for pipe descriptors */ #endif @@ -129,7 +129,7 @@ bool launch_agent(void) if (instance_config.remote.path) { - char const* probackup = pg_probackup; + char const* probackup = PROGRAM_NAME_FULL; char* sep = strrchr(probackup, '/'); if (sep != NULL) { probackup = sep + 1; @@ -141,14 +141,14 @@ bool launch_agent(void) probackup = sep + 1; } } - if (needs_quotes(instance_config.remote.path) || needs_quotes(pg_probackup)) + if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL)) snprintf(cmd, sizeof(cmd), "\"%s\\%s\" agent %s", instance_config.remote.path, probackup, PROGRAM_VERSION); else snprintf(cmd, sizeof(cmd), "%s\\%s agent %s", instance_config.remote.path, probackup, PROGRAM_VERSION); #else - if (needs_quotes(instance_config.remote.path) || needs_quotes(pg_probackup)) + if (needs_quotes(instance_config.remote.path) || needs_quotes(PROGRAM_NAME_FULL)) snprintf(cmd, sizeof(cmd), "\"%s/%s\" agent %s", instance_config.remote.path, probackup, PROGRAM_VERSION); else @@ -156,10 +156,10 @@ bool launch_agent(void) instance_config.remote.path, probackup, PROGRAM_VERSION); #endif } else { - if (needs_quotes(pg_probackup)) - snprintf(cmd, sizeof(cmd), "\"%s\" agent %s", pg_probackup, PROGRAM_VERSION); + if (needs_quotes(PROGRAM_NAME_FULL)) + snprintf(cmd, sizeof(cmd), "\"%s\" agent %s", PROGRAM_NAME_FULL, PROGRAM_VERSION); else - snprintf(cmd, sizeof(cmd), "%s agent %s", pg_probackup, PROGRAM_VERSION); + snprintf(cmd, sizeof(cmd), "%s agent %s", PROGRAM_NAME_FULL, PROGRAM_VERSION); } #ifdef WIN32