[svn] GnuPG - r5206 - in branches/STABLE-BRANCH-2-0: . agent doc g10 po scd sm

svn author wk cvs at cvs.gnupg.org
Thu Dec 3 20:13:24 CET 2009


Author: wk
Date: 2009-12-03 20:13:19 +0100 (Thu, 03 Dec 2009)
New Revision: 5206

Modified:
   branches/STABLE-BRANCH-2-0/NEWS
   branches/STABLE-BRANCH-2-0/agent/ChangeLog
   branches/STABLE-BRANCH-2-0/agent/gpg-agent.c
   branches/STABLE-BRANCH-2-0/doc/gpg-agent.texi
   branches/STABLE-BRANCH-2-0/doc/gpg.texi
   branches/STABLE-BRANCH-2-0/doc/gpgsm.texi
   branches/STABLE-BRANCH-2-0/doc/scdaemon.texi
   branches/STABLE-BRANCH-2-0/g10/ChangeLog
   branches/STABLE-BRANCH-2-0/g10/gpg.c
   branches/STABLE-BRANCH-2-0/po/be.po
   branches/STABLE-BRANCH-2-0/po/ca.po
   branches/STABLE-BRANCH-2-0/po/cs.po
   branches/STABLE-BRANCH-2-0/po/da.po
   branches/STABLE-BRANCH-2-0/po/de.po
   branches/STABLE-BRANCH-2-0/po/el.po
   branches/STABLE-BRANCH-2-0/po/eo.po
   branches/STABLE-BRANCH-2-0/po/es.po
   branches/STABLE-BRANCH-2-0/po/et.po
   branches/STABLE-BRANCH-2-0/po/fi.po
   branches/STABLE-BRANCH-2-0/po/fr.po
   branches/STABLE-BRANCH-2-0/po/gl.po
   branches/STABLE-BRANCH-2-0/po/hu.po
   branches/STABLE-BRANCH-2-0/po/id.po
   branches/STABLE-BRANCH-2-0/po/it.po
   branches/STABLE-BRANCH-2-0/po/ja.po
   branches/STABLE-BRANCH-2-0/po/nb.po
   branches/STABLE-BRANCH-2-0/po/pl.po
   branches/STABLE-BRANCH-2-0/po/pt.po
   branches/STABLE-BRANCH-2-0/po/pt_BR.po
   branches/STABLE-BRANCH-2-0/po/ro.po
   branches/STABLE-BRANCH-2-0/po/ru.po
   branches/STABLE-BRANCH-2-0/po/sk.po
   branches/STABLE-BRANCH-2-0/po/sv.po
   branches/STABLE-BRANCH-2-0/po/tr.po
   branches/STABLE-BRANCH-2-0/po/zh_CN.po
   branches/STABLE-BRANCH-2-0/po/zh_TW.po
   branches/STABLE-BRANCH-2-0/scd/ChangeLog
   branches/STABLE-BRANCH-2-0/scd/scdaemon.c
   branches/STABLE-BRANCH-2-0/sm/ChangeLog
   branches/STABLE-BRANCH-2-0/sm/gpgsm.c
Log:
Allow for numerical debug levels.


Modified: branches/STABLE-BRANCH-2-0/agent/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-2-0/agent/ChangeLog	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/agent/ChangeLog	2009-12-03 19:13:19 UTC (rev 5206)
@@ -1,3 +1,8 @@
+2009-12-03  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (set_debug): Allow for numerical debug leveles.  Print
+	active debug flags.
+
 2009-12-02  Werner Koch  <wk at g10code.com>
 
 	* trustlist.c (read_trustfiles): Store the pointer returned from

Modified: branches/STABLE-BRANCH-2-0/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-2-0/g10/ChangeLog	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/g10/ChangeLog	2009-12-03 19:13:19 UTC (rev 5206)
@@ -1,3 +1,8 @@
+2009-12-03  Werner Koch  <wk at g10code.com>
+
+	* gpg.c (set_debug): Allow for numerical debug levels.  Print
+	active debug flags.
+
 2009-09-28  Werner Koch  <wk at g10code.com>
 
 	* trustdb.c (get_validity_info): Take care of a NULL PK.  Fixes

Modified: branches/STABLE-BRANCH-2-0/scd/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-2-0/scd/ChangeLog	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/scd/ChangeLog	2009-12-03 19:13:19 UTC (rev 5206)
@@ -1,3 +1,8 @@
+2009-12-03  Werner Koch  <wk at g10code.com>
+
+	* scdaemon.c (set_debug): Allow for numerical debug levels.  Print
+	active debug flags.
+
 2009-09-03  Werner Koch  <wk at g10code.com>
 
 	* app-openpgp.c (do_decipher): Compute required Le.

