[Pkg-gnupg-commit] [gnupg2] 77/116: dirmngr: Implement hkps lookups using literal addresses.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Jan 24 04:40:56 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gnupg2.

commit e6aebfe3d0f16c483296fd125b66a44017fe15f4
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Jan 16 19:04:58 2017 +0100

    dirmngr: Implement hkps lookups using literal addresses.
    
    * dirmngr/ks-engine-hkp.c (map_host): For literal addresses do a
    reverse lookup.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>
---
 dirmngr/ks-engine-hkp.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/dirmngr/ks-engine-hkp.c b/dirmngr/ks-engine-hkp.c
index 8c171a5..08ef851 100644
--- a/dirmngr/ks-engine-hkp.c
+++ b/dirmngr/ks-engine-hkp.c
@@ -85,7 +85,7 @@ struct hostinfo_s
   time_t died_at;    /* The time the host was marked dead.  If this is
                         0 the host has been manually marked dead.  */
   char *cname;       /* Canonical name of the host.  Only set if this
-                        is a pool.  */
+                        is a pool or NAME has a numerical IP address.  */
   char *v4addr;      /* A string with the v4 IP address of the host.
                         NULL if NAME has a numeric IP address or no v4
                         address is available.  */
@@ -571,6 +571,34 @@ map_host (ctrl_t ctrl, const char *name, const char *srvtag, int force_reselect,
       hi = hosttable[hi->poolidx];
       assert (hi);
     }
+  else if (r_httphost && is_ip_address (hi->name))
+    {
+      /* This is a numerical IP address and not a pool.  We want to
+       * find the canonical name so that it can be used in the HTTP
+       * Host header.  Fixme: We should store that name in the
+       * hosttable. */
+      dns_addrinfo_t aibuf, ai;
+      char *host;
+
+      err = resolve_dns_name (hi->name, 0, 0, SOCK_STREAM, &aibuf, NULL);
+      if (!err)
+        {
+          for (ai = aibuf; ai; ai = ai->next)
+            {
+              if (ai->family == AF_INET6 || ai->family == AF_INET)
+                {
+                  err = resolve_dns_addr (ai->addr, ai->addrlen, 0, &host);
+                  if (!err)
+                    {
+                      /* Okay, we return the first found name.  */
+                      *r_httphost = host;
+                      break;
+                    }
+                }
+            }
+        }
+      free_dns_addrinfo (aibuf);
+    }
 
   if (hi->dead)
     {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list