1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-02 22:38:02 +02:00

Fix use of DBG_CACHE and DBG_LOOKUP

* dirmngr/dirmngr.h (DBG_LOOKUP_VALUE): Change to 8192.
* g10/options.h (DBG_LOOKUP_VALUE, DBG_LOOKUP): New.
* g10/getkey.c: Use DBG_LOOKUP instead of DBG_CACHE at most places.
This commit is contained in:
Werner Koch 2015-04-06 13:27:26 +02:00
parent 4de8a58e44
commit 2f099eb62a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 26 additions and 23 deletions

View File

@ -133,21 +133,21 @@ struct
#define DBG_X509_VALUE 1 /* debug x.509 parsing */ #define DBG_X509_VALUE 1 /* debug x.509 parsing */
#define DBG_LOOKUP_VALUE 2 /* debug lookup details */
#define DBG_CRYPTO_VALUE 4 /* debug low level crypto */ #define DBG_CRYPTO_VALUE 4 /* debug low level crypto */
#define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */ #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
#define DBG_CACHE_VALUE 64 /* debug the caching */ #define DBG_CACHE_VALUE 64 /* debug the caching */
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */ #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
#define DBG_HASHING_VALUE 512 /* debug hashing operations */ #define DBG_HASHING_VALUE 512 /* debug hashing operations */
#define DBG_ASSUAN_VALUE 1024 /* debug assuan communication */ #define DBG_ASSUAN_VALUE 1024 /* debug assuan communication */
#define DBG_LOOKUP_VALUE 8192 /* debug lookup details */
#define DBG_X509 (opt.debug & DBG_X509_VALUE) #define DBG_X509 (opt.debug & DBG_X509_VALUE)
#define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
#define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE) #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
#define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE) #define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE)
#define DBG_CACHE (opt.debug & DBG_CACHE_VALUE) #define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE) #define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
#define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE) #define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE)
#define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
/* A simple list of certificate references. */ /* A simple list of certificate references. */
struct cert_ref_s struct cert_ref_s

View File

@ -2373,7 +2373,7 @@ finish_lookup (GETKEY_CTX ctx)
} }
} }
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x)\n", log_debug ("finish_lookup: checking key %08lX (%s)(req_usage=%x)\n",
(ulong) keyid_from_pk (keyblock->pkt->pkt.public_key, NULL), (ulong) keyid_from_pk (keyblock->pkt->pkt.public_key, NULL),
foundk ? "one" : "all", req_usage); foundk ? "one" : "all", req_usage);
@ -2400,43 +2400,43 @@ finish_lookup (GETKEY_CTX ctx)
if (foundk) if (foundk)
nextk = NULL; /* what a hack */ nextk = NULL; /* what a hack */
pk = k->pkt->pkt.public_key; pk = k->pkt->pkt.public_key;
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tchecking subkey %08lX\n", log_debug ("\tchecking subkey %08lX\n",
(ulong) keyid_from_pk (pk, NULL)); (ulong) keyid_from_pk (pk, NULL));
if (!pk->flags.valid) if (!pk->flags.valid)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tsubkey not valid\n"); log_debug ("\tsubkey not valid\n");
continue; continue;
} }
if (pk->flags.revoked) if (pk->flags.revoked)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tsubkey has been revoked\n"); log_debug ("\tsubkey has been revoked\n");
continue; continue;
} }
if (pk->has_expired) if (pk->has_expired)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tsubkey has expired\n"); log_debug ("\tsubkey has expired\n");
continue; continue;
} }
if (pk->timestamp > curtime && !opt.ignore_valid_from) if (pk->timestamp > curtime && !opt.ignore_valid_from)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tsubkey not yet valid\n"); log_debug ("\tsubkey not yet valid\n");
continue; continue;
} }
if (!((pk->pubkey_usage & USAGE_MASK) & req_usage)) if (!((pk->pubkey_usage & USAGE_MASK) & req_usage))
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tusage does not match: want=%x have=%x\n", log_debug ("\tusage does not match: want=%x have=%x\n",
req_usage, pk->pubkey_usage); req_usage, pk->pubkey_usage);
continue; continue;
} }
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tsubkey might be fine\n"); log_debug ("\tsubkey might be fine\n");
/* In case a key has a timestamp of 0 set, we make sure /* In case a key has a timestamp of 0 set, we make sure
that it is used. A better change would be to compare that it is used. A better change would be to compare
@ -2455,33 +2455,33 @@ finish_lookup (GETKEY_CTX ctx)
if ((!latest_key && !(ctx->exact && foundk != keyblock)) || req_prim) if ((!latest_key && !(ctx->exact && foundk != keyblock)) || req_prim)
{ {
PKT_public_key *pk; PKT_public_key *pk;
if (DBG_CACHE && !foundk && !req_prim) if (DBG_LOOKUP && !foundk && !req_prim)
log_debug ("\tno suitable subkeys found - trying primary\n"); log_debug ("\tno suitable subkeys found - trying primary\n");
pk = keyblock->pkt->pkt.public_key; pk = keyblock->pkt->pkt.public_key;
if (!pk->flags.valid) if (!pk->flags.valid)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tprimary key not valid\n"); log_debug ("\tprimary key not valid\n");
} }
else if (pk->flags.revoked) else if (pk->flags.revoked)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tprimary key has been revoked\n"); log_debug ("\tprimary key has been revoked\n");
} }
else if (pk->has_expired) else if (pk->has_expired)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tprimary key has expired\n"); log_debug ("\tprimary key has expired\n");
} }
else if (!((pk->pubkey_usage & USAGE_MASK) & req_usage)) else if (!((pk->pubkey_usage & USAGE_MASK) & req_usage))
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tprimary key usage does not match: " log_debug ("\tprimary key usage does not match: "
"want=%x have=%x\n", req_usage, pk->pubkey_usage); "want=%x have=%x\n", req_usage, pk->pubkey_usage);
} }
else /* Okay. */ else /* Okay. */
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tprimary key may be used\n"); log_debug ("\tprimary key may be used\n");
latest_key = keyblock; latest_key = keyblock;
latest_date = pk->timestamp; latest_date = pk->timestamp;
@ -2490,13 +2490,13 @@ finish_lookup (GETKEY_CTX ctx)
if (!latest_key) if (!latest_key)
{ {
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tno suitable key found - giving up\n"); log_debug ("\tno suitable key found - giving up\n");
return 0; /* Not found. */ return 0; /* Not found. */
} }
found: found:
if (DBG_CACHE) if (DBG_LOOKUP)
log_debug ("\tusing key %08lX\n", log_debug ("\tusing key %08lX\n",
(ulong) keyid_from_pk (latest_key->pkt->pkt.public_key, NULL)); (ulong) keyid_from_pk (latest_key->pkt->pkt.public_key, NULL));

