[git] GnuPG - branch, master, updated. gnupg-2.1.15-63-gde62347

by Werner Koch cvs at cvs.gnupg.org
Mon Sep 5 13:09:49 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  de623474db3ba402c9bbd872ab6f932f46cbdde9 (commit)
       via  0ac671f8a2b65a4b339f615c6420287a549779fa (commit)
      from  0a4a03e5310946b0866a0f6a34031eda7a240162 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit de623474db3ba402c9bbd872ab6f932f46cbdde9
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Sep 5 12:50:35 2016 +0200

    dirmngr: Exclude D lines from the IPC debug output.
    
    * dirmngr/dirmngr.h: Include asshelp.h.
    * dirmngr/server.c (server_local_s): Add inhibit_dara_logging fields.
    (data_line_write): Implement logging inhibit.
    (data_line_cookie_close): Print non-logged D lines.
    (cmd_wkd_get, cmd_ks_get, cmd_ks_fetch): Do not log D lines.
    (dirmngr_assuan_log_monitor): New.
    * dirmngr/dirmngr.c (main): Register monitor function.
    --
    
    In particular with large keys the D lines clutter the log output and
    make it unusable.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 2bb57b2..7f989a5 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -702,7 +702,7 @@ main (int argc, char **argv)
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
   assuan_sock_init ();
-  setup_libassuan_logging (&opt.debug, NULL);
+  setup_libassuan_logging (&opt.debug, dirmngr_assuan_log_monitor);
 
   setup_libgcrypt_logging ();
 
diff --git a/dirmngr/dirmngr.h b/dirmngr/dirmngr.h
index 6127386..d823519 100644
--- a/dirmngr/dirmngr.h
+++ b/dirmngr/dirmngr.h
@@ -32,6 +32,7 @@
 #include "../common/util.h"
 #include "../common/membuf.h"
 #include "../common/sysutils.h" /* (gnupg_fd_t) */
+#include "../common/asshelp.h"  /* (assuan_context_t) */
 #include "../common/i18n.h"
 #include "http.h"     /* (parsed_uri_t) */
 
@@ -196,6 +197,8 @@ ksba_cert_t get_issuing_cert_local (ctrl_t ctrl, const char *issuer);
 ksba_cert_t get_cert_local_ski (ctrl_t ctrl,
                                 const char *name, ksba_sexp_t keyid);
 gpg_error_t get_istrusted_from_client (ctrl_t ctrl, const char *hexfpr);
+int dirmngr_assuan_log_monitor (assuan_context_t ctx, unsigned int cat,
+                                const char *msg);
 void start_command_handler (gnupg_fd_t fd);
 gpg_error_t dirmngr_status (ctrl_t ctrl, const char *keyword, ...);
 gpg_error_t dirmngr_status_help (ctrl_t ctrl, const char *text);
diff --git a/dirmngr/server.c b/dirmngr/server.c
index 03adc61..b29628a 100644
--- a/dirmngr/server.c
+++ b/dirmngr/server.c
@@ -95,6 +95,13 @@ struct server_local_s
 
   /* State variable private to is_tor_running.  */
   int tor_state;
+
+  /* If the first both flags are set the assuan logging of data lines
+   * is suppressed.  The count variable is used to show the number of
+   * non-logged bytes.  */
+  size_t inhibit_data_logging_count;
+  unsigned int inhibit_data_logging : 1;
+  unsigned int inhibit_data_logging_now : 1;
 };
 
 
