Allow --gen-key to inquire a passphrase.
authorBen Kibbey <bjk@luxsci.net>
Tue, 14 Apr 2015 22:48:57 +0000 (18:48 -0400)
committerBen Kibbey <bjk@luxsci.net>
Sat, 15 Aug 2015 21:14:13 +0000 (17:14 -0400)
* g10/gpg.c (main): test for --command-fd during --gen-key parse.

When --command-fd is set then imply --batch to let gpg inquire a
passphrase rather than requiring a pinentry.

g10/gpg.c

index 10d8c20..0b3e924 100644 (file)
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -3930,9 +3930,18 @@ main (int argc, char **argv)
            generate_keypair (ctrl, 0, argc? *argv : NULL, NULL, 0);
        }
        else {
-           if( argc )
-               wrong_args("--gen-key");
-           generate_keypair (ctrl, 0, NULL, NULL, 0);
+            if (opt.command_fd != -1 && argc)
+              {
+                if( argc > 1 )
+                  wrong_args("--gen-key [parameterfile]");
+
+                opt.batch = 1;
+                generate_keypair (ctrl, 0, argc? *argv : NULL, NULL, 0);
+              }
+            else if (argc)
+              wrong_args ("--gen-key");
+            else
+              generate_keypair (ctrl, 0, NULL, NULL, 0);
        }
        break;