You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-06-20 01:17:49 +02:00
Fix issue where relative links in $PGDATA could be stored in the backup with the wrong path.
Relative link paths were being combined with the paths of previous links (relative or absolute) due to the $strPath variable being modified in the current iteration rather than simply being passed to the next level of recursion. This issue did not affect absolute links and relative tablespace links were caught by other checks, though the error was confusing. Reported by Cynthia Shang.
This commit is contained in:
@@ -15,6 +15,14 @@
|
||||
<release date="XXXX-XX-XX" version="2.05dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-bug-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix issue where <i>relative</i> links in <path>$PGDATA</path> could be stored in the backup with the wrong path. This issue did not affect absolute links and relative tablespace links were caught by other checks.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="douglas.j.hunley"/>
|
||||
|
||||
@@ -935,11 +935,9 @@ sub build
|
||||
$strFile = substr($strFile, length(MANIFEST_TARGET_PGDATA) + 1);
|
||||
}
|
||||
|
||||
$strPath = dirname("${strPath}/${strName}");
|
||||
|
||||
$self->build(
|
||||
$oStorageDbMaster, $strLinkDestination, undef, $bOnline, $hTablespaceMap, $hDatabaseMap, $rhExclude, $strFile,
|
||||
$bTablespace, $strPath, $strFilter, $iLevel + 1);
|
||||
$bTablespace, dirname("${strPath}/${strName}"), $strFilter, $iLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12339,11 +12339,9 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"$strFile = substr($strFile, length(MANIFEST_TARGET_PGDATA) + 1);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"$strPath = dirname(\"${strPath}/${strName}\");\n"
|
||||
"\n"
|
||||
"$self->build(\n"
|
||||
"$oStorageDbMaster, $strLinkDestination, undef, $bOnline, $hTablespaceMap, $hDatabaseMap, $rhExclude, $strFile,\n"
|
||||
"$bTablespace, $strPath, $strFilter, $iLevel + 1);\n"
|
||||
"$bTablespace, dirname(\"${strPath}/${strName}\"), $strFilter, $iLevel + 1);\n"
|
||||
"}\n"
|
||||
"}\n"
|
||||
"\n\n"
|
||||
|
||||
@@ -2416,9 +2416,9 @@ P00 DEBUG: Manifest->build: found tablespace 2 in offline mode
|
||||
P00 DEBUG: Storage::Local->manifest(): strPathExp = [TEST_PATH]/db-master/db/base
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [hash], strFilter = [TS_PATH-1], strLevel = pg_tblspc/1, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts1
|
||||
P00 DEBUG: Storage::Local->manifest(): strPathExp = [TEST_PATH]/db-master/db/tablespace/ts1
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [hash], strFilter = [TS_PATH-1], strLevel = pg_tblspc/11, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [hash], strFilter = [TS_PATH-1], strLevel = pg_tblspc/11, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Storage::Local->manifest(): strPathExp = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [hash], strFilter = [TS_PATH-1], strLevel = pg_tblspc/2, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc/pg_tblspc/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [hash], strFilter = [TS_PATH-1], strLevel = pg_tblspc/2, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 DEBUG: Storage::Local->manifest(): strPathExp = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 WARN: aborted backup [BACKUP-INCR-2] of same type exists, will be cleaned to remove invalid files and resumed
|
||||
P00 TEST: PgBaCkReStTeSt-BACKUP-RESUME-PgBaCkReStTeSt
|
||||
|
||||
@@ -2425,9 +2425,9 @@ P00 DEBUG: Manifest->build: found tablespace 2 in offline mode
|
||||
P00 DEBUG: Protocol::Storage::Remote->manifest(): rhParam = [undef], strPathExp = [TEST_PATH]/db-master/db/base
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [undef], strFilter = [TS_PATH-1], strLevel = pg_tblspc/1, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts1
|
||||
P00 DEBUG: Protocol::Storage::Remote->manifest(): rhParam = [undef], strPathExp = [TEST_PATH]/db-master/db/tablespace/ts1
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [undef], strFilter = [TS_PATH-1], strLevel = pg_tblspc/11, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [undef], strFilter = [TS_PATH-1], strLevel = pg_tblspc/11, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Protocol::Storage::Remote->manifest(): rhParam = [undef], strPathExp = [TEST_PATH]/db-master/db/tablespace/ts11
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [undef], strFilter = [TS_PATH-1], strLevel = pg_tblspc/2, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc/pg_tblspc/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 DEBUG: Manifest->build(): bOnline = false, bTablespace = true, hDatabaseMap = [undef], hTablespaceMap = [hash], iLevel = 1, oLastManifest = [undef], oStorageDbMaster = [object], rhExclude = [undef], strFilter = [TS_PATH-1], strLevel = pg_tblspc/2, strParentPath = [TEST_PATH]/db-master/db/base/pg_tblspc, strPath = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 DEBUG: Protocol::Storage::Remote->manifest(): rhParam = [undef], strPathExp = [TEST_PATH]/db-master/db/tablespace/ts2
|
||||
P00 WARN: aborted backup [BACKUP-INCR-2] of same type exists, will be cleaned to remove invalid files and resumed
|
||||
P00 TEST: PgBaCkReStTeSt-BACKUP-RESUME-PgBaCkReStTeSt
|
||||
|
||||
@@ -773,18 +773,14 @@ sub run
|
||||
'tablespace symlink ../base destination must not be in $PGDATA');
|
||||
testFileRemove("${strTblSpcPath}/${strTblspcId}");
|
||||
|
||||
# Invalid absolute tablespace is $self->{strDbPath} . /base
|
||||
# INVESTIGATE: But this should fail because the link points to a directory in pg_data but instead it passes the
|
||||
# index($hManifest->{$strName}{link_destination}, '/') != 0 and then fails later. It WILL fail "destination must not be in
|
||||
# $PGDATA" if an ending slash is added - so maybe the comment in Manifest.pm "# Make sure that DB_PATH_PGTBLSPC contains
|
||||
# only absolute links that do not point inside PGDATA" is not exactly correct?
|
||||
# Invalid absolute tablespace is $self->{strDbPath} . /base
|
||||
testLinkCreate("${strTblSpcPath}/${strTblspcId}", $self->{strDbPath} . '/base');
|
||||
$oManifest = new pgBackRest::Manifest(
|
||||
$strBackupManifestFile,
|
||||
{bLoad => false, strDbVersion => PG_VERSION_94, iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_94)});
|
||||
$self->testException(sub {$oManifest->build(storageDb(), $self->{strDbPath}, undef, true)}, ERROR_ASSERT,
|
||||
"tablespace with oid ${strTblspcId} not found in tablespace map\n" .
|
||||
"HINT: was a tablespace created or dropped during the backup?");
|
||||
$self->testException(
|
||||
sub {$oManifest->build(storageDb(), $self->{strDbPath}, undef, true)}, ERROR_TABLESPACE_IN_PGDATA,
|
||||
"tablespace symlink $self->{strDbPath}/base destination must not be in \$PGDATA");
|
||||
testFileRemove("${strTblSpcPath}/${strTblspcId}");
|
||||
|
||||
# Invalid relative tablespace is ../../BOGUS - which is not in $PGDATA and does not exist
|
||||
@@ -801,7 +797,7 @@ sub run
|
||||
my $strTablespace = 'tablespace';
|
||||
storageTest()->pathCreate($strTablespace);
|
||||
|
||||
my $strIntermediateLink = $self->{strDbPath} . "/intermediate_link";
|
||||
my $strIntermediateLink = $self->testPath() . "/intermediate_link";
|
||||
|
||||
# Create a link to a link
|
||||
testLinkCreate($strIntermediateLink, $self->testPath() . '/' . $strTablespace);
|
||||
@@ -813,7 +809,7 @@ sub run
|
||||
$self->testException(sub {$oManifest->build(storageDb(), $self->{strDbPath}, undef, false)}, ERROR_LINK_DESTINATION,
|
||||
"link '${strTblSpcPath}/${strTblspcId}' -> '$strIntermediateLink' cannot reference another link");
|
||||
|
||||
testFileRemove($self->{strDbPath} . "/intermediate_link");
|
||||
testFileRemove($strIntermediateLink);
|
||||
testFileRemove("${strTblSpcPath}/${strTblspcId}");
|
||||
|
||||
# Reload the manifest otherwise it will contain invalid data from the above exception tests
|
||||
|
||||
Reference in New Issue
Block a user