@@ -175,9 +182,14 @@ leave_cmd (assuan_context_t ctx, gpg_error_t err)
 static gpg_error_t
 data_line_write (assuan_context_t ctx, const void *buffer_arg, size_t size)
 {
+  ctrl_t ctrl = assuan_get_pointer (ctx);
   const char *buffer = buffer_arg;
   gpg_error_t err;
 
+  /* If we do not want logging, enable it it here.  */
+  if (ctrl && ctrl->server_local && ctrl->server_local->inhibit_data_logging)
+    ctrl->server_local->inhibit_data_logging_now = 1;
+
   if (opt.verbose && buffer && size)
     {
       /* Ease reading of output by sending a physical line at each LF.  */
@@ -193,14 +205,14 @@ data_line_write (assuan_context_t ctx, const void *buffer_arg, size_t size)
           if (err)
             {
               gpg_err_set_errno (EIO);
-              return err;
+              goto leave;
             }
           buffer += n;
           nbytes -= n;
           if (nbytes && (err=assuan_send_data (ctx, NULL, 0))) /* Flush line. */
             {
               gpg_err_set_errno (EIO);
-              return err;
+              goto leave;
             }
         }
       while (nbytes);
@@ -211,11 +223,18 @@ data_line_write (assuan_context_t ctx, const void *buffer_arg, size_t size)
       if (err)
         {
           gpg_err_set_errno (EIO);  /* For use by data_line_cookie_write.  */
-          return err;
+          goto leave;
         }
     }
 
-  return 0;
+ leave:
+  if (ctrl && ctrl->server_local && ctrl->server_local->inhibit_data_logging)
+    {
+      ctrl->server_local->inhibit_data_logging_now = 0;
+      ctrl->server_local->inhibit_data_logging_count += size;
+    }
+
+  return err;
 }
 
 
@@ -237,6 +256,16 @@ data_line_cookie_close (void *cookie)
 {
   assuan_context_t ctx = cookie;
 
+  if (DBG_IPC)
+    {
+      ctrl_t ctrl = assuan_get_pointer (ctx);
+
+      if (ctrl && ctrl->server_local
+          && ctrl->server_local->inhibit_data_logging
+          && ctrl->server_local->inhibit_data_logging_count)
+        log_debug ("(%zu bytes sent via D lines not shown)\n",
+                   ctrl->server_local->inhibit_data_logging_count);
+    }
   if (assuan_send_data (ctx, NULL, 0))
     {
       gpg_err_set_errno (EIO);
@@ -810,6 +839,7 @@ cmd_wkd_get (assuan_context_t ctx, char *line)
   char *encodedhash = NULL;
   int opt_submission_addr;
   int opt_policy_flags;
+  int no_log = 0;
 
   opt_submission_addr = has_option (line, "--submission-address");
   opt_policy_flags = has_option (line, "--policy-flags");
@@ -852,6 +882,7 @@ cmd_wkd_get (assuan_context_t ctx, char *line)
                        "/.well-known/openpgpkey/hu/",
                        encodedhash,
                        NULL);
+      no_log = 1;
     }
   if (!uri)
     {
@@ -869,8 +900,13 @@ cmd_wkd_get (assuan_context_t ctx, char *line)
                        "error setting up a data stream");
     else
       {
+        if (no_log)
+          ctrl->server_local->inhibit_data_logging = 1;
+        ctrl->server_local->inhibit_data_logging_now = 0;
+        ctrl->server_local->inhibit_data_logging_count = 0;
         err = ks_action_fetch (ctrl, uri, outfp);
         es_fclose (outfp);
+        ctrl->server_local->inhibit_data_logging = 0;
       }
   }
 
@@ -2079,8 +2115,12 @@ cmd_ks_get (assuan_context_t ctx, char *line)
     err = set_error (GPG_ERR_ASS_GENERAL, "error setting up a data stream");
   else
     {
+      ctrl->server_local->inhibit_data_logging = 1;
+      ctrl->server_local->inhibit_data_logging_now = 0;
+      ctrl->server_local->inhibit_data_logging_count = 0;
       err = ks_action_get (ctrl, ctrl->server_local->keyservers, list, outfp);
       es_fclose (outfp);
+      ctrl->server_local->inhibit_data_logging = 0;
     }
 
  leave:
