In case of an integrity violation, tell the user how they can reset integrity data.

This commit is contained in:
Sebastian Messmer 2016-06-25 16:16:26 -07:00
parent 839a511c4d
commit 491b277cee
4 changed files with 15 additions and 1 deletions

View File

@ -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;
}
}
}

View File

@ -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<ClientIdAndBlockKey, uint64_t> _knownVersions;

View File

@ -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());
}
}

View File

@ -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());
}