[git] GnuPG - branch, master, updated. gnupg-2.1.17-61-g915864e

by Werner Koch cvs at cvs.gnupg.org
Wed Jan 11 10:50:45 CET 2017


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  915864e7f0315b0c96315d0bcd48b1b93592353a (commit)
       via  da894c48ec3393e7c815f575daa5a52ab37cc102 (commit)
       via  02ab4b0085f8b4cdfe163d25ddd0fc80753d7f4a (commit)
       via  088d71d3671e74eb088386026f0e439a7e3b5543 (commit)
      from  7249ab0f95d1f6cb8ee61eefedc79801bb56398f (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 915864e7f0315b0c96315d0bcd48b1b93592353a
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 11 10:48:20 2017 +0100

    dirmngr: Remove warnings about unused global variables.
    
    * dirmngr/crlcache.c (oidstr_issuingDistributionPoint): Comment.
    * dirmngr/ocsp.c (oidstr_certHash): Comment.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/dirmngr/crlcache.c b/dirmngr/crlcache.c
index 07fa5b1..2e471cb 100644
--- a/dirmngr/crlcache.c
+++ b/dirmngr/crlcache.c
@@ -127,7 +127,7 @@
 
 
 static const char oidstr_crlNumber[] = "2.5.29.20";
-static const char oidstr_issuingDistributionPoint[] = "2.5.29.28";
+/* static const char oidstr_issuingDistributionPoint[] = "2.5.29.28"; */
 static const char oidstr_authorityKeyIdentifier[] = "2.5.29.35";
 
 
diff --git a/dirmngr/ocsp.c b/dirmngr/ocsp.c
index 8c893aa..9127cf7 100644
--- a/dirmngr/ocsp.c
+++ b/dirmngr/ocsp.c
@@ -44,7 +44,7 @@ static const char oidstr_ocsp[] = "1.3.6.1.5.5.7.48.1";
       HashAlgorithm    AlgorithmIdentifier,
       certificateHash OCTET STRING }
  */
-static const char oidstr_certHash[] = "1.3.36.8.3.13";
+/* static const char oidstr_certHash[] = "1.3.36.8.3.13"; */
 
 
 

commit da894c48ec3393e7c815f575daa5a52ab37cc102
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 11 10:35:46 2017 +0100

    dirmngr: Implement debug option "network" for http.
    
    * dirmngr/dirmngr.c (parse_rereadable_options): Set http debugging.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index f50e935..92984b6 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -651,6 +651,7 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
     }
 
   set_dns_verbose (opt.verbose, !!DBG_DNS);
+  http_set_verbose (opt.verbose, !!DBG_NETWORK);
 
   return 1; /* Handled. */
 }
diff --git a/doc/dirmngr.texi b/doc/dirmngr.texi
index 4448bf0..e27157c 100644
--- a/doc/dirmngr.texi
+++ b/doc/dirmngr.texi
@@ -198,9 +198,11 @@ however carefully selected to best aid in debugging.
 
 @item --debug @var{flags}
 @opindex debug
-This option is only useful for debugging and the behavior may change at
-any time without notice.  FLAGS are bit encoded and may be given in
-usual C-Syntax.
+Set debugging flags.  This option is only useful for debugging and its
+behavior may change with a new release.  All flags are or-ed and may
+be given in C syntax (e.g. 0x0042) or as a comma separated list of
+flag names.  To get a list of all supported flags the single word
+"help" can be used.
 
 @item --debug-all
 @opindex debug-all

commit 02ab4b0085f8b4cdfe163d25ddd0fc80753d7f4a
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 11 10:34:49 2017 +0100

    dirmngr: Add debug code to http.c.
    
    * dirmngr/http.c (opt_verbose, opt_debug): New vars.
    (http_set_verbose): New function.
    (_my_socket_new): Add debug output.
    (_my_socket_ref, _my_socket_unref, session_unref): Call log_debug if
    OPT_DEBUG has ben set to 2 in a debugger.
    (http_session_new, http_session_ref): Ditto.
    (send_request, http_start_data): Print debug output for the request.
    (parse_response): Change to use log_debug_string for the response.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/dirmngr/http.c b/dirmngr/http.c
index 0a47d9f..c1a60be 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006, 2009, 2010,
  *               2011 Free Software Foundation, Inc.
  * Copyright (C) 2014 Werner Koch
- * Copyright (C) 2015 g10 Code GmbH
+ * Copyright (C) 2015-2017 g10 Code GmbH
  *
  * This file is part of GnuPG.
  *