Modified: branches/STABLE-BRANCH-2-0/sm/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-2-0/sm/ChangeLog	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/sm/ChangeLog	2009-12-03 19:13:19 UTC (rev 5206)
@@ -1,3 +1,8 @@
+2009-12-03  Werner Koch  <wk at g10code.com>
+
+	* gpgsm.c (set_debug): Allow for numerical debug levels.  Print
+	active debug flags.
+
 2009-10-16  Werner Koch  <wk at g10code.com>
 
 	* gpgsm.c (DEFAULT_INCLUDE_CERTS): New.

Modified: branches/STABLE-BRANCH-2-0/NEWS
===================================================================
--- branches/STABLE-BRANCH-2-0/NEWS	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/NEWS	2009-12-03 19:13:19 UTC (rev 5206)
@@ -4,7 +4,10 @@
  * The default for --inlucde-cert is now to include all certificates
    in the chain except for the root certificate.
 
+ * Numerical values may now be used as an alternative to the
+   debug-level keywords.
 
+
 Noteworthy changes in version 2.0.13 (2009-09-04)
 -------------------------------------------------
 

Modified: branches/STABLE-BRANCH-2-0/agent/gpg-agent.c
===================================================================
--- branches/STABLE-BRANCH-2-0/agent/gpg-agent.c	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/agent/gpg-agent.c	2009-12-03 19:13:19 UTC (rev 5206)
@@ -360,19 +360,30 @@
 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_COMMAND_VALUE;
-  else if (!strcmp (debug_level, "expert"))
+  else if (!strcmp (debug_level, "expert") || (numok && numlvl <= 8))
     opt.debug = (DBG_ASSUAN_VALUE|DBG_COMMAND_VALUE
                  |DBG_CACHE_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);
@@ -390,6 +401,17 @@
   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_COMMAND_VALUE)? " command":"",    
+              (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":"");
 }
  
 

Modified: branches/STABLE-BRANCH-2-0/doc/gpg-agent.texi
===================================================================
--- branches/STABLE-BRANCH-2-0/doc/gpg-agent.texi	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/doc/gpg-agent.texi	2009-12-03 19:13:19 UTC (rev 5206)
@@ -213,20 +213,26 @@
 @item --debug-level @var{level}
 @opindex debug-level
 Select the debug level for investigating problems. @var{level} may be
-one of:
+a numeric value or a keyword:
 
-   @table @code
-   @item none
-   no debugging at all.
-   @item basic  
-   some basic debug messages
-   @item advanced
-   more verbose debug messages
-   @item expert
-   even more detailed messages
-   @item guru
-   all of the debug messages you can get
-   @end table
+ at table @code
+ at item none
+No debugging at all.  A value of less than 1 may be used instead of
+the keyword.
+ at item basic  
+Some basic debug messages.  A value between 1 and 2 may be used
+instead of the keyword.
+ at item advanced
+More verbose debug messages.  A value between 3 and 5 may be used
+instead of the keyword.
+ at item expert
+Even more detailed messages.  A value between 6 and 8 may be used
+instead of the keyword.
+ at item guru
+All of the debug messages you can get. A value greater than 8 may be
+used instead of the keyword.  The creation of hash tracing files is
+only enabled if the keyword is used.
+ at end table
 
 How these messages are mapped to the actual debugging flags is not
 specified and may change with newer releases of this program. They are

Modified: branches/STABLE-BRANCH-2-0/doc/gpg.texi
===================================================================
--- branches/STABLE-BRANCH-2-0/doc/gpg.texi	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/doc/gpg.texi	2009-12-03 19:13:19 UTC (rev 5206)
@@ -2134,6 +2134,34 @@
 @opindex interactive
 Prompt before overwriting any files.
 
+ at item --debug-level @var{level}
+ at opindex debug-level
+Select the debug level for investigating problems. @var{level} may be
+a numeric value or by a keyword:
+
+ at table @code
+ at item none
+No debugging at all.  A value of less than 1 may be used instead of
+the keyword.
+ at item basic  
+Some basic debug messages.  A value between 1 and 2 may be used
+instead of the keyword.
+ at item advanced
+More verbose debug messages.  A value between 3 and 5 may be used
+instead of the keyword.
+ at item expert
+Even more detailed messages.  A value between 6 and 8 may be used
+instead of the keyword.
+ at item guru
+All of the debug messages you can get. A value greater than 8 may be
+used instead of the keyword.  The creation of hash tracing files is
+only enabled if the keyword is used.
+ at end table
+
+How these messages are mapped to the actual debugging flags is not
+specified and may change with newer releases of this program. They are
+however carefully selected to best aid in debugging.
+
 @item --debug @var{flags}
 @opindex debug
 Set debugging flags. All flags are or-ed and @var{flags} may

Modified: branches/STABLE-BRANCH-2-0/doc/gpgsm.texi
===================================================================
--- branches/STABLE-BRANCH-2-0/doc/gpgsm.texi	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/doc/gpgsm.texi	2009-12-03 19:13:19 UTC (rev 5206)
@@ -617,19 +617,25 @@
 @item --debug-level @var{level}
 @opindex debug-level
 Select the debug level for investigating problems. @var{level} may be
