[git] GnuPG - branch, master, updated. gnupg-2.1.9-54-g1e34007
by Werner Koch
cvs at cvs.gnupg.org
Wed Oct 21 22:45:31 CEST 2015
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 1e34007c972c1d7730cfcacd88f6bbebba7dec1d (commit)
via b6af3377e14fad35b9c6041b11888cabce6e8a56 (commit)
via 6fafda979df8e7e117f8e6929bcce89513a6e746 (commit)
from 03e230f0ea62fa7ec363e727ea1cf1344643464f (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 1e34007c972c1d7730cfcacd88f6bbebba7dec1d
Author: Werner Koch <wk at gnupg.org>
Date: Wed Oct 21 22:41:12 2015 +0200
dirmngr: Use the new DNS wrapper for the HTTP module.
* dirmngr/t-http.c (main): Init assuan sockets.
* dirmngr/http.c: Include dns-stuff.h.
(connect_server)[!HAVE_GETADDRINFO]: Remove all code.
(connect_server): Change to use resolve_dns_name.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/dirmngr/http.c b/dirmngr/http.c
index f49d3d0..19d5f8f 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -98,6 +98,7 @@
#include "util.h"
#include "i18n.h"
+#include "dns-stuff.h"
#include "http.h"
#ifdef USE_DNS_SRV
# include "srv.h"
@@ -2213,6 +2214,7 @@ static assuan_fd_t
connect_server (const char *server, unsigned short port,
unsigned int flags, const char *srvtag, int *r_host_not_found)
{
+ gpg_error_t err;
assuan_fd_t sock = ASSUAN_INVALID_FD;
int srvcount = 0;
int hostfound = 0;
@@ -2293,36 +2295,36 @@ connect_server (const char *server, unsigned short port,
srvcount = 1;
}
-#ifdef HAVE_GETADDRINFO
connected = 0;
for (srv=0; srv < srvcount && !connected; srv++)
{
- struct addrinfo hints, *res, *ai;
- char portstr[35];
+ dns_addrinfo_t aibuf, ai;
- snprintf (portstr, sizeof portstr, "%hu", port);
- memset (&hints, 0, sizeof (hints));
- hints.ai_socktype = SOCK_STREAM;
- if (getaddrinfo (serverlist[srv].target, portstr, &hints, &res))
- continue; /* Not found - try next one. */
+ err = resolve_dns_name (serverlist[srv].target, port, 0, SOCK_STREAM,
+ &aibuf, NULL);
+ if (err)
+ {
+ log_info ("resolving '%s' failed: %s\n",
+ serverlist[srv].target, gpg_strerror (err));
+ continue; /* Not found - try next one. */
+ }
hostfound = 1;
- for (ai = res; ai && !connected; ai = ai->ai_next)
+ for (ai = aibuf; ai && !connected; ai = ai->next)
{
- if (ai->ai_family == AF_INET && (flags & HTTP_FLAG_IGNORE_IPv4))
+ if (ai->family == AF_INET && (flags & HTTP_FLAG_IGNORE_IPv4))
continue;
- if (ai->ai_family == AF_INET6 && (flags & HTTP_FLAG_IGNORE_IPv6))
+ if (ai->family == AF_INET6 && (flags & HTTP_FLAG_IGNORE_IPv6))
continue;
if (sock != ASSUAN_INVALID_FD)
assuan_sock_close (sock);
- sock = assuan_sock_new (ai->ai_family, ai->ai_socktype,
- ai->ai_protocol);
+ sock = assuan_sock_new (ai->family, ai->socktype, ai->protocol);
if (sock == ASSUAN_INVALID_FD)
{
int save_errno = errno;
log_error ("error creating socket: %s\n", strerror (errno));
- freeaddrinfo (res);
+ free_dns_addrinfo (aibuf);
xfree (serverlist);
errno = save_errno;
return ASSUAN_INVALID_FD;
@@ -2330,77 +2332,15 @@ connect_server (const char *server, unsigned short port,
anyhostaddr = 1;
my_unprotect ();
- ret = assuan_sock_connect (sock, ai->ai_addr, ai->ai_addrlen);
+ ret = assuan_sock_connect (sock, ai->addr, ai->addrlen);
my_protect ();
if (ret)
last_errno = errno;
else
connected = 1;
}
- freeaddrinfo (res);
- }
-#else /* !HAVE_GETADDRINFO */
- connected = 0;
- for (srv=0; srv < srvcount && !connected; srv++)
- {
- int i;
- struct hostent *host = NULL;
- struct sockaddr_in addr;
-
- /* Note: This code is not thread-safe. */
-
- memset (&addr, 0, sizeof (addr));
- host = gethostbyname (serverlist[srv].target);
- if (!host)
- continue;
- hostfound = 1;
-
- if (sock != ASSUAN_INVALID_FD)
- assuan_sock_close (sock);
- sock = assuan_sock_new (host->h_addrtype, SOCK_STREAM, 0);
- if (sock == ASSUAN_INVALID_FD)
- {
- log_error ("error creating socket: %s\n", strerror (errno));
- xfree (serverlist);
- return ASSUAN_INVALID_FD;
- }
-
- addr.sin_family = host->h_addrtype;
- if (addr.sin_family != AF_INET)
- {
- log_error ("unknown address family for '%s'\n",
- serverlist[srv].target);
- xfree (serverlist);
- return ASSUAN_INVALID_FD;
- }
- addr.sin_port = htons (serverlist[srv].port);
- if (host->h_length != 4)
- {
- log_error ("illegal address length for '%s'\n",
- serverlist[srv].target);
- xfree (serverlist);
- return ASSUAN_INVALID_FD;
- }
-
- /* Try all A records until one responds. */
- for (i = 0; host->h_addr_list[i] && !connected; i++)
- {
- anyhostaddr = 1;
- memcpy (&addr.sin_addr, host->h_addr_list[i], host->h_length);
- my_unprotect ();
- ret = assuan_sock_connect (sock,
- (struct sockaddr *) &addr, sizeof (addr));
- my_protect ();
- if (ret)
- last_errno = errno;
- else
- {
- connected = 1;
- break;
- }
- }
+ free_dns_addrinfo (aibuf);
}
-#endif /* !HAVE_GETADDRINFO */
xfree (serverlist);
diff --git a/dirmngr/t-http.c b/dirmngr/t-http.c
index 41b2dd1..816b744 100644
--- a/dirmngr/t-http.c
+++ b/dirmngr/t-http.c
@@ -243,6 +243,9 @@ main (int argc, char **argv)
if (!cafile)
cafile = prepend_srcdir ("tls-ca.pem");
+ /* http.c makes use of the assuan socket wrapper. */
+ assuan_sock_init ();
+
#if HTTP_USE_NTBTLS
(void)err;
commit b6af3377e14fad35b9c6041b11888cabce6e8a56
Author: Werner Koch <wk at gnupg.org>
Date: Wed Oct 21 22:38:21 2015 +0200
dirmngr: Allow use of http.c if USE_NPTH is not defined.
* dirmngr/http.c (send_request): Always set the gnutls pull/push
functions.
(my_npth_read): Rename to ...
(my_gnutls_read) .. this. Use system read if !USE_NPTH.
(my_npth_write): Rename to ...
(my_gnutls_write) .. this. Use system write if !USE_NPTH.
--
This is necessary to run t-http because we once switched to a ref
counted object with the socket descriptor.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/dirmngr/http.c b/dirmngr/http.c
index 90dfc08..f49d3d0 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -400,20 +400,28 @@ _my_socket_unref (int lnr, my_socket_t so,
#define my_socket_unref(a,b,c) _my_socket_unref (__LINE__,(a),(b),(c))
-#if defined (USE_NPTH) && defined(HTTP_USE_GNUTLS)
+#ifdef HTTP_USE_GNUTLS
static ssize_t
-my_npth_read (gnutls_transport_ptr_t ptr, void *buffer, size_t size)
+my_gnutls_read (gnutls_transport_ptr_t ptr, void *buffer, size_t size)
{
my_socket_t sock = ptr;
+#if USE_NPTH
return npth_read (sock->fd, buffer, size);
+#else
+ return read (sock->fd, buffer, size);
+#endif
}
static ssize_t
-my_npth_write (gnutls_transport_ptr_t ptr, const void *buffer, size_t size)
+my_gnutls_write (gnutls_transport_ptr_t ptr, const void *buffer, size_t size)
{
my_socket_t sock = ptr;
+#if USE_NPTH
return npth_write (sock->fd, buffer, size);
+#else
+ return write (sock->fd, buffer, size);
+#endif
}
-#endif /*USE_NPTH && HTTP_USE_GNUTLS*/
+#endif /*HTTP_USE_GNUTLS*/
@@ -1641,12 +1649,10 @@ send_request (http_t hd, const char *httphost, const char *auth,
my_socket_ref (hd->sock);
gnutls_transport_set_ptr (hd->session->tls_session, hd->sock);
-#ifdef USE_NPTH
gnutls_transport_set_pull_function (hd->session->tls_session,
- my_npth_read);
+ my_gnutls_read);
gnutls_transport_set_push_function (hd->session->tls_session,
- my_npth_write);
-#endif
+ my_gnutls_write);
do
{
commit 6fafda979df8e7e117f8e6929bcce89513a6e746
Author: Werner Koch <wk at gnupg.org>
Date: Wed Oct 21 22:11:59 2015 +0200
dirmngr: Check that getaddrinfo is available.
* dirmngr/Makefile.am (t_http_SOURCES): Add dns-stuff.c.
(t_ldap_parse_uri_SOURCES): Ditto.
* dirmngr/dns-stuff.c: Bail out if neither ADNS nor getaddrinfo is
available.
--
We used to have replacement code for getaddrinfo and thus check for it
in configure. However, this was for the old http and dns-cert code
from common/. For dirmngr I made liberal use of getaddrinfo w/o
without checking. Just in case someone tries to build on an old
platform we now error our with a suitable #error.
Signed-off-by: Werner Koch <wk at gnupg.org>
diff --git a/dirmngr/Makefile.am b/dirmngr/Makefile.am
index 8cb1bb7..0d4400f 100644
--- a/dirmngr/Makefile.am
+++ b/dirmngr/Makefile.am
@@ -128,7 +128,7 @@ endif
# http tests
-t_http_SOURCES = t-http.c http.c
+t_http_SOURCES = t-http.c http.c dns-stuff.c
t_http_CFLAGS = -DWITHOUT_NPTH=1 \
$(LIBGCRYPT_CFLAGS) $(NTBTLS_CFLAGS) $(LIBGNUTLS_CFLAGS) \
$(GPG_ERROR_CFLAGS)
@@ -136,7 +136,8 @@ t_http_LDADD = $(t_common_ldadd) \
$(NTBTLS_LIBS) $(LIBGNUTLS_LIBS) $(DNSLIBS)
t_ldap_parse_uri_SOURCES = \
- t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h http.c \
+ t-ldap-parse-uri.c ldap-parse-uri.c ldap-parse-uri.h \
+ http.c dns-stuff.c \
$(ldap_url) $(t_common_src)
t_ldap_parse_uri_CFLAGS = -DWITHOUT_NPTH=1
t_ldap_parse_uri_LDADD = $(ldaplibs) $(t_common_ldadd)
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index 00d2b3e..3fa6054 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -46,6 +46,10 @@
# include <adns.h>
#endif
+#if !defined(HAVE_GETADDRINFO) && !defined(USE_ADNS)
+# error Either getaddrinfo or the ADNS libary is required.
+#endif
+
#include "util.h"
#include "host2net.h"
#include "dns-stuff.h"
-----------------------------------------------------------------------
Summary of changes:
dirmngr/Makefile.am | 5 ++-
dirmngr/dns-stuff.c | 4 ++
dirmngr/http.c | 118 ++++++++++++++--------------------------------------
dirmngr/t-http.c | 3 ++
4 files changed, 42 insertions(+), 88 deletions(-)
hooks/post-receive
--
The GNU Privacy Guard
http://git.gnupg.org
More information about the Gnupg-commits
mailing list