From bc9f7d2899891c0b8c4516629acd7d0e64a25223 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 25 Sep 2026 14:23:05 +0200 Subject: [PATCH] CLI: preserve read-only mode with protection credentials Apply the same read-only precedence as protect-hidden=yes when parsing hidden-volume passwords, keyfiles, and PIMs. --- src/Main/CommandLineInterface.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index 17b9b940..47209cc6 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -572,13 +572,15 @@ namespace VeraCrypt if (parser.Found (L"protection-keyfiles", &str)) { ArgMountOptions.ProtectionKeyfiles = ToKeyfileList (str); - ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; + if (ArgMountOptions.Protection != VolumeProtection::ReadOnly) + ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; } if (parser.Found (L"protection-password", &str)) { ArgMountOptions.ProtectionPassword = ToUTF8Password (str.c_str(), -1, ArgUseLegacyPassword? VolumePassword::MaxLegacySize : VolumePassword::MaxSize); - ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; + if (ArgMountOptions.Protection != VolumeProtection::ReadOnly) + ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; } if (parser.Found (L"protection-pim", &str)) @@ -595,7 +597,8 @@ namespace VeraCrypt throw_err (LangString["PARAMETER_INCORRECT"] + L": " + str); } ArgMountOptions.ProtectionPim = pim; - ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; + if (ArgMountOptions.Protection != VolumeProtection::ReadOnly) + ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; } if (parser.Found (L"protection-hash", &str))