@@ -2113,8 +2153,12 @@ cmd_ks_fetch (assuan_context_t ctx, char *line)
     err = set_error (GPG_ERR_ASS_GENERAL, "error setting up a data stream");
   else
     {
+      ctrl->server_local->inhibit_data_logging = 1;
+      ctrl->server_local->inhibit_data_logging_now = 0;
+      ctrl->server_local->inhibit_data_logging_count = 0;
       err = ks_action_fetch (ctrl, line, outfp);
       es_fclose (outfp);
+      ctrl->server_local->inhibit_data_logging = 0;
     }
 
  leave:
@@ -2356,6 +2400,30 @@ reset_notify (assuan_context_t ctx, char *line)
 }
 
 
+/* This function is called by our assuan log handler to test whether a
+ * log message shall really be printed.  The function must return
+ * false to inhibit the logging of MSG.  CAT gives the requested log
+ * category.  MSG might be NULL. */
+int
+dirmngr_assuan_log_monitor (assuan_context_t ctx, unsigned int cat,
+                            const char *msg)
+{
+  ctrl_t ctrl = assuan_get_pointer (ctx);
+
+  (void)cat;
+  (void)msg;
+
+  if (!ctrl || !ctrl->server_local)
+    return 1; /* Can't decide - allow logging.  */
+
+  if (!ctrl->server_local->inhibit_data_logging)
+    return 1; /* Not requested - allow logging.  */
+
+  /* Disallow logging if *_now is true.  */
+  return !ctrl->server_local->inhibit_data_logging_now;
+}
+
+
 /* Startup the server and run the main command loop.  With FD = -1,
    use stdin/stdout. */
 void

commit 0ac671f8a2b65a4b339f615c6420287a549779fa
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Sep 5 10:55:10 2016 +0200

    common: Add an assuan logging monitor.
    
    * common/asshelp.c (my_log_monitor): New var.
    (my_libassuan_log_handler): Run that monitor.
    (setup_libassuan_logging): Add arg to set a log monitor and change all
    callers.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index b8a5a3e..79c83a5 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -771,7 +771,7 @@ main (int argc, char **argv )
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
   assuan_sock_init ();
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   setup_libgcrypt_logging ();
   gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
diff --git a/common/asshelp.c b/common/asshelp.c
index c03e67b..bb01a03 100644
--- a/common/asshelp.c
+++ b/common/asshelp.c
@@ -69,6 +69,12 @@
 static int log_cats;
 #define TEST_LOG_CAT(x) (!! (log_cats & (1 << (x - 1))))
 
