From bf4a8935866e1527224f2463f3fa86d314dde480 Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 7 Nov 2002 04:37:27 +0000 Subject: [PATCH] * options.h, g10.c (main), trustdb.c (ask_ownertrust): Add --force-ownertrust option for debugging purposes. This allows setting a whole keyring to a given trust during an --update-trustdb. Not for normal use - it's just easier than hitting "4" all the time to test a large trustdb. --- g10/ChangeLog | 6 ++++++ g10/g10.c | 11 +++++++++++ g10/options.h | 1 + g10/trustdb.c | 23 +++++++++++++++++------ 4 files changed, 35 insertions(+), 6 deletions(-) diff --git a/g10/ChangeLog b/g10/ChangeLog index aec63a538..769f945cb 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,5 +1,11 @@ 2002-11-06 David Shaw + * options.h, g10.c (main), trustdb.c (ask_ownertrust): Add + --force-ownertrust option for debugging purposes. This allows + setting a whole keyring to a given trust during an + --update-trustdb. Not for normal use - it's just easier than + hitting "4" all the time to test a large trustdb. + * pubkey-enc.c (get_session_key): With hidden recipients or try a given passphrase against all secret keys rather than trying all secret keys in turn. Don't if --try-all-secrets or --status-fd is diff --git a/g10/g10.c b/g10/g10.c index 365d15fba..19c1828e6 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -206,6 +206,7 @@ enum cmd_and_opt_values { aNull = 0, oCompressSigs, oAlwaysTrust, oTrustModel, + oForceOwnertrust, oEmuChecksumBug, oRunAsShmCP, oSetFilename, @@ -524,6 +525,7 @@ static ARGPARSE_OPTS opts[] = { { oDefCertCheckLevel, "default-cert-check-level", 1, "@"}, { oAlwaysTrust, "always-trust", 0, "@"}, { oTrustModel, "trust-model", 2, "@"}, + { oForceOwnertrust, "force-ownertrust", 1, "@"}, { oEmuChecksumBug, "emulate-checksum-bug", 0, "@"}, { oRunAsShmCP, "run-as-shm-coprocess", 4, "@" }, { oSetFilename, "set-filename", 2, "@" }, @@ -1460,6 +1462,15 @@ main( int argc, char **argv ) else log_error("unknown trust model \"%s\"\n",pargs.r.ret_str); break; + case oForceOwnertrust: + log_info(_("NOTE: %s is not for normal use!\n"), + "--force-ownertrust"); + if(pargs.r.ret_int>=TRUST_UNDEFINED + && pargs.r.ret_int<=TRUST_ULTIMATE) + opt.force_ownertrust=pargs.r.ret_int; + else + log_error("invalid ownertrust %d\n",pargs.r.ret_int); + break; case oLoadExtension: #ifndef __riscos__ #if defined(USE_DYNAMIC_LINKING) || defined(__MINGW32__) diff --git a/g10/options.h b/g10/options.h index 1edec5817..d2f39077c 100644 --- a/g10/options.h +++ b/g10/options.h @@ -89,6 +89,7 @@ struct { int compress_keys; int compress_sigs; enum {TM_OPENPGP, TM_CLASSIC, TM_ALWAYS} trust_model; + unsigned int force_ownertrust; int pgp2; int pgp6; int pgp7; /* if we get any more of these, it's time to look at a diff --git a/g10/trustdb.c b/g10/trustdb.c index da05632d7..ffdce2c16 100644 --- a/g10/trustdb.c +++ b/g10/trustdb.c @@ -1075,13 +1075,24 @@ ask_ownertrust (u32 *kid,int minimum) return TRUST_UNKNOWN; } - ot=edit_ownertrust(pk,0); - if(ot>0) - ot = get_ownertrust (pk); - else if(ot==0) - ot = minimum?minimum:TRUST_UNDEFINED; + if(opt.force_ownertrust) + { + log_info("force trust for key %08lX to %s\n",(ulong)kid[1], + trust_string(opt.force_ownertrust)); + update_ownertrust(pk,opt.force_ownertrust); + ot=opt.force_ownertrust; + } else - ot = -1; /* quit */ + { + ot=edit_ownertrust(pk,0); + if(ot>0) + ot = get_ownertrust (pk); + else if(ot==0) + ot = minimum?minimum:TRUST_UNDEFINED; + else + ot = -1; /* quit */ + } + free_public_key( pk ); return ot;