View File

@ -1093,7 +1093,7 @@ set_debug (const char *level)
opt.debug = DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE; opt.debug = DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE;
else if (!strcmp (level, "expert") || (numok && numlvl <= 8)) else if (!strcmp (level, "expert") || (numok && numlvl <= 8))
opt.debug = (DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE opt.debug = (DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE
|DBG_CACHE_VALUE|DBG_FILTER_VALUE|DBG_PACKET_VALUE); |DBG_CACHE_VALUE|DBG_LOOKUP|DBG_FILTER_VALUE|DBG_PACKET_VALUE);
else if (!strcmp (level, "guru") || numok) else if (!strcmp (level, "guru") || numok)
{ {
opt.debug = ~0; opt.debug = ~0;
@ -1123,7 +1123,7 @@ set_debug (const char *level)
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose); gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
if (opt.debug) if (opt.debug)
log_info ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", log_info ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
(opt.debug & DBG_PACKET_VALUE )? " packet":"", (opt.debug & DBG_PACKET_VALUE )? " packet":"",
(opt.debug & DBG_MPI_VALUE )? " mpi":"", (opt.debug & DBG_MPI_VALUE )? " mpi":"",
(opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"",
@ -1137,7 +1137,8 @@ set_debug (const char *level)
(opt.debug & DBG_EXTPROG_VALUE)? " extprog":"", (opt.debug & DBG_EXTPROG_VALUE)? " extprog":"",
(opt.debug & DBG_CARD_IO_VALUE)? " cardio":"", (opt.debug & DBG_CARD_IO_VALUE)? " cardio":"",
(opt.debug & DBG_ASSUAN_VALUE )? " assuan":"", (opt.debug & DBG_ASSUAN_VALUE )? " assuan":"",
(opt.debug & DBG_CLOCK_VALUE )? " clock":""); (opt.debug & DBG_CLOCK_VALUE )? " clock":"",
(opt.debug & DBG_LOOKUP_VALUE )? " lookup":"");
} }

View File

@ -273,13 +273,14 @@ struct {
#define DBG_FILTER_VALUE 8 /* debug internal filter handling */ #define DBG_FILTER_VALUE 8 /* debug internal filter handling */
#define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */ #define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */
#define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */ #define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
#define DBG_CACHE_VALUE 64 /* debug the cacheing */ #define DBG_CACHE_VALUE 64 /* debug the caching */
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */ #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
#define DBG_TRUST_VALUE 256 /* debug the trustdb */ #define DBG_TRUST_VALUE 256 /* debug the trustdb */
#define DBG_HASHING_VALUE 512 /* debug hashing operations */ #define DBG_HASHING_VALUE 512 /* debug hashing operations */
#define DBG_EXTPROG_VALUE 1024 /* debug external program calls */ #define DBG_EXTPROG_VALUE 1024 /* debug external program calls */
#define DBG_CARD_IO_VALUE 2048 /* debug smart card I/O. */ #define DBG_CARD_IO_VALUE 2048 /* debug smart card I/O. */
#define DBG_CLOCK_VALUE 4096 #define DBG_CLOCK_VALUE 4096
#define DBG_LOOKUP_VALUE 8192 /* debug the kety lookup */
/* Fixme: For now alias this value. */ /* Fixme: For now alias this value. */
#define DBG_ASSUAN_VALUE DBG_EXTPROG_VALUE #define DBG_ASSUAN_VALUE DBG_EXTPROG_VALUE
@ -296,6 +297,7 @@ struct {
#define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE) #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
#define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE) #define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE)
#define DBG_CLOCK (opt.debug & DBG_CLOCK_VALUE) #define DBG_CLOCK (opt.debug & DBG_CLOCK_VALUE)
#define DBG_LOOKUP (opt.debug & DBG_LOOKUP_VALUE)
/* FIXME: We need to check whey we did not put this into opt. */ /* FIXME: We need to check whey we did not put this into opt. */
#define DBG_MEMORY memory_debug_mode #define DBG_MEMORY memory_debug_mode