mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 02:58:02 -06:00
Merge pull request #18 from LouisTakePILLz/master
Linux/MacOSX: Support supplying password to VeraCrypt via pipe (stdin)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user