mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Add stdin-supplied password support
This commit is contained in:
@@ -71,6 +71,7 @@ namespace VeraCrypt
|
|||||||
parser.AddOption (L"", L"new-password", _("New password"));
|
parser.AddOption (L"", L"new-password", _("New password"));
|
||||||
parser.AddOption (L"", L"new-pim", _("New PIM"));
|
parser.AddOption (L"", L"new-pim", _("New PIM"));
|
||||||
parser.AddSwitch (L"", L"non-interactive", _("Do not interact with user"));
|
parser.AddSwitch (L"", L"non-interactive", _("Do not interact with user"));
|
||||||
|
parser.AddSwitch (L"", L"stdin", _("Read password from standard input"));
|
||||||
parser.AddOption (L"p", L"password", _("Password"));
|
parser.AddOption (L"p", L"password", _("Password"));
|
||||||
parser.AddOption (L"", L"pim", _("PIM"));
|
parser.AddOption (L"", L"pim", _("PIM"));
|
||||||
parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume"));
|
parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume"));
|
||||||
@@ -402,9 +403,21 @@ namespace VeraCrypt
|
|||||||
Preferences.NonInteractive = true;
|
Preferences.NonInteractive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parser.Found (L"stdin"))
|
||||||
|
{
|
||||||
|
if (!Preferences.NonInteractive)
|
||||||
|
throw_err (L"--stdin is supported only in non-interactive mode");
|
||||||
|
|
||||||
|
Preferences.UseStandardInput = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (parser.Found (L"password", &str))
|
if (parser.Found (L"password", &str))
|
||||||
|
{
|
||||||
|
if (Preferences.UseStandardInput)
|
||||||
|
throw_err (L"--password cannot be used with --stdin");
|
||||||
ArgPassword.reset (new VolumePassword (wstring (str)));
|
ArgPassword.reset (new VolumePassword (wstring (str)));
|
||||||
|
}
|
||||||
|
|
||||||
if (parser.Found (L"pim", &str))
|
if (parser.Found (L"pim", &str))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -889,11 +889,19 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
CommandLineInterface &cmdLine = *CmdLine;
|
CommandLineInterface &cmdLine = *CmdLine;
|
||||||
|
|
||||||
switch (cmdLine.ArgCommand)
|
if (cmdLine.ArgCommand == CommandId::None)
|
||||||
{
|
|
||||||
case CommandId::None:
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (Preferences.UseStandardInput)
|
||||||
|
{
|
||||||
|
wstring pwdInput;
|
||||||
|
wcin >> pwdInput;
|
||||||
|
|
||||||
|
cmdLine.ArgPassword = make_shared<VolumePassword> (pwdInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (cmdLine.ArgCommand)
|
||||||
|
{
|
||||||
case CommandId::AutoMountDevices:
|
case CommandId::AutoMountDevices:
|
||||||
case CommandId::AutoMountFavorites:
|
case CommandId::AutoMountFavorites:
|
||||||
case CommandId::AutoMountDevicesFavorites:
|
case CommandId::AutoMountDevicesFavorites:
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ namespace VeraCrypt
|
|||||||
MountDevicesOnLogon (false),
|
MountDevicesOnLogon (false),
|
||||||
MountFavoritesOnLogon (false),
|
MountFavoritesOnLogon (false),
|
||||||
NonInteractive (false),
|
NonInteractive (false),
|
||||||
|
UseStandardInput (false),
|
||||||
OpenExplorerWindowAfterMount (false),
|
OpenExplorerWindowAfterMount (false),
|
||||||
SaveHistory (false),
|
SaveHistory (false),
|
||||||
StartOnLogon (false),
|
StartOnLogon (false),
|
||||||
@@ -83,6 +84,7 @@ namespace VeraCrypt
|
|||||||
bool MountDevicesOnLogon;
|
bool MountDevicesOnLogon;
|
||||||
bool MountFavoritesOnLogon;
|
bool MountFavoritesOnLogon;
|
||||||
bool NonInteractive;
|
bool NonInteractive;
|
||||||
|
bool UseStandardInput;
|
||||||
bool OpenExplorerWindowAfterMount;
|
bool OpenExplorerWindowAfterMount;
|
||||||
bool SaveHistory;
|
bool SaveHistory;
|
||||||
FilePath SecurityTokenModule;
|
FilePath SecurityTokenModule;
|
||||||
|
|||||||
Reference in New Issue
Block a user