summaryrefslogtreecommitdiffstats
path: root/sm
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2009-12-03 19:04:40 +0100
committerWerner Koch <wk@gnupg.org>2009-12-03 19:04:40 +0100
commitcb5491bfaf8f9c24652af8f02ac21ca2a1cb884d (patch)
tree884ff5e015bd066e13e1e920566b3445db8c9503 /sm
parentFix usage of realloc. (diff)
downloadgnupg2-cb5491bfaf8f9c24652af8f02ac21ca2a1cb884d.tar.xz
gnupg2-cb5491bfaf8f9c24652af8f02ac21ca2a1cb884d.zip
support numeric debug levels.
Diffstat (limited to 'sm')
-rw-r--r--sm/ChangeLog5
-rw-r--r--sm/gpgsm.c36
2 files changed, 34 insertions, 7 deletions
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 167316330..39ae4df40 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-03 Werner Koch <wk@g10code.com>
+
+ * gpgsm.c (set_debug): Allow for numerical debug leveles. Print
+ active debug flags.
+
2009-12-02 Werner Koch <wk@g10code.com>
* verify.c (gpgsm_verify): Add audit info on hash algorithms.
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 6e7cd8406..834bcce23 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -648,23 +648,34 @@ set_opt_session_env (const char *name, const char *value)
static void
set_debug (void)
{
+ int numok = (debug_level && digitp (debug_level));
+ int numlvl = numok? atoi (debug_level) : 0;
+
if (!debug_level)
;
- else if (!strcmp (debug_level, "none"))
+ else if (!strcmp (debug_level, "none") || (numok && numlvl < 1))
opt.debug = 0;
- else if (!strcmp (debug_level, "basic"))
+ else if (!strcmp (debug_level, "basic") || (numok && numlvl <= 2))
opt.debug = DBG_ASSUAN_VALUE;
- else if (!strcmp (debug_level, "advanced"))
+ else if (!strcmp (debug_level, "advanced") || (numok && numlvl <= 5))
opt.debug = DBG_ASSUAN_VALUE|DBG_X509_VALUE;
- else if (!strcmp (debug_level, "expert"))
+ else if (!strcmp (debug_level, "expert") || (numok && numlvl <= 8))
opt.debug = (DBG_ASSUAN_VALUE|DBG_X509_VALUE
|DBG_CACHE_VALUE|DBG_CRYPTO_VALUE);
- else if (!strcmp (debug_level, "guru"))
- opt.debug = ~0;
+ else if (!strcmp (debug_level, "guru") || numok)
+ {
+ opt.debug = ~0;
+ /* Unless the "guru" string has been used we don't want to allow
+ hashing debugging. The rationale is that people tend to
+ select the highest debug value and would then clutter their
+ disk with debug files which may reveal confidential data. */
+ if (numok)
+ opt.debug &= ~(DBG_HASHING_VALUE);
+ }
else
{
log_error (_("invalid debug-level `%s' given\n"), debug_level);
- gpgsm_exit(2);
+ gpgsm_exit (2);
}
opt.debug |= debug_value;
@@ -679,6 +690,17 @@ set_debug (void)
if (opt.debug & DBG_CRYPTO_VALUE )
gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
+
+ if (opt.debug)
+ log_info ("enabled debug flags:%s%s%s%s%s%s%s%s\n",
+ (opt.debug & DBG_X509_VALUE )? " x509":"",
+ (opt.debug & DBG_MPI_VALUE )? " mpi":"",
+ (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"",
+ (opt.debug & DBG_MEMORY_VALUE )? " memory":"",
+ (opt.debug & DBG_CACHE_VALUE )? " cache":"",
+ (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"",
+ (opt.debug & DBG_HASHING_VALUE)? " hashing":"",
+ (opt.debug & DBG_ASSUAN_VALUE )? " assuan":"" );
}