@@ -255,6 +255,12 @@ struct http_context_s
 };
 
 
+/* Two flags to enable verbose and debug mode.  Although currently not
+ * set-able a value > 1 for OPT_DEBUG enables debugging of the session
+ * reference counting.  */
+static int opt_verbose;
+static int opt_debug;
+
 /* The global callback for the verification function.  */
 static gpg_error_t (*tls_callback) (http_t, http_session_t, int);
 
@@ -330,9 +336,9 @@ _my_socket_new (int lnr, assuan_fd_t fd)
     }
   so->fd = fd;
   so->refcount = 1;
-  /* log_debug ("http.c:socket_new(%d): object %p for fd %d created\n", */
-  /*            lnr, so, so->fd); */
-  (void)lnr;
+  if (opt_debug)
+    log_debug ("http.c:%d:socket_new: object %p for fd %d created\n",
+               lnr, so, so->fd);
   return so;
 }
 #define my_socket_new(a) _my_socket_new (__LINE__, (a))
@@ -342,9 +348,9 @@ static my_socket_t
 _my_socket_ref (int lnr, my_socket_t so)
 {
   so->refcount++;
-  /* log_debug ("http.c:socket_ref(%d) object %p for fd %d refcount now %d\n", */
-  /*            lnr, so, so->fd, so->refcount); */
-  (void)lnr;
+  if (opt_debug > 1)
+    log_debug ("http.c:%d:socket_ref: object %p for fd %d refcount now %d\n",
+               lnr, so, so->fd, so->refcount);
   return so;
 }
 #define my_socket_ref(a) _my_socket_ref (__LINE__,(a))
