From 9267666d784e8a0cd070743447f05af6efef9078 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Tue, 5 Mar 2002 04:57:10 +0000 Subject: [PATCH] Some minor bug fixes. do not prompt for revocation reason for v3 revocations (unless force-v4-certs is on) since they wouldn't be used anyway. show the status of the sigs (exportable? revocable?) to the user before prompting for which sig to revoke. Also, make sure that local signatures get local revocations. Add "exec-path" variable to override PATH for execing programs. properly check return code from classify_user_id to catch unclassifiable keys. --- g10/ChangeLog | 20 ++++++++++++++++++++ g10/export.c | 3 +-- g10/g10.c | 19 +++++++++++++++++-- g10/keyedit.c | 22 +++++++++++++++------- g10/revoke.c | 17 +++++++++++------ 5 files changed, 64 insertions(+), 17 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index a3fb38a19..2ffa250b8 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,23 @@ +2002-03-04 David Shaw + + * revoke.c (gen_revoke): do not prompt for revocation reason for + v3 revocations (unless force-v4-certs is on) since they wouldn't + be used anyway. + + * keyedit.c (menu_revsig): show the status of the sigs + (exportable? revocable?) to the user before prompting for which + sig to revoke. Also, make sure that local signatures get local + revocations. + + * keyedit.c (ask_revoke_sig): remind the user which sigs are + local. + + * g10.c (main): Add "exec-path" variable to override PATH for + execing programs. + + * export.c (do_export_stream): properly check return code from + classify_user_id to catch unclassifiable keys. + 2002-03-03 David Shaw * parse-packet.c (parse_signature): variable type tweak for RISC diff --git a/g10/export.c b/g10/export.c index a8ca9210c..c9adc0639 100644 --- a/g10/export.c +++ b/g10/export.c @@ -135,8 +135,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any ) desc = m_alloc ( ndesc * sizeof *desc); for (ndesc=0, sl=users; sl; sl = sl->next) { - classify_user_id (sl->d, desc+ndesc); - if (desc->mode) + if (classify_user_id (sl->d, desc+ndesc)) ndesc++; else log_error (_("key `%s' not found: %s\n"), diff --git a/g10/g10.c b/g10/g10.c index 75f5bdcc9..80aba425f 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -227,6 +227,7 @@ enum cmd_and_opt_values { aNull = 0, oKeyServer, oKeyServerOptions, oTempDir, + oExecPath, oEncryptTo, oNoEncryptTo, oLoggerFD, @@ -345,6 +346,7 @@ static ARGPARSE_OPTS opts[] = { N_("use the default key as default recipient")}, { oNoDefRecipient, "no-default-recipient", 0, "@" }, { oTempDir, "temp-directory", 2, "@" }, + { oExecPath, "exec-path", 2, "@" }, { oEncryptTo, "encrypt-to", 2, "@" }, { oNoEncryptTo, "no-encrypt-to", 0, "@" }, { oUser, "local-user",2, N_("use this user-id to sign or decrypt")}, @@ -1186,13 +1188,26 @@ main( int argc, char **argv ) #endif /* __riscos__ */ break; case oKeyServer: - if(parse_keyserver_uri(pargs.r.ret_str)) + if(pargs.r.ret_str==NULL || parse_keyserver_uri(pargs.r.ret_str)) log_error(_("could not parse keyserver URI\n")); break; case oKeyServerOptions: - parse_keyserver_options(pargs.r.ret_str); + if(pargs.r.ret_str) + parse_keyserver_options(pargs.r.ret_str); break; case oTempDir: opt.temp_dir=pargs.r.ret_str; break; + case oExecPath: + if(pargs.r.ret_str) + { + /* Notice that path is never freed. That is + intentional due to the way putenv() works. */ + char *path=m_alloc(5+strlen(pargs.r.ret_str)+1); + strcpy(path,"PATH="); + strcat(path,pargs.r.ret_str); + if(putenv(path)!=0) + log_error(_("unable to set exec-path to %s\n"),path); + } + break; case oNotation: add_notation_data( pargs.r.ret_str ); break; case oShowNotation: opt.show_notation=1; break; case oNoShowNotation: opt.show_notation=0; break; diff --git a/g10/keyedit.c b/g10/keyedit.c index 3cfbf99ec..bca65a12a 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -2328,8 +2328,13 @@ ask_revoke_sig( KBNODE keyblock, KBNODE node ) tty_printf(_("user ID: \"")); tty_print_utf8_string( unode->pkt->pkt.user_id->name, unode->pkt->pkt.user_id->len ); - tty_printf(_("\"\nsigned with your key %08lX at %s\n"), - (ulong)sig->keyid[1], datestr_from_sig(sig) ); + + if(sig->flags.exportable) + tty_printf(_("\"\nsigned with your key %08lX at %s\n"), + (ulong)sig->keyid[1], datestr_from_sig(sig) ); + else + tty_printf(_("\"\nlocally signed with your key %08lX at %s\n"), + (ulong)sig->keyid[1], datestr_from_sig(sig) ); if( cpr_get_answer_is_yes("ask_revoke_sig.one", _("Create a revocation certificate for this signature? (y/N)")) ) { @@ -2370,9 +2375,10 @@ menu_revsig( KBNODE keyblock ) && ((sig = node->pkt->pkt.signature), !seckey_available(sig->keyid) ) ) { if( (sig->sig_class&~3) == 0x10 ) { - tty_printf(_(" signed by %08lX at %s%s\n"), - (ulong)sig->keyid[1], datestr_from_sig(sig), - sig->flags.revocable?"":" (not revocable)"); + tty_printf(_(" signed by %08lX at %s%s%s\n"), + (ulong)sig->keyid[1], datestr_from_sig(sig), + sig->flags.exportable?"":" (non-exportable)", + sig->flags.revocable?"":" (non-revocable)"); if(sig->flags.revocable) node->flag |= NODFLG_SELSIG; } @@ -2407,8 +2413,9 @@ menu_revsig( KBNODE keyblock ) } else if( node->pkt->pkttype == PKT_SIGNATURE ) { sig = node->pkt->pkt.signature; - tty_printf(_(" signed by %08lX at %s\n"), - (ulong)sig->keyid[1], datestr_from_sig(sig) ); + tty_printf(_(" signed by %08lX at %s%s\n"), + (ulong)sig->keyid[1], datestr_from_sig(sig), + sig->flags.exportable?"":_(" (non-exportable)") ); } } if( !any ) @@ -2440,6 +2447,7 @@ menu_revsig( KBNODE keyblock ) memset( &attrib, 0, sizeof attrib ); attrib.reason = reason; + attrib.non_exportable=!node->pkt->pkt.signature->flags.exportable; node->flag &= ~NODFLG_MARK_A; sk = m_alloc_secure_clear( sizeof *sk ); diff --git a/g10/revoke.c b/g10/revoke.c index ef3137109..625ca6edd 100644 --- a/g10/revoke.c +++ b/g10/revoke.c @@ -52,6 +52,9 @@ revocation_reason_build_cb( PKT_signature *sig, void *opaque ) byte *buffer; size_t buflen = 1; + if(!reason) + return 0; + if( reason->desc ) { ud = native_to_utf8( reason->desc ); buflen += strlen(ud); @@ -159,11 +162,13 @@ gen_revoke( const char *uname ) goto leave; } - /* get the reason for the revocation */ - reason = ask_revocation_reason( 1, 0, 1 ); - if( !reason ) { /* user decided to cancel */ + if(sk->version>=4 || opt.force_v4_certs) { + /* get the reason for the revocation */ + reason = ask_revocation_reason( 1, 0, 1 ); + if( !reason ) { /* user decided to cancel */ rc = 0; goto leave; + } } switch( is_secret_key_protected( sk ) ) { @@ -193,9 +198,9 @@ gen_revoke( const char *uname ) iobuf_push_filter( out, armor_filter, &afx ); /* create it */ - rc = make_keysig_packet( &sig, pk, NULL, NULL, sk, 0x20, 0, 0, 0, 0, - revocation_reason_build_cb, - reason ); + rc = make_keysig_packet( &sig, pk, NULL, NULL, sk, 0x20, 0, + opt.force_v4_certs?4:0, 0, 0, + revocation_reason_build_cb, reason ); if( rc ) { log_error(_("make_keysig_packet failed: %s\n"), g10_errstr(rc)); goto leave;