VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouisTakePILLz <LouisTakePILLz@users.noreply.github.com>2015-08-12 17:25:47 -0400
committerLouisTakePILLz <LouisTakePILLz@users.noreply.github.com>2015-08-30 19:45:01 -0400
commit9582d8fbcb57c0297aad3d4a05eac53f1c125cd3 (patch)
treeb7149525bbcb8903ced14b7077f614925decba59
parentba9af466624706ada9bff2d74a257c7fbedba5cc (diff)
downloadVeraCrypt-9582d8fbcb57c0297aad3d4a05eac53f1c125cd3.tar.gz
VeraCrypt-9582d8fbcb57c0297aad3d4a05eac53f1c125cd3.zip
Add stdin-supplied password support
-rw-r--r--src/Main/CommandLineInterface.cpp15
-rw-r--r--src/Main/UserInterface.cpp14
-rw-r--r--src/Main/UserPreferences.h2
3 files changed, 27 insertions, 4 deletions
diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp
index 4b1584c8..3563f0b0 100644
--- a/src/Main/CommandLineInterface.cpp
+++ b/src/Main/CommandLineInterface.cpp
@@ -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
diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp
index 68048663..070a49c1 100644
--- a/src/Main/UserInterface.cpp
+++ b/src/Main/UserInterface.cpp
@@ -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:
diff --git a/src/Main/UserPreferences.h b/src/Main/UserPreferences.h
index 2c7d16f1..efc02d5e 100644
--- a/src/Main/UserPreferences.h
+++ b/src/Main/UserPreferences.h
@@ -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;