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 committed 2026-09-25 13:59:24 +02:00
1 parent d7fa847de0
commit b111be60d2
2 files changed
+9 -5

No files matched your search

+3 -1
View File
@@ -92,7 +92,9 @@ namespace VeraCrypt
options.Path.reset (new VolumePath (Path)); options.Path.reset (new VolumePath (Path));
options.PartitionInSystemEncryptionScope = System; 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; options.SlotNumber = SlotNumber;
} }
} }
+6 -4
View File
@@ -847,13 +847,15 @@ namespace VeraCrypt
newMountedVolumes.push_back (Core->MountVolume (favoriteOptions)); newMountedVolumes.push_back (Core->MountVolume (favoriteOptions));
mountPerformed = true; mountPerformed = true;
} }
catch (PasswordException&) catch (PasswordException &e)
{ {
CloseSecurityTokenSessionsAfterMountScope closeTokenSessionsScope (Preferences.CloseSecurityTokenSessionsAfterMount); CloseSecurityTokenSessionsAfterMountScope closeTokenSessionsScope (Preferences.CloseSecurityTokenSessionsAfterMount);
// The initial silent mount attempt has already consulted cached passwords. // A protection failure accepted the outer password. Let the UI recover
// Avoid repeating the same failed cache sweep before prompting the user. // using that cache; only skip a cache sweep that failed outer authentication.
shared_ptr <VolumeInfo> volume = MountVolume (favoriteOptions, false); bool protectionError = dynamic_cast <ProtectionPasswordIncorrect *> (&e)
|| dynamic_cast <ProtectionPasswordKeyfilesIncorrect *> (&e);
shared_ptr <VolumeInfo> volume = MountVolume (favoriteOptions, protectionError);
if (!volume) if (!volume)
break; break;