aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/t-dns-stuff.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2016-12-19 22:27:02 +0000
committerWerner Koch <[email protected]>2016-12-19 22:27:02 +0000
commitaf8b68fae39b1378c769e0de6ba6437ea1aac7e3 (patch)
tree16bc96db023b812d21422caf3c029dcee0c91dcf /dirmngr/t-dns-stuff.c
parentbuild: Add target to sign the windows installer. (diff)
downloadgnupg-af8b68fae39b1378c769e0de6ba6437ea1aac7e3.tar.gz
gnupg-af8b68fae39b1378c769e0de6ba6437ea1aac7e3.zip
dirmngr: Fix problems with the getsrv function.
* dirmngr/dns-stuff.c (opt_debug, opt_verbose): New vars. (set_dns_verbose): New func. (libdns_switch_port_p): Add debug output. (resolve_dns_name): Ditto. (get_dns_cert): Ditto. (get_dns_cname): Ditto. (getsrv_libdns, getsrv_standard): Change SRVCOUNT to an unsigend int. (getsrv): Rename to ... ((get_dns_srv): this. Add arg R_COUNT and return an error. Add debug output. * dirmngr/http.c: Adjust for chnaged getsrv(). * dirmngr/ks-engine-hkp.c (map_host): Ditto. * dirmngr/t-dns-stuff.c (main): Ditto. Call set_dns_verbose. * dirmngr/dirmngr.c (parse_rereadable_options): Call set_dns_verbose. -- Due to our switch to Libdns getsrv didn't worked correctly because it returned -1 for an NXDOMAIN. However, it is perfectly okay to have no SRV record and thus we change the way this function is called to be aligned with the other functions and also map NXDOMAIN to a zero SRV record count. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--dirmngr/t-dns-stuff.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/dirmngr/t-dns-stuff.c b/dirmngr/t-dns-stuff.c
index dd8e21e2e..f58f3235a 100644
--- a/dirmngr/t-dns-stuff.c
+++ b/dirmngr/t-dns-stuff.c
@@ -157,6 +157,7 @@ main (int argc, char **argv)
exit (1);
}
+ set_dns_verbose (verbose, debug);
init_sockets ();
if (opt_tor)
@@ -234,19 +235,27 @@ main (int argc, char **argv)
else if (opt_srv)
{
struct srventry *srv;
- int rc,i;
+ unsigned int count;
+ int i;
- rc=getsrv (name? name : "_hkp._tcp.wwwkeys.pgp.net", &srv);
- printf("Count=%d\n",rc);
- for(i=0;i<rc;i++)
+ err = get_dns_srv (name? name : "_hkp._tcp.wwwkeys.pgp.net",
+ &srv, &count);
+ if (err)
+ printf ("get_dns_srv failed: %s <%s>\n",
+ gpg_strerror (err), gpg_strsource (err));
+ else
{
- printf("priority=%-8hu ",srv[i].priority);
- printf("weight=%-8hu ",srv[i].weight);
- printf("port=%-5hu ",srv[i].port);
- printf("target=%s\n",srv[i].target);
- }
+ printf ("count=%u\n",count);
+ for (i=0; i < count; i++)
+ {
+ printf("priority=%-8hu ",srv[i].priority);
+ printf("weight=%-8hu ",srv[i].weight);
+ printf("port=%-5hu ",srv[i].port);
+ printf("target=%s\n",srv[i].target);
+ }
- xfree(srv);
+ xfree(srv);
+ }
}
else /* Standard lookup. */
{
@@ -289,7 +298,7 @@ main (int argc, char **argv)
(opt_bracket? DNS_WITHBRACKET:0),
&host);
if (err)
- printf ("[resolve_dns_addr failed (2): %s]", gpg_strerror (err));
+ printf (" [resolve_dns_addr failed (2): %s]", gpg_strerror (err));
else
{
if (!is_ip_address (host))