[git] GnuPG - branch, master, updated. gnupg-2.1.0-65-gb72ece6

by Werner Koch cvs at cvs.gnupg.org
Mon Dec 8 11:14:47 CET 2014


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  b72ece6d74d3e385e818ead748eba0cb111b95b3 (commit)
       via  66ab8f807c96b778f2a2c82b58d3e15ac295e1b2 (commit)
      from  c50c11d5751f46ddb38244a5a07d8274e1e10922 (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 b72ece6d74d3e385e818ead748eba0cb111b95b3
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Dec 8 11:13:17 2014 +0100

    dirmngr: Return a proper error for all dead hosts.
    
    * dirmngr/ks-engine-hkp.c (map_host): Change to return an gpg_error_t.
    Return an error code for all dead hosts.
    (make_host_part): Change to return an gpg_error_t.  Change all
    callers.
    --
    
    The functions used to return an error code via ERRNO.  However, this
    does not allow to return extra error codes in a portable way.  Thus we
    change the function to directly return a gpg_error_t.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index 83e878a..0a86b5d 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -316,25 +316,30 @@ is_ip_address (const char *name)
    to choose one of the hosts.  For example we skip those hosts which
    failed for some time and we stick to one host for a time
    independent of DNS retry times.  If FORCE_RESELECT is true a new
-   host is always selected.  If R_HTTPFLAGS is not NULL if will
-   receive flags which are to be passed to http_open.  If R_HOST is
-   not NULL a malloced name of the pool is stored or NULL if it is not
-   a pool. */
-static char *
+   host is always selected.  The selected host is stored as a malloced
+   string at R_HOST; on error NULL is stored.  If R_HTTPFLAGS is not
+   NULL it will receive flags which are to be passed to http_open.  If
+   R_POOLNAME is not NULL a malloced name of the pool is stored or
+   NULL if it is not a pool. */
+static gpg_error_t
 map_host (ctrl_t ctrl, const char *name, int force_reselect,
-          unsigned int *r_httpflags, char **r_host)
+          char **r_host, unsigned int *r_httpflags, char **r_poolname)
 {
   hostinfo_t hi;
   int idx;
 
+  *r_host = NULL;
   if (r_httpflags)
     *r_httpflags = 0;
-  if (r_host)
-    *r_host = NULL;
+  if (r_poolname)
+    *r_poolname = NULL;
 
   /* No hostname means localhost.  */
   if (!name || !*name)
-    return xtrystrdup ("localhost");
+    {
+      *r_host = xtrystrdup ("localhost");
+      return *r_host? 0 : gpg_error_from_syserror ();
+    }
 
   /* See whether the host is in our table.  */
   idx = find_hostinfo (name);
@@ -350,14 +355,14 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect,
       reftblsize = 100;
       reftbl = xtrymalloc (reftblsize * sizeof *reftbl);
       if (!reftbl)
-        return NULL;
+        return gpg_error_from_syserror ();
       refidx = 0;
 
       idx = create_new_hostinfo (name);
       if (idx == -1)
         {
           xfree (reftbl);
-          return NULL;
+          return gpg_error_from_syserror ();
         }
       hi = hosttable[idx];
 
@@ -527,7 +532,7 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect,
           if (hi->poolidx == -1)
             {
               log_error ("no alive host found in pool '%s'\n", name);
-              return NULL;
+              return gpg_error (GPG_ERR_NO_KEYSERVER);
             }
         }
 
@@ -539,7 +544,7 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect,
   if (hi->dead)
     {
       log_error ("host '%s' marked as dead\n", hi->name);
-      return NULL;
+      return gpg_error (GPG_ERR_NO_KEYSERVER);
     }
 
   if (r_httpflags)
@@ -555,10 +560,24 @@ map_host (ctrl_t ctrl, const char *name, int force_reselect,
         *r_httpflags |= HTTP_FLAG_IGNORE_IPv6;
     }
 
-  if (r_host && hi->pool && hi->cname)
-    *r_host = xtrystrdup (hi->cname);
+  if (r_poolname && hi->pool && hi->cname)
+    {
+      *r_poolname = xtrystrdup (hi->cname);
+      if (!*r_poolname)
+        return gpg_error_from_syserror ();
+    }
 
-  return xtrystrdup (hi->name);
+  *r_host = xtrystrdup (hi->name);
+  if (!*r_host)
+    {
+      if (r_poolname)
+        {
+          xfree (*r_poolname);
+          *r_poolname = NULL;
+        }
+      return gpg_error_from_syserror ();
+    }
+  return 0;
 }
 
 
