mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-09-26 01:44:53 +00:00
Unix: preserve requested protection when mounting favorites
Keep caller protection unless a favorite requires read-only access. Reuse cached outer credentials when recovering hidden-protection errors.
This commit is contained in:
@@ -92,7 +92,9 @@ namespace VeraCrypt
|
||||
|
||||
options.Path.reset (new VolumePath (Path));
|
||||
options.PartitionInSystemEncryptionScope = System;
|
||||
options.Protection = (ReadOnly ? VolumeProtection::ReadOnly : VolumeProtection::None);
|
||||
// A favorite may require read-only access, but must not weaken requested protection.
|
||||
if (ReadOnly)
|
||||
options.Protection = VolumeProtection::ReadOnly;
|
||||
options.SlotNumber = SlotNumber;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,13 +847,15 @@ namespace VeraCrypt
|
||||
newMountedVolumes.push_back (Core->MountVolume (favoriteOptions));
|
||||
mountPerformed = true;
|
||||
}
|
||||
catch (PasswordException&)
|
||||
catch (PasswordException &e)
|
||||
{
|
||||
CloseSecurityTokenSessionsAfterMountScope closeTokenSessionsScope (Preferences.CloseSecurityTokenSessionsAfterMount);
|
||||
|
||||
// The initial silent mount attempt has already consulted cached passwords.
|
||||
// Avoid repeating the same failed cache sweep before prompting the user.
|
||||
shared_ptr <VolumeInfo> volume = MountVolume (favoriteOptions, false);
|
||||
// A protection failure accepted the outer password. Let the UI recover
|
||||
// using that cache; only skip a cache sweep that failed outer authentication.
|
||||
bool protectionError = dynamic_cast <ProtectionPasswordIncorrect *> (&e)
|
||||
|| dynamic_cast <ProtectionPasswordKeyfilesIncorrect *> (&e);
|
||||
shared_ptr <VolumeInfo> volume = MountVolume (favoriteOptions, protectionError);
|
||||
|
||||
if (!volume)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user