From 233b5fedabd80a34452e748132e65b5944310428 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Tue, 14 Apr 2015 18:48:57 -0400 Subject: [PATCH] Allow --gen-key to inquire a passphrase. * 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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/g10/gpg.c b/g10/gpg.c index 10d8c2057..0b3e92404 100644 --- 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;