-one of:
+a numeric value or by a keyword:
 
 @table @code
 @item none
-no debugging at all.
+No debugging at all.  A value of less than 1 may be used instead of
+the keyword.
 @item basic  
-some basic debug messages
+Some basic debug messages.  A value between 1 and 2 may be used
+instead of the keyword.
 @item advanced
-more verbose debug messages
+More verbose debug messages.  A value between 3 and 5 may be used
+instead of the keyword.
 @item expert
-even more detailed messages
+Even more detailed messages.  A value between 6 and 8 may be used
+instead of the keyword.
 @item guru
-all of the debug messages you can get
+All of the debug messages you can get. A value greater than 8 may be
+used instead of the keyword.  The creation of hash tracing files is
+only enabled if the keyword is used.
 @end table
 
 How these messages are mapped to the actual debugging flags is not

Modified: branches/STABLE-BRANCH-2-0/doc/scdaemon.texi
===================================================================
--- branches/STABLE-BRANCH-2-0/doc/scdaemon.texi	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/doc/scdaemon.texi	2009-12-03 19:13:19 UTC (rev 5206)
@@ -123,20 +123,26 @@
 
 @item --debug-level @var{level}
 @opindex debug-level
-Select the debug level for investigating problems. @var{level} may be
-one of:
+Select the debug level for investigating problems.  @var{level} may be
+a numeric value or a keyword:
 
 @table @code
 @item none
-no debugging at all.
+No debugging at all.  A value of less than 1 may be used instead of
+the keyword.
 @item basic  
-some basic debug messages
+Some basic debug messages.  A value between 1 and 2 may be used
+instead of the keyword.
 @item advanced
-more verbose debug messages
+More verbose debug messages.  A value between 3 and 5 may be used
+instead of the keyword.
 @item expert
-even more detailed messages
+Even more detailed messages.  A value between 6 and 8 may be used
+instead of the keyword.
 @item guru
-all of the debug messages you can get
+All of the debug messages you can get. A value greater than 8 may be
+used instead of the keyword.  The creation of hash tracing files is
+only enabled if the keyword is used.
 @end table
 
 How these messages are mapped to the actual debugging flags is not

Modified: branches/STABLE-BRANCH-2-0/g10/gpg.c
===================================================================
--- branches/STABLE-BRANCH-2-0/g10/gpg.c	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/g10/gpg.c	2009-12-03 19:13:19 UTC (rev 5206)
@@ -972,19 +972,30 @@
 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);
@@ -1002,6 +1013,22 @@
   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":"");
 }
 
 

Modified: branches/STABLE-BRANCH-2-0/po/be.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/ca.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/cs.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/da.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/de.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/el.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/eo.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/es.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/et.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/fi.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/fr.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/gl.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/hu.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/id.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/it.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/ja.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/nb.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/pl.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/pt.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/pt_BR.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/ro.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/ru.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/sk.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/sv.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/tr.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/zh_CN.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/po/zh_TW.po  [not shown]
Modified: branches/STABLE-BRANCH-2-0/scd/scdaemon.c
===================================================================
--- branches/STABLE-BRANCH-2-0/scd/scdaemon.c	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/scd/scdaemon.c	2009-12-03 19:13:19 UTC (rev 5206)
@@ -288,19 +288,30 @@
 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_ASSUAN_VALUE;
-  else if (!strcmp (level, "advanced"))
+  else if (!strcmp (level, "advanced") || (numok && numlvl <= 5))
     opt.debug = DBG_ASSUAN_VALUE|DBG_COMMAND_VALUE;
-  else if (!strcmp (level, "expert"))
+  else if (!strcmp (level, "expert") || (numok && numlvl <= 8))
     opt.debug = (DBG_ASSUAN_VALUE|DBG_COMMAND_VALUE
                  |DBG_CACHE_VALUE|DBG_CARD_IO_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);
@@ -318,6 +329,18 @@
   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%s\n",
+              (opt.debug & DBG_COMMAND_VALUE)? " command":"",    
+              (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":"",
+              (opt.debug & DBG_CARD_IO_VALUE)? " cardio":"");
 }
  
 

Modified: branches/STABLE-BRANCH-2-0/sm/gpgsm.c
===================================================================
--- branches/STABLE-BRANCH-2-0/sm/gpgsm.c	2009-12-03 18:04:40 UTC (rev 5205)
+++ branches/STABLE-BRANCH-2-0/sm/gpgsm.c	2009-12-03 19:13:19 UTC (rev 5206)
@@ -636,23 +636,34 @@
 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;
@@ -667,6 +678,17 @@
   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":"" );
 }
  
 




More information about the Gnupg-commits mailing list