1
0
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:
LouisTakePILLz
2015-08-12 17:25:47 -04:00
parent ba9af46662
commit 9582d8fbcb
3 changed files with 27 additions and 4 deletions

View File

@@ -71,6 +71,7 @@ namespace VeraCrypt
parser.AddOption (L"", L"new-password", _("New password"));
parser.AddOption (L"", L"new-pim", _("New PIM"));
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"", L"pim", _("PIM"));
parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume"));
@@ -402,9 +403,21 @@ namespace VeraCrypt
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 (Preferences.UseStandardInput)
throw_err (L"--password cannot be used with --stdin");
ArgPassword.reset (new VolumePassword (wstring (str)));
}
if (parser.Found (L"pim", &str))
{
try

View File

@@ -889,11 +889,19 @@ namespace VeraCrypt
{
CommandLineInterface &cmdLine = *CmdLine;
switch (cmdLine.ArgCommand)
{
case CommandId::None:
if (cmdLine.ArgCommand == CommandId::None)
return false;
if (Preferences.UseStandardInput)
{
wstring pwdInput;
wcin >> pwdInput;
cmdLine.ArgPassword = make_shared<VolumePassword> (pwdInput);
}
switch (cmdLine.ArgCommand)
{
case CommandId::AutoMountDevices:
case CommandId::AutoMountFavorites:
case CommandId::AutoMountDevicesFavorites:

View File

@@ -43,6 +43,7 @@ namespace VeraCrypt
MountDevicesOnLogon (false),
MountFavoritesOnLogon (false),
NonInteractive (false),
UseStandardInput (false),
OpenExplorerWindowAfterMount (false),
SaveHistory (false),
StartOnLogon (false),
@@ -83,6 +84,7 @@ namespace VeraCrypt
bool MountDevicesOnLogon;
bool MountFavoritesOnLogon;
bool NonInteractive;
bool UseStandardInput;
bool OpenExplorerWindowAfterMount;
bool SaveHistory;
FilePath SecurityTokenModule;