From 5201d1ec9d058300581b6cab1c3ef52448140ef5 Mon Sep 17 00:00:00 2001 From: Timo Schulz Date: Sun, 18 Aug 2002 17:24:21 +0000 Subject: [PATCH] 2002-08-16 Timo Schulz * g10.c (main): enable opt.interactive. * import.c (import_one): Ask the user if the key shall be imported when the interactive mode is used. Useful to extract selected keys from a file. --- g10/ChangeLog | 8 ++++++++ g10/g10.c | 2 +- g10/import.c | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index 34dbb2cb3..1857317cc 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,11 @@ +2002-08-16 Timo Schulz + + * g10.c (main): enable opt.interactive. + + * import.c (import_one): Ask the user if the key shall be + imported when the interactive mode is used. Useful to extract + selected keys from a file. + 2002-08-16 Werner Koch * seckey-cert.c: Workaround to allow decryption of v3 keys created diff --git a/g10/g10.c b/g10/g10.c index 70c609c21..ca8d8eff0 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -403,7 +403,7 @@ static ARGPARSE_OPTS opts[] = { { oDisableMDC, "disable-mdc", 0, N_("never use a MDC for encryption") }, { oNoDisableMDC, "no-disable-mdc", 0, "@" }, { oDryRun, "dry-run", 0, N_("do not make any changes") }, - /*{ oInteractive, "interactive", 0, N_("prompt before overwriting") }, */ + { oInteractive, "interactive", 0, N_("prompt before overwriting") }, { oUseAgent, "use-agent",0, N_("use the gpg-agent")}, { oNoUseAgent, "no-use-agent",0, "@"}, { oGpgAgentInfo, "gpg-agent-info",2, "@"}, diff --git a/g10/import.c b/g10/import.c index bc4be7a2d..ec9ada602 100644 --- a/g10/import.c +++ b/g10/import.c @@ -641,6 +641,23 @@ import_one( const char *fname, KBNODE keyblock, int fast, log_error( _("key %08lX: no user ID\n"), (ulong)keyid[1]); return 0; } + + if( opt.interactive ) { + char *prompt, *p; + size_t n = 0; + + p = get_user_id( pk->keyid, &n ); + prompt = m_alloc( n + 16 + 128 + 1 ); + snprintf( prompt, n + 16 + 128, + "Do you want to import %08lX \"%s\" ? (y/n) ", + (ulong)keyid[1], p ); + m_free( p ); + if( !cpr_get_answer_is_yes( "import.okay", prompt ) ) { + m_free( prompt ); + return 0; + } + m_free( prompt ); + } clear_kbnode_flags( keyblock );