Show old config values at mount time, otherwise they'd just always show the current version
This commit is contained in:
parent
8978eb546e
commit
b28b8b6ea8
@ -230,18 +230,29 @@ namespace cryfs_cli {
|
||||
}
|
||||
|
||||
namespace {
|
||||
void printConfig(const CryConfig& config) {
|
||||
void printConfig(const CryConfig& oldConfig, const CryConfig& updatedConfig) {
|
||||
auto printValue = [&] (const char* prefix, const char* suffix, auto member) {
|
||||
std::cout << prefix;
|
||||
auto oldConfigValue = member(oldConfig);
|
||||
auto updatedConfigValue = member(updatedConfig);
|
||||
if (oldConfigValue == updatedConfigValue) {
|
||||
std::cout << oldConfigValue;
|
||||
} else {
|
||||
std::cout << oldConfigValue << " -> " << updatedConfigValue;
|
||||
}
|
||||
std::cout << suffix;
|
||||
};
|
||||
std::cout
|
||||
<< "\n----------------------------------------------------"
|
||||
<< "\nFilesystem configuration:"
|
||||
<< "\n----------------------------------------------------"
|
||||
<< "\n- Filesystem format version: " << config.Version()
|
||||
<< "\n- Created with: CryFS " << config.CreatedWithVersion()
|
||||
<< "\n- Last opened with: CryFS " << config.LastOpenedWithVersion()
|
||||
<< "\n- Cipher: " << config.Cipher()
|
||||
<< "\n- Blocksize: " << config.BlocksizeBytes() << " bytes"
|
||||
<< "\n- Filesystem Id: " << config.FilesystemId().ToString()
|
||||
<< "\n----------------------------------------------------\n";
|
||||
<< "\n----------------------------------------------------";
|
||||
printValue("\n- Filesystem format version: ", "", [] (const CryConfig& config) {return config.Version(); });
|
||||
printValue("\n- Created with: CryFS ", "", [] (const CryConfig& config) { return config.CreatedWithVersion(); });
|
||||
printValue("\n- Last opened with: CryFS ", "", [] (const CryConfig& config) { return config.LastOpenedWithVersion(); });
|
||||
printValue("\n- Cipher: ", "", [] (const CryConfig& config) { return config.Cipher(); });
|
||||
printValue("\n- Blocksize: ", " bytes", [] (const CryConfig& config) { return config.BlocksizeBytes(); });
|
||||
printValue("\n- Filesystem Id: ", "", [] (const CryConfig& config) { return config.FilesystemId().ToString(); });
|
||||
std::cout << "\n----------------------------------------------------\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +261,7 @@ namespace cryfs_cli {
|
||||
LocalStateDir localStateDir(Environment::localStateDir());
|
||||
auto blockStore = make_unique_ref<OnDiskBlockStore2>(options.baseDir());
|
||||
auto config = _loadOrCreateConfig(options, localStateDir);
|
||||
printConfig(*config.configFile->config());
|
||||
printConfig(config.oldConfig, *config.configFile->config());
|
||||
unique_ptr<fspp::fuse::Fuse> fuse = nullptr;
|
||||
bool stoppedBecauseOfIntegrityViolation = false;
|
||||
|
||||
|
@ -37,6 +37,7 @@ either<CryConfigFile::LoadError, CryConfigLoader::ConfigLoadResult> CryConfigLoa
|
||||
if (config.is_left()) {
|
||||
return config.left();
|
||||
}
|
||||
auto oldConfig = *config.right()->config();
|
||||
#ifndef CRYFS_NO_COMPATIBILITY
|
||||
//Since 0.9.7 and 0.9.8 set their own version to cryfs.version instead of the filesystem format version (which is 0.9.6), overwrite it
|
||||
if (config.right()->config()->Version() == "0.9.7" || config.right()->config()->Version() == "0.9.8") {
|
||||
@ -60,7 +61,7 @@ either<CryConfigFile::LoadError, CryConfigLoader::ConfigLoadResult> CryConfigLoa
|
||||
auto localState = LocalStateMetadata::loadOrGenerate(_localStateDir.forFilesystemId(config.right()->config()->FilesystemId()), cpputils::Data::FromString(config.right()->config()->EncryptionKey()), allowReplacedFilesystem);
|
||||
uint32_t myClientId = localState.myClientId();
|
||||
_checkMissingBlocksAreIntegrityViolations(config.right().get(), myClientId);
|
||||
return ConfigLoadResult {std::move(config.right()), myClientId};
|
||||
return ConfigLoadResult {std::move(oldConfig), std::move(config.right()), myClientId};
|
||||
}
|
||||
|
||||
void CryConfigLoader::_checkVersion(const CryConfig &config, bool allowFilesystemUpgrade) {
|
||||
@ -118,8 +119,8 @@ either<CryConfigFile::LoadError, CryConfigLoader::ConfigLoadResult> CryConfigLoa
|
||||
|
||||
CryConfigLoader::ConfigLoadResult CryConfigLoader::_createConfig(bf::path filename, bool allowReplacedFilesystem) {
|
||||
auto config = _creator.create(_cipherFromCommandLine, _blocksizeBytesFromCommandLine, _missingBlockIsIntegrityViolationFromCommandLine, allowReplacedFilesystem);
|
||||
auto result = CryConfigFile::create(std::move(filename), std::move(config.config), _keyProvider.get());
|
||||
return ConfigLoadResult {std::move(result), config.myClientId};
|
||||
auto result = CryConfigFile::create(std::move(filename), config.config, _keyProvider.get());
|
||||
return ConfigLoadResult {std::move(config.config), std::move(result), config.myClientId};
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
CryConfigLoader(CryConfigLoader &&rhs) = default;
|
||||
|
||||
struct ConfigLoadResult {
|
||||
CryConfig oldConfig; // loading a config file updates the config file, but this member keeps the original config
|
||||
cpputils::unique_ref<CryConfigFile> configFile;
|
||||
uint32_t myClientId;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user