diff options
author | Werner Koch <wk@gnupg.org> | 2009-12-03 19:04:40 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2009-12-03 19:04:40 +0100 |
commit | cb5491bfaf8f9c24652af8f02ac21ca2a1cb884d (patch) | |
tree | 884ff5e015bd066e13e1e920566b3445db8c9503 /g10 | |
parent | Fix usage of realloc. (diff) | |
download | gnupg2-cb5491bfaf8f9c24652af8f02ac21ca2a1cb884d.tar.xz gnupg2-cb5491bfaf8f9c24652af8f02ac21ca2a1cb884d.zip |
support numeric debug levels.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 5 | ||||
-rw-r--r-- | g10/gpg.c | 39 |
2 files changed, 38 insertions, 6 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 67a2eeafa..044369d06 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,8 @@ +2009-12-03 Werner Koch <wk@g10code.com> + + * gpg.c (set_debug): Allow for numerical debug leveles. Print + active debug flags. + 2009-11-27 Werner Koch <wk@g10code.com> * keyedit.c (cmds, keyedit_menu): New command "checkbkupkey". @@ -976,19 +976,30 @@ set_opt_session_env (const char *name, const char *value) static void set_debug (const char *level) { + int numok = (level && digitp (level)); + int numlvl = numok? atoi (level) : 0; + if (!level) ; - else if (!strcmp (level, "none")) + else if (!strcmp (level, "none") || (numok && numlvl < 1)) opt.debug = 0; - else if (!strcmp (level, "basic")) + else if (!strcmp (level, "basic") || (numok && numlvl <= 2)) opt.debug = DBG_MEMSTAT_VALUE; - else if (!strcmp (level, "advanced")) + else if (!strcmp (level, "advanced") || (numok && numlvl <= 5)) opt.debug = DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE; - else if (!strcmp (level, "expert")) + else if (!strcmp (level, "expert") || (numok && numlvl <= 8)) opt.debug = (DBG_MEMSTAT_VALUE|DBG_TRUST_VALUE|DBG_EXTPROG_VALUE |DBG_CACHE_VALUE|DBG_FILTER_VALUE|DBG_PACKET_VALUE); - else if (!strcmp (level, "guru")) - opt.debug = ~0; + else if (!strcmp (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"), level); @@ -1006,6 +1017,22 @@ set_debug (const char *level) if (opt.debug & DBG_IOBUF_VALUE ) iobuf_debug_mode = 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%s%s%s%s%s\n", + (opt.debug & DBG_PACKET_VALUE )? " packet":"", + (opt.debug & DBG_MPI_VALUE )? " mpi":"", + (opt.debug & DBG_CIPHER_VALUE )? " cipher":"", + (opt.debug & DBG_FILTER_VALUE )? " filter":"", + (opt.debug & DBG_IOBUF_VALUE )? " iobuf":"", + (opt.debug & DBG_MEMORY_VALUE )? " memory":"", + (opt.debug & DBG_CACHE_VALUE )? " cache":"", + (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"", + (opt.debug & DBG_TRUST_VALUE )? " trust":"", + (opt.debug & DBG_HASHING_VALUE)? " hashing":"", + (opt.debug & DBG_EXTPROG_VALUE)? " extprog":"", + (opt.debug & DBG_CARD_IO_VALUE)? " cardio":"", + (opt.debug & DBG_ASSUAN_VALUE )? " assuan":""); } |