@@ -360,9 +366,10 @@ _my_socket_unref (int lnr, my_socket_t so,
   if (so)
     {
       so->refcount--;
-      /* log_debug ("http.c:socket_unref(%d): object %p for fd %d ref now %d\n", */
-      /*            lnr, so, so->fd, so->refcount); */
-      (void)lnr;
+      if (opt_debug > 1)
+        log_debug ("http.c:%d:socket_unref: object %p for fd %d ref now %d\n",
+                   lnr, so, so->fd, so->refcount);
+
       if (!so->refcount)
         {
           if (preclose)
@@ -469,6 +476,15 @@ make_header_line (const char *prefix, const char *suffix,
 
 
 

+/* Set verbosity and debug mode for this module. */
+void
+http_set_verbose (int verbose, int debug)
+{
+  opt_verbose = verbose;
+  opt_debug = debug;
+}
+
+
 /* Register a non-standard global TLS callback function.  If no
    verification is desired a callback needs to be registered which
    always returns NULL.  */
@@ -562,9 +578,9 @@ session_unref (int lnr, http_session_t sess)
     return;
 
   sess->refcount--;
-  /* log_debug ("http.c:session_unref(%d): sess %p ref now %d\n", */
-  /*            lnr, sess, sess->refcount); */
-  (void)lnr;
+  if (opt_debug > 1)
+    log_debug ("http.c:%d:session_unref: sess %p ref now %d\n",
+               lnr, sess, sess->refcount);
   if (sess->refcount)
     return;
 
@@ -731,7 +747,8 @@ http_session_new (http_session_t *r_session, const char *tls_priority,
   }
 #endif /*!HTTP_USE_GNUTLS*/
 
-  /* log_debug ("http.c:session_new: sess %p created\n", sess); */
+  if (opt_debug > 1)
+    log_debug ("http.c:session_new: sess %p created\n", sess);
   err = 0;
 
 #if USE_TLS
@@ -754,8 +771,9 @@ http_session_ref (http_session_t sess)
   if (sess)
     {
       sess->refcount++;
-      /* log_debug ("http.c:session_ref: sess %p ref now %d\n", sess, */
-      /*            sess->refcount); */
+      if (opt_debug > 1)
+        log_debug ("http.c:session_ref: sess %p ref now %d\n",
+                   sess, sess->refcount);
     }
   return sess;
 }
@@ -937,6 +955,8 @@ http_start_data (http_t hd)
 {
   if (!hd->in_data)
     {
+      if (opt_debug || (hd->flags & HTTP_FLAG_LOG_RESP))
+        log_debug_with_string ("\r\n", "http.c:request-header:");
       es_fputs ("\r\n", hd->fp_write);
       es_fflush (hd->fp_write);
       hd->in_data = 1;
@@ -1881,7 +1901,8 @@ send_request (http_t hd, const char *httphost, const char *auth,
       return err;
     }
 
-  /* log_debug ("request:\n%s\nEND request\n", request); */
+  if (opt_debug || (hd->flags & HTTP_FLAG_LOG_RESP))
+    log_debug_with_string (request, "http.c:request:");
 
   /* First setup estream so that we can write even the first line
      using estream.  This is also required for the sake of gnutls. */
@@ -1916,6 +1937,8 @@ send_request (http_t hd, const char *httphost, const char *auth,
     {
       for (;headers; headers=headers->next)
         {
+          if (opt_debug || (hd->flags & HTTP_FLAG_LOG_RESP))
+            log_debug_with_string (headers->d, "http.c:request-header:");
           if ((es_fputs (headers->d, hd->fp_write) || es_fflush (hd->fp_write))
               || (es_fputs("\r\n",hd->fp_write) || es_fflush(hd->fp_write)))
             {
@@ -2167,8 +2190,7 @@ parse_response (http_t hd)
 	return GPG_ERR_EOF;
 
       if ((hd->flags & HTTP_FLAG_LOG_RESP))
-        log_info ("RESP: '%.*s'\n",
-                  (int)strlen(line)-(*line&&line[1]?2:0),line);
+        log_debug_with_string (line, "http.c:response:\n");
     }
   while (!*line);
 
@@ -2213,7 +2235,7 @@ parse_response (http_t hd)
       if ((*line == '\r' && line[1] == '\n') || *line == '\n')
 	*line = 0;
       if ((hd->flags & HTTP_FLAG_LOG_RESP))
-        log_info ("RESP: '%.*s'\n",
+        log_info ("http.c:RESP: '%.*s'\n",
                   (int)strlen(line)-(*line&&line[1]?2:0),line);
       if (*line)
         {
@@ -2341,6 +2363,9 @@ connect_server (const char *server, unsigned short port,
     {
 #ifdef ASSUAN_SOCK_TOR
 
+      if (opt_debug)
+        log_debug ("http.c:connect_server:onion: name='%s' port=%hu\n",
+                   server, port);
       sock = assuan_sock_connect_byname (server, port, 0, NULL,
                                          ASSUAN_SOCK_TOR);
       if (sock == ASSUAN_INVALID_FD)
@@ -2389,6 +2414,9 @@ connect_server (const char *server, unsigned short port,
     {
       dns_addrinfo_t aibuf, ai;
 
+      if (opt_debug)
+        log_debug ("http.c:connect_server: trying name='%s' port=%hu\n",
+                   serverlist[srv].target, port);
       err = resolve_dns_name (serverlist[srv].target, port, 0, SOCK_STREAM,
                               &aibuf, NULL);
       if (err)
@@ -2539,7 +2567,8 @@ cookie_read (void *cookie, void *buffer, size_t size)
 
       ntbtls_get_stream (c->session->tls_session, &in, &out);
       nread = es_fread (buffer, 1, size, in);
-      log_debug ("TLS network read: %d/%u\n", nread, size);
+      if (opt_debug)
+        log_debug ("TLS network read: %d/%u\n", nread, size);
     }
   else
 #elif HTTP_USE_GNUTLS
@@ -2631,7 +2660,8 @@ cookie_write (void *cookie, const void *buffer_arg, size_t size)
         es_fflush (out);
       else
         nwritten = es_fwrite (buffer, 1, size, out);
-      log_debug ("TLS network write: %d/%u\n", nwritten, size);
+      if (opt_debug)
+        log_debug ("TLS network write: %d/%u\n", nwritten, size);
     }
   else
 #elif HTTP_USE_GNUTLS
diff --git a/dirmngr/http.h b/dirmngr/http.h
index 32556a4..0b581fe 100644
--- a/dirmngr/http.h
+++ b/dirmngr/http.h
@@ -97,6 +97,8 @@ typedef struct http_session_s *http_session_t;
 struct http_context_s;
 typedef struct http_context_s *http_t;
 
+void http_set_verbose (int verbose, int debug);
+
 void http_register_tls_callback (gpg_error_t (*cb)(http_t,http_session_t,int));
 void http_register_tls_ca (const char *fname);
 void http_register_netactivity_cb (void (*cb)(void));

commit 088d71d3671e74eb088386026f0e439a7e3b5543
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jan 11 10:21:32 2017 +0100

    common: New function log_debug_with_string.
    
    * common/logging.c (do_logv): Factor some code out to ...
    (print_prefix): new.
    (log_logv): Add arg EXTRASTRING and print it.  Change all callers to
    pass NULL for it.
    (log_debug_with_string): New.  Uses EXTRASTRING.
    --
    
    This function can be used to print a human readable buffer in addition
    to a log message to the log stream.  This function will keep all lines
    together and prefix them with ">> ".
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/logging.c b/common/logging.c
index c06a34f..0db1860 100644
--- a/common/logging.c
+++ b/common/logging.c
@@ -665,31 +665,10 @@ log_get_stream ()
   return logstream;
 }
 
+
 static void
-do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
+print_prefix (int level, int leading_backspace)
 {
-  if (!logstream)
-    {
-#ifdef HAVE_W32_SYSTEM
-      char *tmp;
-
-      tmp = (no_registry
-             ? NULL
-             : read_w32_registry_string (NULL, GNUPG_REGISTRY_DIR,
-                                         "DefaultLogFile"));
-      log_set_file (tmp && *tmp? tmp : NULL);
-      xfree (tmp);
-#else
-      log_set_file (NULL); /* Make sure a log stream has been set.  */
-#endif
-      assert (logstream);
-    }
-
-  es_flockfile (logstream);
-  if (missing_lf && level != GPGRT_LOG_CONT)
-    es_putc_unlocked ('\n', logstream );
-  missing_lf = 0;
-
   if (level != GPGRT_LOG_CONT)
     { /* Note this does not work for multiple line logging as we would
        * need to print to a buffer first */
@@ -720,11 +699,9 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
         es_putc_unlocked (':', logstream);
       /* A leading backspace suppresses the extra space so that we can
          correctly output, programname, filename and linenumber. */
-      if (fmt && *fmt == '\b')
-        fmt++;
-      else
-        if (with_time || with_prefix || with_pid || force_prefixes)
-          es_putc_unlocked (' ', logstream);
+      if (!leading_backspace
+          && (with_time || with_prefix || with_pid || force_prefixes))
+        es_putc_unlocked (' ', logstream);
     }
 
   switch (level)
@@ -741,6 +718,40 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
       es_fprintf_unlocked (logstream,"[Unknown log level %d]: ", level);
       break;
     }
+}
+
+
+static void
+do_logv (int level, int ignore_arg_ptr, const char *extrastring,
+         const char *fmt, va_list arg_ptr)
+{
+  int leading_backspace = (fmt && *fmt == '\b');
+
+  if (!logstream)
+    {
+#ifdef HAVE_W32_SYSTEM
+      char *tmp;
+
+      tmp = (no_registry
+             ? NULL
+             : read_w32_registry_string (NULL, GNUPG_REGISTRY_DIR,
+                                         "DefaultLogFile"));
+      log_set_file (tmp && *tmp? tmp : NULL);
+      xfree (tmp);
+#else
+      log_set_file (NULL); /* Make sure a log stream has been set.  */
+#endif
+      assert (logstream);
+    }
+
+  es_flockfile (logstream);
+  if (missing_lf && level != GPGRT_LOG_CONT)
+    es_putc_unlocked ('\n', logstream );
+  missing_lf = 0;
+
+  print_prefix (level, leading_backspace);
+  if (leading_backspace)
+    fmt++;
 
   if (fmt)
     {
@@ -766,6 +777,48 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
         missing_lf = 1;
     }
 
+  /* If we have an EXTRASTRING print it now while we still hold the
+   * lock on the logstream.  */
+  if (extrastring)
+    {
+      int c;
+
+      if (missing_lf)
+        {
+          es_putc_unlocked ('\n', logstream);
+          missing_lf = 0;
+        }
+      print_prefix (level, leading_backspace);
+      es_fputs_unlocked (">> ", logstream);
+      missing_lf = 1;
+      while ((c = *extrastring++))
+        {
+          missing_lf = 1;
+          if (c == '\\')
+            es_fputs_unlocked ("\\\\", logstream);
+          else if (c == '\r')
+            es_fputs_unlocked ("\\r", logstream);
+          else if ((c == '\n'))
+            {
+              es_fputs_unlocked ("\\n\n", logstream);
+              if (*extrastring)
+                {
+                  print_prefix (level, leading_backspace);
+                  es_fputs_unlocked (">> ", logstream);
+                }
+              else
+                missing_lf = 0;
+            }
+          else
+            es_putc_unlocked (c, logstream);
+        }
+      if (missing_lf)
+        {
+          es_putc_unlocked ('\n', logstream);
+          missing_lf = 0;
+        }
+    }
+
   if (level == GPGRT_LOG_FATAL)
     {
       if (missing_lf)
@@ -804,7 +857,7 @@ log_log (int level, const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt) ;
-  do_logv (level, 0, fmt, arg_ptr);
+  do_logv (level, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
@@ -812,7 +865,7 @@ log_log (int level, const char *fmt, ...)
 void
 log_logv (int level, const char *fmt, va_list arg_ptr)
 {
-  do_logv (level, 0, fmt, arg_ptr);
+  do_logv (level, 0, NULL, fmt, arg_ptr);
 }
 
 
@@ -821,7 +874,7 @@ do_log_ignore_arg (int level, const char *str, ...)
 {
   va_list arg_ptr;
   va_start (arg_ptr, str);
-  do_logv (level, 1, str, arg_ptr);
+  do_logv (level, 1, NULL, str, arg_ptr);
   va_end (arg_ptr);
 }
 
@@ -843,7 +896,7 @@ log_info (const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
-  do_logv (GPGRT_LOG_INFO, 0, fmt, arg_ptr);
+  do_logv (GPGRT_LOG_INFO, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
@@ -854,7 +907,7 @@ log_error (const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
-  do_logv (GPGRT_LOG_ERROR, 0, fmt, arg_ptr);
+  do_logv (GPGRT_LOG_ERROR, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
   /* Protect against counter overflow.  */
   if (errorcount < 30000)
@@ -868,7 +921,7 @@ log_fatal (const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
-  do_logv (GPGRT_LOG_FATAL, 0, fmt, arg_ptr);
+  do_logv (GPGRT_LOG_FATAL, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
   abort (); /* Never called; just to make the compiler happy.  */
 }
@@ -880,7 +933,7 @@ log_bug (const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
-  do_logv (GPGRT_LOG_BUG, 0, fmt, arg_ptr);
+  do_logv (GPGRT_LOG_BUG, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
   abort (); /* Never called; just to make the compiler happy.  */
 }
@@ -892,7 +945,21 @@ log_debug (const char *fmt, ...)
   va_list arg_ptr ;
 
   va_start (arg_ptr, fmt);
-  do_logv (GPGRT_LOG_DEBUG, 0, fmt, arg_ptr);
+  do_logv (GPGRT_LOG_DEBUG, 0, NULL, fmt, arg_ptr);
+  va_end (arg_ptr);
+}
+
+
+/* The same as log_debug but at the end of the output STRING is
+ * printed with LFs expanded to include the prefix and a final --end--
+ * marker.  */
+void
+log_debug_with_string (const char *string, const char *fmt, ...)
+{
+  va_list arg_ptr ;
+
+  va_start (arg_ptr, fmt);
+  do_logv (GPGRT_LOG_DEBUG, 0, string, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
@@ -903,7 +970,7 @@ log_printf (const char *fmt, ...)
   va_list arg_ptr;
 
   va_start (arg_ptr, fmt);
-  do_logv (fmt ? GPGRT_LOG_CONT : GPGRT_LOG_BEGIN, 0, fmt, arg_ptr);
+  do_logv (fmt ? GPGRT_LOG_CONT : GPGRT_LOG_BEGIN, 0, NULL, fmt, arg_ptr);
   va_end (arg_ptr);
 }
 
diff --git a/common/logging.h b/common/logging.h
index 8edc5c9..ed1d3b9 100644
--- a/common/logging.h
+++ b/common/logging.h
@@ -96,6 +96,8 @@ void log_fatal (const char *fmt, ...)  GPGRT_ATTR_NR_PRINTF(1,2);
 void log_error (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
 void log_info (const char *fmt, ...)   GPGRT_ATTR_PRINTF(1,2);
 void log_debug (const char *fmt, ...)  GPGRT_ATTR_PRINTF(1,2);
+void log_debug_with_string (const char *string, const char *fmt,
+                            ...) GPGRT_ATTR_PRINTF(2,3);
 void log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2);
 void log_flush (void);
 

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

Summary of changes:
 common/logging.c   | 141 +++++++++++++++++++++++++++++++++++++++--------------
 common/logging.h   |   2 +
 dirmngr/crlcache.c |   2 +-
 dirmngr/dirmngr.c  |   1 +
 dirmngr/http.c     |  74 +++++++++++++++++++---------
 dirmngr/http.h     |   2 +
 dirmngr/ocsp.c     |   2 +-
 doc/dirmngr.texi   |   8 +--
 8 files changed, 168 insertions(+), 64 deletions(-)


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




More information about the Gnupg-commits mailing list