+/* The assuan log monitor used to temporary inhibit log messages from
+ * assuan.  */
+static int (*my_log_monitor) (assuan_context_t ctx,
+                              unsigned int cat,
+                              const char *msg);
+
 
 static int
 my_libassuan_log_handler (assuan_context_t ctx, void *hook,
@@ -76,8 +82,6 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
 {
   unsigned int dbgval;
 
-  (void)ctx;
-
   if (! TEST_LOG_CAT (cat))
     return 0;
 
@@ -85,6 +89,9 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
   if (!(dbgval & 1024))
     return 0; /* Assuan debugging is not enabled.  */
 
+  if (ctx && my_log_monitor && !my_log_monitor (ctx, cat, msg))
+    return 0; /* Temporary disabled.  */
+
   if (msg)
     log_string (GPGRT_LOG_DEBUG, msg);
 
@@ -95,7 +102,10 @@ my_libassuan_log_handler (assuan_context_t ctx, void *hook,
 /* Setup libassuan to use our own logging functions.  Should be used
    early at startup.  */
 void
-setup_libassuan_logging (unsigned int *debug_var_address)
+setup_libassuan_logging (unsigned int *debug_var_address,
+                         int (*log_monitor)(assuan_context_t ctx,
+                                            unsigned int cat,
+                                            const char *msg))
 {
   char *flagstr;
 
@@ -104,9 +114,11 @@ setup_libassuan_logging (unsigned int *debug_var_address)
     log_cats = atoi (flagstr);
   else /* Default to log the control channel.  */
     log_cats = (1 << (ASSUAN_LOG_CONTROL - 1));
+  my_log_monitor = log_monitor;
   assuan_set_log_cb (my_libassuan_log_handler, debug_var_address);
 }
 
+
 /* Change the Libassuan log categories to those given by NEWCATS.
    NEWCATS is 0 the default category of ASSUAN_LOG_CONTROL is
    selected.  Note, that setup_libassuan_logging overrides the values
diff --git a/common/asshelp.h b/common/asshelp.h
index 4eb1d92..609b203 100644
--- a/common/asshelp.h
+++ b/common/asshelp.h
@@ -38,7 +38,10 @@
 
 /*-- asshelp.c --*/
 
-void setup_libassuan_logging (unsigned int *debug_var_address);
+void setup_libassuan_logging (unsigned int *debug_var_address,
+                              int (*log_monitor)(assuan_context_t ctx,
+                                                 unsigned int cat,
+                                                 const char *msg));
 void set_libassuan_log_cats (unsigned int newcats);
 
 
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 0667e59..2bb57b2 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -702,7 +702,7 @@ main (int argc, char **argv)
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
   assuan_sock_init ();
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   setup_libgcrypt_logging ();
 
diff --git a/g10/gpg.c b/g10/gpg.c
index 0b0fb7e..9f7da05 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -2317,7 +2317,7 @@ main (int argc, char **argv)
     malloc_hooks.free = gcry_free;
     assuan_set_malloc_hooks (&malloc_hooks);
     assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
-    setup_libassuan_logging (&opt.debug);
+    setup_libassuan_logging (&opt.debug, NULL);
 
     /* Try for a version specific config file first */
     default_configname = get_default_configname ();
diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c
index 7976be4..7b46239 100644
--- a/g13/g13-syshelp.c
+++ b/g13/g13-syshelp.c
@@ -302,7 +302,7 @@ main ( int argc, char **argv)
   /* Prepare libassuan.  */
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   /*assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);*/
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   /* Setup a default control structure for command line mode.  */
   memset (&ctrl, 0, sizeof ctrl);
diff --git a/g13/g13.c b/g13/g13.c
index 7744855..33f82d6 100644
--- a/g13/g13.c
+++ b/g13/g13.c
@@ -431,7 +431,7 @@ main ( int argc, char **argv)
   /* Prepare libassuan.  */
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   /* Setup a default control structure for command line mode.  */
   memset (&ctrl, 0, sizeof ctrl);
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 514e3c2..bf54d95 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -433,7 +433,7 @@ main (int argc, char **argv )
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
   assuan_set_system_hooks (ASSUAN_SYSTEM_NPTH);
   assuan_sock_init ();
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   setup_libgcrypt_logging ();
   gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index e3b1e88..9bb3053 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -1006,7 +1006,7 @@ main ( int argc, char **argv)
   malloc_hooks.free = gcry_free;
   assuan_set_malloc_hooks (&malloc_hooks);
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   keybox_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
 
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index c0e34c4..660d1bd 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -211,7 +211,7 @@ main (int argc, char **argv)
   init_common_subsystems (&argc, &argv);
 
   assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
-  setup_libassuan_logging (&opt.debug);
+  setup_libassuan_logging (&opt.debug, NULL);
 
   /* Parse the command line. */
   pargs.argc  = &argc;

-----------------------------------------------------------------------

Summary of changes:
 agent/gpg-agent.c      |  2 +-
 common/asshelp.c       | 18 ++++++++++--
 common/asshelp.h       |  5 +++-
 dirmngr/dirmngr.c      |  2 +-
 dirmngr/dirmngr.h      |  3 ++
 dirmngr/server.c       | 76 +++++++++++++++++++++++++++++++++++++++++++++++---
 g10/gpg.c              |  2 +-
 g13/g13-syshelp.c      |  2 +-
 g13/g13.c              |  2 +-
 scd/scdaemon.c         |  2 +-
 sm/gpgsm.c             |  2 +-
 tools/gpg-wks-client.c |  2 +-
 12 files changed, 102 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list