@@ -792,18 +811,20 @@ ks_hkp_help (ctrl_t ctrl, parsed_uri_t uri)
 
 
 /* Build the remote part of the URL from SCHEME, HOST and an optional
-   PORT.  Returns an allocated string or NULL on failure and sets
-   ERRNO.  If R_HTTPHOST is not NULL it receive a mallcoed string with
-   the poolname.  */
-static char *
+   PORT.  Returns an allocated string at R_HOSTPORT or NULL on failure
+   If R_POOLNAME is not NULL it receives a malloced string with the
+   poolname.  */
+static gpg_error_t
 make_host_part (ctrl_t ctrl,
                 const char *scheme, const char *host, unsigned short port,
                 int force_reselect,
-                unsigned int *r_httpflags, char **r_httphost)
+                char **r_hostport, unsigned int *r_httpflags, char **r_poolname)
 {
+  gpg_error_t err;
   char portstr[10];
   char *hostname;
-  char *hostport;
+
+  *r_hostport = NULL;
 
   /* Map scheme and port.  */
   if (!strcmp (scheme, "hkps") || !strcmp (scheme,"https"))
@@ -823,13 +844,23 @@ make_host_part (ctrl_t ctrl,
       /*fixme_do_srv_lookup ()*/
     }
 
-  hostname = map_host (ctrl, host, force_reselect, r_httpflags, r_httphost);
-  if (!hostname)
-    return NULL;
+  err = map_host (ctrl, host, force_reselect,
+                  &hostname, r_httpflags, r_poolname);
+  if (err)
+    return err;
 
-  hostport = strconcat (scheme, "://", hostname, ":", portstr, NULL);
+  *r_hostport = strconcat (scheme, "://", hostname, ":", portstr, NULL);
   xfree (hostname);
-  return hostport;
+  if (!*r_hostport)
+    {
+      if (r_poolname)
+        {
+          xfree (*r_poolname);
+          *r_poolname = NULL;
+        }
+      return gpg_error_from_syserror ();
+    }
+  return 0;
 }
 
 
@@ -842,11 +873,10 @@ ks_hkp_resolve (ctrl_t ctrl, parsed_uri_t uri)
   gpg_error_t err;
   char *hostport = NULL;
 
-  hostport = make_host_part (ctrl, uri->scheme, uri->host, uri->port, 1,
-                             NULL, NULL);
-  if (!hostport)
+  err = make_host_part (ctrl, uri->scheme, uri->host, uri->port, 1,
+                        &hostport, NULL, NULL);
+  if (err)
     {
-      err = gpg_error_from_syserror ();
       err = ks_printf_help (ctrl, "%s://%s:%hu: resolve failed: %s",
                             uri->scheme, uri->host, uri->port,
                             gpg_strerror (err));
@@ -1187,15 +1217,12 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
   {
     char *searchkey;
 
-    xfree (hostport);
+    xfree (hostport); hostport = NULL;
     xfree (httphost); httphost = NULL;
-    hostport = make_host_part (ctrl, uri->scheme, uri->host, uri->port,
-                               reselect, &httpflags, &httphost);
-    if (!hostport)
-      {
-        err = gpg_error_from_syserror ();
-        goto leave;
-      }
+    err = make_host_part (ctrl, uri->scheme, uri->host, uri->port, reselect,
+                          &hostport, &httpflags, &httphost);
+    if (err)
+      goto leave;
 
     searchkey = http_escape_string (pattern, EXTRA_ESCAPE_CHARS);
     if (!searchkey)
@@ -1330,15 +1357,12 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
   reselect = 0;
  again:
   /* Build the request string.  */
-  xfree (hostport);
+  xfree (hostport); hostport = NULL;
   xfree (httphost); httphost = NULL;
-  hostport = make_host_part (ctrl, uri->scheme, uri->host, uri->port,
-                             reselect, &httpflags, &httphost);
-  if (!hostport)
-    {
-      err = gpg_error_from_syserror ();
-      goto leave;
-    }
+  err = make_host_part (ctrl, uri->scheme, uri->host, uri->port, reselect,
+                        &hostport, &httpflags, &httphost);
+  if (err)
+    goto leave;
 
   xfree (request);
   request = strconcat (hostport,
@@ -1445,15 +1469,12 @@ ks_hkp_put (ctrl_t ctrl, parsed_uri_t uri, const void *data, size_t datalen)
   /* Build the request string.  */
   reselect = 0;
  again:
-  xfree (hostport);
+  xfree (hostport); hostport = NULL;
   xfree (httphost); httphost = NULL;
-  hostport = make_host_part (ctrl, uri->scheme, uri->host, uri->port,
-                             reselect, &httpflags, &httphost);
-  if (!hostport)
-    {
-      err = gpg_error_from_syserror ();
-      goto leave;
-    }
+  err = make_host_part (ctrl, uri->scheme, uri->host, uri->port, reselect,
+                        &hostport, &httpflags, &httphost);
+  if (err)
+    goto leave;
 
   xfree (request);
   request = strconcat (hostport, "/pks/add", NULL);

commit 66ab8f807c96b778f2a2c82b58d3e15ac295e1b2
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Dec 8 11:10:11 2014 +0100

    gpg: Write a status line for a failed --send-keys.
    
    * g10/keyserver.c (keyserver_put): Write an status error.

diff --git a/g10/keyserver.c b/g10/keyserver.c
index e3ad707..6b603cd 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1828,7 +1828,10 @@ keyserver_put (ctrl_t ctrl, strlist_t keyspecs,
           release_kbnode (keyblock);
           xfree (data);
           if (err)
-            log_error (_("keyserver send failed: %s\n"), gpg_strerror (err));
+            {
+              write_status_error ("keyserver_send", err);
+              log_error (_("keyserver send failed: %s\n"), gpg_strerror (err));
+            }
         }
     }
 

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

Summary of changes:
 dirmngr/ks-engine-hkp.c |  131 +++++++++++++++++++++++++++--------------------
 g10/keyserver.c         |    5 +-
 2 files changed, 80 insertions(+), 56 deletions(-)


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




More information about the Gnupg-commits mailing list