pgbackrest.git / summary / log / commit / refs
commit 70514061fdca620ba99dd0e36bb99dccbca43e1d
Author: David Steele <david@pgmasters.net>
Date: Thu Aug 30 20:27:36 2018 +0000
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.
doc/xml/release.xml | 8 ++++++++
lib/pgBackRest/Manifest.pm | 4 +---
src/perl/embed.auto.c | 4 +---
test/expect/mock-all-001.log | 4 ++--
test/expect/mock-all-002.log | 4 ++--
.../Module/Manifest/ManifestAllPerlTest.pm | 16 ++++++----------
6 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index b31921ec7..df48c9d60 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -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"/>
diff --git a/lib/pgBackRest/Manifest.pm b/lib/pgBackRest/Manifest.pm
index 172c8a922..0ee9106a9 100644
--- a/lib/pgBackRest/Manifest.pm
+++ b/lib/pgBackRest/Manifest.pm
@@ -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);
}
}
diff --git a/src/perl/embed.auto.c b/src/perl/embed.auto.c
index f40ae4745..6d3c8e5c8 100644
--- a/src/perl/embed.auto.c
+++ b/src/perl/embed.auto.c
@@ -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"
diff --git a/test/expect/mock-all-001.log b/test/expect/mock-all-001.log
index 45b903551..73e35581f 100644
--- a/test/expect/mock-all-001.log
+++ b/test/expect/mock-all-001.log
@@ -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
diff --git a/test/expect/mock-all-002.log b/test/expect/mock-all-002.log
index ca4c97446..fdc0aeaca 100644
--- a/test/expect/mock-all-002.log
+++ b/test/expect/mock-all-002.log
@@ -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
diff --git a/test/lib/pgBackRestTest/Module/Manifest/ManifestAllPerlTest.pm b/test/lib/pgBackRestTest/Module/Manifest/ManifestAllPerlTest.pm
index ec9bf5f43..16c0c9671 100644
--- a/test/lib/pgBackRestTest/Module/Manifest/ManifestAllPerlTest.pm
+++ b/test/lib/pgBackRestTest/Module/Manifest/ManifestAllPerlTest.pm
@@ -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
[parent: 1631f8b3cebb]