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:
Mounir IDRASSI
2026-09-25 13:59:24 +02:00
parent d7fa847de0
commit b111be60d2
2 changed files with 9 additions and 5 deletions
+3 -1
View File
@@ -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;
}
}
+6 -4
View File
@@ -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;