From d5ff215da293bcfbdea3f351396a99ce92639790 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Mon, 19 Jan 2015 21:20:25 -0500 Subject: [PATCH] Support for passing the master password non-interactively for testing. --- MasterPassword/C/mpw-cli.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MasterPassword/C/mpw-cli.c b/MasterPassword/C/mpw-cli.c index ce146c73..74f19744 100644 --- a/MasterPassword/C/mpw-cli.c +++ b/MasterPassword/C/mpw-cli.c @@ -112,11 +112,16 @@ int main(int argc, char *const argv[]) { ftl( "Invalid %s: %s\n", MP_env_algorithm, algorithmVersionString ); // Read the options. - for (int opt; (opt = getopt( argc, argv, "u:t:c:v:V:C:h" )) != -1;) + for (int opt; (opt = getopt( argc, argv, "u:P:t:c:v:V:C:h" )) != -1;) switch (opt) { case 'u': fullName = optarg; break; + case 'P': + // Do not use this. Passing your master password via the command-line + // is insecure. This is here for non-interactive testing purposes only. + masterPassword = strcpy( malloc( strlen( optarg ) + 1 ), optarg ); + break; case 't': siteTypeString = optarg; break;