diff options
author | Justus Winter <justus@g10code.com> | 2017-03-21 14:18:25 +0100 |
---|---|---|
committer | Justus Winter <justus@g10code.com> | 2017-03-21 14:18:25 +0100 |
commit | 88f1505f0613894d5544290a170119eb538921e5 (patch) | |
tree | df50a568c33abbff499516dd987363c5e5ed7c36 /dirmngr | |
parent | tests: Create temporary directories in '/tmp'. (diff) | |
download | gnupg2-88f1505f0613894d5544290a170119eb538921e5.tar.xz gnupg2-88f1505f0613894d5544290a170119eb538921e5.zip |
dirmngr: Load the hosts file into libdns.
* dirmngr/dns-stuff.c (libdns_init): Actually load the hosts file into
libdns.
--
Previously, connecting to key servers specified in /etc/hosts was not
possible because libdns' hosts structure was initialized, but not
filled with the content of the hosts file.
GnuPG-bug-id: 2977
Signed-off-by: Justus Winter <justus@g10code.com>
Diffstat (limited to 'dirmngr')
-rw-r--r-- | dirmngr/dns-stuff.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c index ec9a09523..78c70e139 100644 --- a/dirmngr/dns-stuff.c +++ b/dirmngr/dns-stuff.c @@ -533,11 +533,35 @@ libdns_init (void) ld.hosts = dns_hosts_open (&derr); if (!ld.hosts) { - log_error ("failed to load hosts file: %s\n", gpg_strerror (err)); err = libdns_error_to_gpg_error (derr); + log_error ("failed to initialize hosts file: %s\n", gpg_strerror (err)); goto leave; } + + { +#if HAVE_W32_SYSTEM + char *hosts_path = xtryasprintf ("%s\System32\drivers\etc\hosts", + getenv ("SystemRoot")); + if (! hosts_path) + { + err = gpg_error_from_syserror (); + goto leave; + } + + derr = dns_hosts_loadpath (ld.hosts, hosts_path); + xfree (hosts_path); +#else + derr = dns_hosts_loadpath (ld.hosts, "/etc/hosts"); +#endif + if (derr) + { + err = libdns_error_to_gpg_error (derr); + log_error ("failed to load hosts file: %s\n", gpg_strerror (err)); + goto leave; + } + } + /* dns_hints_local for stub mode, dns_hints_root for recursive. */ ld.hints = (recursive_resolver ? dns_hints_root (ld.resolv_conf, &derr) |