Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3b8d5d

Browse files
committed
bugfix: do not use find_my_exec(), because it is relying on PATH, which can be unavailable. More details:#39
1 parent16dca32 commitb3b8d5d

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

‎src/pg_probackup.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
#include"utils/thread.h"
2121
#include<time.h>
2222

23-
constchar*PROGRAM_URL="https://github.com/postgrespro/pg_probackup";
24-
constchar*PROGRAM_EMAIL="https://github.com/postgrespro/pg_probackup/issues";
25-
constchar*PROGRAM_FULL_PATH=NULL;
23+
constchar*PROGRAM_NAME=NULL;
24+
constchar*PROGRAM_FULL_PATH=NULL;
25+
constchar*PROGRAM_URL="https://github.com/postgrespro/pg_probackup";
26+
constchar*PROGRAM_EMAIL="https://github.com/postgrespro/pg_probackup/issues";
2627

2728
typedefenumProbackupSubcmd
2829
{
@@ -245,13 +246,7 @@ main(int argc, char *argv[])
245246
PROGRAM_NAME=get_progname(argv[0]);
246247
PROGRAM_FULL_PATH=palloc0(MAXPGPATH);
247248

248-
if (find_my_exec(argv[0],(char*)PROGRAM_FULL_PATH)<0)
249-
{
250-
fprintf(stderr,_("%s: could not find own program executable\n"),PROGRAM_NAME);
251-
exit(1);
252-
}
253-
254-
set_pglocale_pgservice(argv[0],"pgscripts");
249+
//set_pglocale_pgservice(argv[0], "pgscripts");
255250

256251
#ifPG_VERSION_NUM >=110000
257252
/*
@@ -514,6 +509,15 @@ main(int argc, char *argv[])
514509
command=NULL;
515510
}
516511

512+
/* For archive-push and archive-get skip full path lookup */
513+
if ((backup_subcmd!=ARCHIVE_GET_CMD&&
514+
backup_subcmd!=ARCHIVE_PUSH_CMD)&&
515+
(find_my_exec(argv[0],(char*)PROGRAM_FULL_PATH)<0))
516+
{
517+
PROGRAM_FULL_PATH=NULL;
518+
elog(WARNING,"%s: could not find a full path to executable",PROGRAM_NAME);
519+
}
520+
517521
/*
518522
* We have read pgdata path from command line or from configuration file.
519523
* Ensure that pgdata is an absolute path.

‎src/pg_probackup.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434

3535
#include"datapagemap.h"
3636

37+
/* pgut client variables and full path */
38+
externconstchar*PROGRAM_NAME;
39+
externconstchar*PROGRAM_FULL_PATH;
40+
externconstchar*PROGRAM_URL;
41+
externconstchar*PROGRAM_EMAIL;
42+
3743
/* Directory/File names */
3844
#defineDATABASE_DIR"database"
3945
#defineBACKUPS_DIR"backups"

‎src/restore.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ create_recovery_conf(time_t backup_id,
882882

883883
fio_fprintf(fp,"restore_command = '%s archive-get -B %s --instance %s "
884884
"--wal-file-path %%p --wal-file-name %%f'\n",
885-
PROGRAM_FULL_PATH,backup_path,instance_name);
885+
PROGRAM_FULL_PATH ?PROGRAM_FULL_PATH :PROGRAM_NAME,
886+
backup_path,instance_name);
886887

887888
/*
888889
* We've already checked that only one of the four following mutually

‎src/utils/pgut.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*-------------------------------------------------------------------------
99
*/
1010

11+
#include"pg_probackup.h"
1112
#include"postgres_fe.h"
1213

1314
#include"getopt_long.h"
@@ -22,8 +23,6 @@
2223
#include"file.h"
2324

2425

25-
constchar*PROGRAM_NAME="pg_probackup";
26-
2726
staticchar*password=NULL;
2827
boolprompt_password= true;
2928
boolforce_password= false;

‎src/utils/pgut.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@
1616

1717
typedefvoid (*pgut_atexit_callback)(boolfatal,void*userdata);
1818

19-
/*
20-
* pgut client variables and functions
21-
*/
22-
externconstchar*PROGRAM_NAME;
23-
externconstchar*PROGRAM_FULL_PATH;
24-
externconstchar*PROGRAM_VERSION;
25-
externconstchar*PROGRAM_URL;
26-
externconstchar*PROGRAM_EMAIL;
27-
2819
externvoidpgut_help(booldetails);
2920

3021
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp