VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/UserPreferences.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main/UserPreferences.cpp')
-rw-r--r--src/Main/UserPreferences.cpp50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/Main/UserPreferences.cpp b/src/Main/UserPreferences.cpp
index fafd0824..194cb6df 100644
--- a/src/Main/UserPreferences.cpp
+++ b/src/Main/UserPreferences.cpp
@@ -3,9 +3,9 @@
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2016 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2017 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -20,9 +20,9 @@ namespace VeraCrypt
void UserPreferences::SetValue (const wxString &cfgText, bool &cfgVar)
{
if (cfgText == L"0")
cfgVar = false;
- else if (cfgText == L"1")
+ else
cfgVar = true;
}
void UserPreferences::SetValue (const wxString &cfgText, int &cfgVar)
@@ -57,8 +57,11 @@ namespace VeraCrypt
}
void UserPreferences::Load()
{
+ // first we clear the unknown config map entries
+ UnknownConfigMapEntries.clear();
+
// Preferences
FilePath cfgPath = Application::GetConfigFilePath (GetPreferencesFileName());
if (cfgPath.IsFile())
{
@@ -67,66 +70,71 @@ namespace VeraCrypt
{
configMap[node.Attributes[L"key"]] = node.InnerText;
}
-#define TC_CONFIG_SET(NAME) SetValue (configMap[L###NAME], NAME)
+#define TC_CONFIG_SET(NAME) if (configMap.count(L###NAME) > 0) { SetValue (configMap[L###NAME], NAME); configMap.erase (L###NAME); }
TC_CONFIG_SET (BackgroundTaskEnabled);
TC_CONFIG_SET (BackgroundTaskMenuDismountItemsEnabled);
TC_CONFIG_SET (BackgroundTaskMenuMountItemsEnabled);
TC_CONFIG_SET (BackgroundTaskMenuOpenItemsEnabled);
TC_CONFIG_SET (BeepAfterHotkeyMountDismount);
- SetValue (configMap[L"CachePasswords"], DefaultMountOptions.CachePassword);
+ if (configMap.count(L"CachePasswords") > 0) { SetValue (configMap[L"CachePasswords"], DefaultMountOptions.CachePassword); configMap.erase (L"CachePasswords"); }
TC_CONFIG_SET (CloseBackgroundTaskOnNoVolumes);
TC_CONFIG_SET (CloseExplorerWindowsOnDismount);
TC_CONFIG_SET (CloseSecurityTokenSessionsAfterMount);
+ TC_CONFIG_SET (EMVSupportEnabled);
TC_CONFIG_SET (DisableKernelEncryptionModeWarning);
TC_CONFIG_SET (DismountOnInactivity);
TC_CONFIG_SET (DismountOnLogOff);
TC_CONFIG_SET (DismountOnPowerSaving);
TC_CONFIG_SET (DismountOnScreenSaver);
TC_CONFIG_SET (DisplayMessageAfterHotkeyDismount);
TC_CONFIG_SET (BackgroundTaskEnabled);
- SetValue (configMap[L"FilesystemOptions"], DefaultMountOptions.FilesystemOptions);
+ if (configMap.count(L"FilesystemOptions") > 0) { SetValue (configMap[L"FilesystemOptions"], DefaultMountOptions.FilesystemOptions); configMap.erase (L"FilesystemOptions"); }
TC_CONFIG_SET (ForceAutoDismount);
+ TC_CONFIG_SET (Language);
TC_CONFIG_SET (LastSelectedSlotNumber);
TC_CONFIG_SET (MaxVolumeIdleTime);
TC_CONFIG_SET (MountDevicesOnLogon);
TC_CONFIG_SET (MountFavoritesOnLogon);
- bool readOnly;
- SetValue (configMap[L"MountVolumesReadOnly"], readOnly);
+ bool readOnly = false;
+ if (configMap.count(L"MountVolumesReadOnly") > 0) { SetValue (configMap[L"MountVolumesReadOnly"], readOnly); configMap.erase (L"MountVolumesReadOnly"); }
DefaultMountOptions.Protection = readOnly ? VolumeProtection::ReadOnly : VolumeProtection::None;
- SetValue (configMap[L"MountVolumesRemovable"], DefaultMountOptions.Removable);
- SetValue (configMap[L"NoHardwareCrypto"], DefaultMountOptions.NoHardwareCrypto);
- SetValue (configMap[L"NoKernelCrypto"], DefaultMountOptions.NoKernelCrypto);
+ if (configMap.count(L"MountVolumesRemovable") > 0) { SetValue (configMap[L"MountVolumesRemovable"], DefaultMountOptions.Removable); configMap.erase (L"MountVolumesRemovable"); }
+ if (configMap.count(L"NoHardwareCrypto") > 0) { SetValue (configMap[L"NoHardwareCrypto"], DefaultMountOptions.NoHardwareCrypto); configMap.erase (L"NoHardwareCrypto"); }
+ if (configMap.count(L"NoKernelCrypto") > 0) { SetValue (configMap[L"NoKernelCrypto"], DefaultMountOptions.NoKernelCrypto); configMap.erase (L"NoKernelCrypto"); }
TC_CONFIG_SET (OpenExplorerWindowAfterMount);
- SetValue (configMap[L"PreserveTimestamps"], DefaultMountOptions.PreserveTimestamps);
+ if (configMap.count(L"PreserveTimestamps") > 0) { SetValue (configMap[L"PreserveTimestamps"], DefaultMountOptions.PreserveTimestamps); configMap.erase (L"PreserveTimestamps"); }
TC_CONFIG_SET (SaveHistory);
- SetValue (configMap[L"SecurityTokenLibrary"], SecurityTokenModule);
+ if (configMap.count(L"SecurityTokenLibrary") > 0) { SetValue (configMap[L"SecurityTokenLibrary"], SecurityTokenModule); configMap.erase (L"SecurityTokenLibrary"); }
TC_CONFIG_SET (StartOnLogon);
TC_CONFIG_SET (UseKeyfiles);
TC_CONFIG_SET (WipeCacheOnAutoDismount);
TC_CONFIG_SET (WipeCacheOnClose);
- SetValue (configMap[L"DefaultTrueCryptMode"], DefaultMountOptions.TrueCryptMode);
-
wstring defaultPrf;
- SetValue (configMap[L"DefaultPRF"], defaultPrf);
+ if (configMap.count(L"DefaultPRF") > 0) { SetValue (configMap[L"DefaultPRF"], defaultPrf); configMap.erase (L"DefaultPRF"); }
+ if (defaultPrf.empty())
+ defaultPrf = L"autodetection";
shared_ptr <Pkcs5Kdf> savedKdf;
try
{
if (defaultPrf != L"autodetection")
- savedKdf = Pkcs5Kdf::GetAlgorithm (defaultPrf, DefaultMountOptions.TrueCryptMode);
+ savedKdf = Pkcs5Kdf::GetAlgorithm (defaultPrf);
}
catch (ParameterIncorrect&)
{
}
DefaultMountOptions.Kdf = savedKdf;
DefaultMountOptions.ProtectionKdf = savedKdf;
+
+ // at this point, the configMap should be empty, if not, we have unknown config entries that we need to store
+ UnknownConfigMapEntries = configMap;
}
// Default keyfiles
cfgPath = Application::GetConfigFilePath (GetDefaultKeyfilesFileName());
@@ -196,8 +204,9 @@ namespace VeraCrypt
formatter.AddEntry (L"CachePasswords", DefaultMountOptions.CachePassword);
TC_CONFIG_ADD (CloseBackgroundTaskOnNoVolumes);
TC_CONFIG_ADD (CloseExplorerWindowsOnDismount);
TC_CONFIG_ADD (CloseSecurityTokenSessionsAfterMount);
+ TC_CONFIG_ADD (EMVSupportEnabled);
TC_CONFIG_ADD (DisableKernelEncryptionModeWarning);
TC_CONFIG_ADD (DismountOnInactivity);
TC_CONFIG_ADD (DismountOnLogOff);
TC_CONFIG_ADD (DismountOnPowerSaving);
@@ -205,8 +214,9 @@ namespace VeraCrypt
TC_CONFIG_ADD (DisplayMessageAfterHotkeyDismount);
TC_CONFIG_ADD (BackgroundTaskEnabled);
formatter.AddEntry (L"FilesystemOptions", DefaultMountOptions.FilesystemOptions);
TC_CONFIG_ADD (ForceAutoDismount);
+ TC_CONFIG_ADD (Language);
TC_CONFIG_ADD (LastSelectedSlotNumber);
TC_CONFIG_ADD (MaxVolumeIdleTime);
TC_CONFIG_ADD (MountDevicesOnLogon);
TC_CONFIG_ADD (MountFavoritesOnLogon);
@@ -222,15 +232,19 @@ namespace VeraCrypt
TC_CONFIG_ADD (UseKeyfiles);
TC_CONFIG_ADD (WipeCacheOnAutoDismount);
TC_CONFIG_ADD (WipeCacheOnClose);
- formatter.AddEntry (L"DefaultTrueCryptMode", DefaultMountOptions.TrueCryptMode);
-
wstring defaultPrf = L"autodetection";
if (DefaultMountOptions.Kdf)
defaultPrf = DefaultMountOptions.Kdf->GetName ();
formatter.AddEntry (L"DefaultPRF", defaultPrf);
+ // add unknown config entries by iterating over all elements of the UnknownConfigMapEntries map
+ for (map<wxString, wxString>::const_iterator it = UnknownConfigMapEntries.begin(); it != UnknownConfigMapEntries.end(); ++it)
+ {
+ formatter.AddEntry(it->first.c_str(), it->second);
+ }
+
XmlWriter writer (Application::GetConfigFilePath (GetPreferencesFileName(), true));
writer.WriteNode (formatter.XmlConfig);
writer.Close();