From 491b277ceedc1b9d60a7b7fdf021160d4af3cd6b Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sat, 25 Jun 2016 16:16:26 -0700 Subject: [PATCH] In case of an integrity violation, tell the user how they can reset integrity data. --- .../implementations/versioncounting/KnownBlockVersions.cpp | 4 ++++ .../implementations/versioncounting/KnownBlockVersions.h | 1 + .../versioncounting/VersionCountingBlockStore.cpp | 6 +++++- .../versioncounting/KnownBlockVersionsTest.cpp | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/blockstore/implementations/versioncounting/KnownBlockVersions.cpp b/src/blockstore/implementations/versioncounting/KnownBlockVersions.cpp index 5f62e021..0f5a5e89 100644 --- a/src/blockstore/implementations/versioncounting/KnownBlockVersions.cpp +++ b/src/blockstore/implementations/versioncounting/KnownBlockVersions.cpp @@ -205,5 +205,9 @@ bool KnownBlockVersions::blockShouldExist(const Key &key) const { return found->second != CLIENT_ID_FOR_DELETED_BLOCK; } +const bf::path &KnownBlockVersions::path() const { + return _stateFilePath; +} + } } diff --git a/src/blockstore/implementations/versioncounting/KnownBlockVersions.h b/src/blockstore/implementations/versioncounting/KnownBlockVersions.h index b3edbbf2..4cc2243f 100644 --- a/src/blockstore/implementations/versioncounting/KnownBlockVersions.h +++ b/src/blockstore/implementations/versioncounting/KnownBlockVersions.h @@ -32,6 +32,7 @@ namespace blockstore { uint64_t getBlockVersion(uint32_t clientId, const Key &key) const; uint32_t myClientId() const; + const boost::filesystem::path &path() const; private: std::unordered_map _knownVersions; diff --git a/src/blockstore/implementations/versioncounting/VersionCountingBlockStore.cpp b/src/blockstore/implementations/versioncounting/VersionCountingBlockStore.cpp index f73889f9..5dac818d 100644 --- a/src/blockstore/implementations/versioncounting/VersionCountingBlockStore.cpp +++ b/src/blockstore/implementations/versioncounting/VersionCountingBlockStore.cpp @@ -43,7 +43,11 @@ namespace blockstore { void VersionCountingBlockStore::_checkNoPastIntegrityViolations() { if (_integrityViolationDetected) { - throw std::runtime_error("There was an integrity violation detected. Preventing any further access to the file system."); + throw std::runtime_error(string() + + "There was an integrity violation detected. Preventing any further access to the file system. " + + "If you want to reset the integrity data (i.e. accept changes made by a potential attacker), " + + "please unmount the file system and delete the following file before re-mounting it: " + + _knownBlockVersions.path().native()); } } diff --git a/test/blockstore/implementations/versioncounting/KnownBlockVersionsTest.cpp b/test/blockstore/implementations/versioncounting/KnownBlockVersionsTest.cpp index 877a125d..6c7ce192 100644 --- a/test/blockstore/implementations/versioncounting/KnownBlockVersionsTest.cpp +++ b/test/blockstore/implementations/versioncounting/KnownBlockVersionsTest.cpp @@ -335,3 +335,8 @@ TEST_F(KnownBlockVersionsTest, blockShouldExist_deletedBlock) { testobj.markBlockAsDeleted(key); EXPECT_FALSE(testobj.blockShouldExist(key)); } + +TEST_F(KnownBlockVersionsTest, path) { + KnownBlockVersions obj(stateFile.path()); + EXPECT_EQ(stateFile.path(), obj.path()); +} \ No newline at end of file