aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dns-stuff.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* dirmngr: Use IPv4 or IPv6 interface only if available.Werner Koch2019-11-121-0/+7
| | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (cached_inet_support): New variable. (dns_stuff_housekeeping): New. (check_inet_support): New. * dirmngr/http.c (connect_server): Use only detected interfaces. * dirmngr/dirmngr.c (housekeeping_thread): Flush the new cache. -- This currently works only for Windows but that is where users really ran into problems. The old workaround was to configure disable-ipv4 or disable-ipv6. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Print a WARNING status for DNS config problems.Werner Koch2018-07-251-5/+9
| | | | | | | | | | | | | | | | | | | | | * dirmngr/dirmngr-status.h: New. * dirmngr/dirmngr.h: Include dirmngr-status.h and move some prototypes to that file. * dirmngr/t-support.c: New. * dirmngr/Makefile.am (dirmngr_SOURCES): Add dirmngr-status.h. (t_common_src): Add t-support.c. * dirmngr/server.c (dirmngr_status_printf): Bypass if CTRL is NULL. * dirmngr/dns-stuff.c: Include dirmngr-status.h. (libdns_init): Print WARNING status line. Change call callers to take and pass a CTRL argument. * g10/call-dirmngr.c (ks_status_cb): Print info for new WARNING status. -- To test this you can change RESOLV_CONF_NAME in dns-stuff.c and run gpg --recv-key -v SOMETHING. Signed-off-by: Werner Koch <[email protected]>
* Spelling fixes in docs and comments.NIIBE Yutaka2017-04-281-1/+1
| | | | | | | | | | -- In addition, fix trailing spaces in tests/inittests. GnuPG-bug-id: 3121 Reported-by: ka7 (klemens) Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Fix alignment of ADDR.NIIBE Yutaka2017-04-131-2/+2
| | | | | | | | | | | * dirmngr/dns-stuff.h (dns_addrinfo_s): Use struct sockaddr_storage for size and alignment. * dirmngr/dns-stuff.c (resolve_name_libdns): Follow the change. (resolve_dns_name): Use struct sockaddr_storage. (resolve_addr_standard, resolve_dns_addr): Likewise. (resolve_dns_addr): Likewise. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: New option --disable-ipv6Werner Koch2017-04-031-0/+4
| | | | | | | | | | | | | | | | | | * dirmngr/dirmngr.h (struct opt): Add field 'disable_ipv6'. * dirmngr/dirmngr.c (oDisableIPv6): New const. (opts): New option --disable-ipv6. (parse_rereadable_options): Set that option. * dirmngr/dns-stuff.c (opt_disable_ipv6): New var. (set_dns_disable_ipv6): New. (resolve_name_standard): Make use of it. * dirmngr/ks-engine-finger.c (ks_finger_fetch): Take care of OPT.DISABLE_IPV6. * dirmngr/ks-engine-hkp.c (map_host): Ditto. (send_request): Ditto. * dirmngr/ks-engine-http.c (ks_http_fetch): Ditto. * dirmngr/ocsp.c (do_ocsp_request): Ditto. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New option --no-use-tor and internal changes.Werner Koch2017-02-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (disable_dns_tormode): New. * dirmngr/dirmngr.c (oNoUseTor): New const. (opts): New option --no-use-tor. (tor_mode): New var. (parse_rereadable_options): Change to use TOR_MODE. (dirmngr_use_tor): New. (set_tor_mode): Call disable_dns_tormode. Implement oNoUseTor. * dirmngr/dirmngr.h (opt): Remove field 'use_tor'. Replace all references by a call to dirmngr_use_tor(). * dirmngr/server.c (cmd_getinfo): Distinguish between default and enforced TOR_MODE. -- This patch replaces the global variable opt.use_tar by a function testing a file local mode flag. This patch prepares for a use-tor-if-available mode. GnuPG-bug-id: 2935 Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New option --disable-ipv4.Werner Koch2017-01-241-0/+4
| | | | | | | | | | | | | | | | | | | * dirmngr/dirmngr.c (oDisableIPv4): New const. (opts): New option --disable-ipv4. (parse_rereadable_options): Set that option. * dirmngr/dirmngr.h (opt): New field 'disable_ipv4'. * dirmngr/dns-stuff.c (opt_disable_ipv4): bew var. (set_dns_disable_ipv4): New. (resolve_name_standard): Skip v4 addresses when OPT_DISABLE_IPV4 is set. * dirmngr/ks-engine-hkp.c (map_host): Ditto. (send_request): Pass HTTP_FLAG_IGNORE_IPv4 if opt.disable_v4 is set. * dirmngr/crlfetch.c (crl_fetch): Ditto. * dirmngr/ks-engine-finger.c (ks_finger_fetch): Ditto. * dirmngr/ks-engine-http.c (ks_http_fetch): Ditto. * dirmngr/ocsp.c (do_ocsp_request): Ditto. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Change internal SRV lookup API.Werner Koch2017-01-081-0/+1
| | | | | | | | | | | | | * dirmngr/dns-stuff.c (get_dns_srv): Add args SERVICE and PROTO. * dirmngr/http.c (connect_server): Simplify SRV lookup. * dirmngr/ks-engine-hkp.c (map_host): Ditto. * dirmngr/t-dns-stuff.c (main): Adjust for changed get_dns_srv. -- This new API is more convenient because it includes commonly used code. Note that right now http.c's SRV record code is not used. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Make sure Tor mode is also set for DNS on SIGHUP.Werner Koch2017-01-031-3/+3
| | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (enable_dns_tormode): Always succeed. (reload_dns_stuff): Reset tor port. * dirmngr/dirmngr.c (set_tor_mode): Also enable Tor mode for DNS. (main): Remove warning that Tor mode may not fully work. * dirmngr/server.c (cmd_dns_cert): Remove explicit Tor for DNS initialization. * dirmngr/t-dns-stuff.c (main): Remove option --new-circuit and error checking for enable_dns_tormode. -- This patch also resets the port on SIGHUP so that after starting Tor SIGHUP is sufficient to use Tor. Without the SIGHUP and when not using the Tor browser Dirmngr would keep on trying the Tor browser port. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New option --resolver-timeout.Werner Koch2016-12-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (DEFAULT_TIMEOUT): New. (opt_timeout): New var. (set_dns_timeout): New. (libdns_res_open): Set the default timeout. (libdns_res_wait): Use configurable timeout. (resolve_name_libdns): Ditto. * dirmngr/dirmngr.c (oResolverTimeout): New const. (opts): New option --resolver-timeout. (parse_rereadable_options): Set that option. (main) <aGPGConfList>: Add --nameserver and --resolver-timeout. * tools/gpgconf-comp.c (gc_options_dirmngr): Add --resolver-timeout and --nameserver. * dirmngr/http.c (connect_server): Fix yesterday introduced bug in error diagnostic. -- This timeout is a pretty crude thing because libdns has a few other internal timeouts as well. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Fix problems with the getsrv function.Werner Koch2016-12-191-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* dirmngr: Use one context for all libdns queries.Werner Koch2016-12-161-0/+2
| | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (libdns_reinit_pending): New var. (enable_recursive_resolver): Set var. (set_dns_nameserver): Ditto. (libdns_init): Avoid double initialization. (libdns_deinit): New. (reload_dns_stuff): New. (libdns_res_open): Act upon LIBDNS_REINIT_PENDING. * dirmngr/t-dns-stuff.c (main): Call reload_dns_stuff to release memory. * dirmngr/dirmngr.c (cleanup): Ditto. (dirmngr_sighup_action): Call reload_dns_stuff to set LIBDNS_REINIT_PENDING. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New configure option --disable-libdns.Werner Koch2016-12-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Add option --disable-libdns (USE_LIBDNS): New ac_subst and am_conditional. (USE_C99_CFLAGS): Set only if libdns is used. * dirmngr/Makefile.am (dirmngr_SOURCES): Move dns.c and dns.h to ... (dirmngr_SOURCES) [USE_LIBDNS0: here. (t_common_src): Ditto. * dirmngr/dirmngr.c (oRecursiveResolver): New constant. (opts): New option "--recursive-resolver". (parse_rereadable_options): Set option. * dirmngr/t-dns-stuff.c (main): Add option --recursive-resolver. * dirmngr/server.c (cmd_getinfo): Depend output of "dnsinfo" on the new variables. * dirmngr/dns-stuff.c: Include dns.h only if USE_DNSLIB is defined. Also build and call dnslib functions only if USE_DNSLIB is defined. (recursive_resolver): New var. (enable_recursive_resolver): New func. (recursive_resolver_p): New func. -- In case users run into problems building GnuPG, the configure option allows to disable that support and continue w/o Tor support using the system resolver. --recursive-resolver was easy enough to implement and may be useful in some situation. It does not fully work, though. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Add option --standard-resolver.Werner Koch2016-12-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dirmngr/dirmngr.c (oStandardResolver): New constant. (opts): New option --standard-resolver. (parse_rereadable_options): Set option. * dirmngr/dns-stuff.c: Refactor all code to support the new option. (standard_resolver): New var. (enable_standard_resolver, standard_resolver_p): New func. * dirmngr/http.c (connect_server): Remove USE_DNS_SRV build conditional. * dirmngr/ks-engine-hkp.c (map_host): Ditto. * dirmngr/server.c (cmd_getinfo) <dnsinfo>: Take care of new option * configure.ac (HAVE_ADNS_IF_TORMODE): Remove var ADNSLIB. ac_define USE_ADNS in the adns checking code. Remove options --disable-dns-srv and --disable-dns-cert. Always look for the system resolver. Print warning if no system resolver was found. (USE_DNS_CERT, USE_DNS_SRV): Remove ac_defines. (HAVE_SYSTEM_RESOLVER): New ac_define. (USE_DNS_SRV): Remove am_conditional; not used anyway. -- This option allows for runtime switching to the system's standard resolver. This is mainly useful to work around possible bugs in the optional resolver libraries (as of now ADNS). Note that on Windows there is no code to use systems's resolver and thus for full functionality dirmngr must be build with a separate resolver. This patch also does way with configure options to disable the use of CERT and SRV records. Signed-off-by: Werner Koch <[email protected]>
* Change all http://www.gnu.org in license notices to https://Werner Koch2016-11-051-1/+1
| | | | --
* dirmngr: New option --nameserver.Werner Koch2015-11-121-0/+6
| | | | | | | | | | | | * dirmngr/dirmngr.c (oNameServer): New. (opts): Add --nameserver. (parse_rereadable_options): Act upon oNameServer. * dirmngr/dns-stuff.c (DEFAULT_NAMESERVER): New. (tor_nameserver): New. (set_dns_nameserver): New. (my_adns_init): Make name server configurable. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Change to new ADNS Tor mode init scheme.Werner Koch2015-11-091-1/+1
| | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (tor_credentials): New. (enable_dns_tormode): Add arg new_circuit and update tor_credentials. (my_adns_init): Rework to set Tor mode using a config file options and always use credentials. * dirmngr/server.c (cmd_dns_cert): Improve error message. * dirmngr/t-dns-stuff.c (main): Add option --new-circuit. -- Note that the option --new-circuit in t-dns-stuff is not really useful because a new circuit is also used for the first call to the function. Todo: We need to find a policy when to requrest a new curcuit and we also need to add credentials to the assuan_sock_connect calls. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Support Tor hidden services.Werner Koch2015-10-261-0/+3
| | | | | | | | | | | | | | * dirmngr/dns-stuff.c (is_onion_address): New. * dirmngr/ks-engine-hkp.c (hostinfo_s): Add field "onion". (map_host): Special case onion addresses. (ks_hkp_print_hosttable): Print an 'O' for an onion address. * dirmngr/http.c (connect_server): Special case onion addresses. -- Note that this requires the latest libassuan from git. Onion addresses are always support regardless of the --use-tor flag. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Add workaround for broken getaddrinfo.Werner Koch2015-10-251-0/+3
| | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (resolve_name_standard): On failure retry by first resolving the CNAME. (get_dns_cname): New. * dirmngr/t-dns-stuff.c (main): Add option --cname. -- At least the getaddrinfo implementation in glibc 2.19-13 from Debian returns EAI_NONAME if the CNAME points to a too long list of A/AAAA addresses. Looking at the wire the data is correctly returned from the server but getaddrinfo seems to get confused by truncation and retry. To fix this we resolve the CNAME again and call getaddrinfo again with the canonical name. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Implement a getnameinfo wrapper.Werner Koch2015-10-251-1/+20
| | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.h (DNS_NUMERICHOST): New. (DNS_WITHBRACKET): New. * dirmngr/dns-stuff.c (resolve_name_standard): Factor code out to... (map_eai_to_gpg_error): new. (resolve_addr_standard): New. (resolve_dns_addr): New. * dirmngr/ks-engine-hkp.c (is_ip_address): Move to ... * dirmngr/dns-stuff.c (is_ip_address): here. Add support for non bracketed v6 addresses. * dirmngr/t-dns-stuff.c: Remove header netdb.h. (main): Add option --bracket. Use resolve_dns_name instead of getnameinfo. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Do not use MAXDNAME.Werner Koch2015-10-221-6/+1
| | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.c (getsrv): Replace MAXDNAME. * dirmngr/dns-stuff.h (MAXDNAME): Remove. (struct srventry): Use a fixed value instead of MAXDNAME. * dirmngr/http.c (connect_server): Use DIMof instead of MAXDNAME. Malloc a helper array. -- Depending on the order of included headers it might be that we allocate the array with a different size than what we test against in another module. To make it more robust we use the actual known size of checking. A better would be to use a linked list and avoid these large arrays. Signed-off-by: Werner Koch <[email protected]>
* Move SRV RR code from common/ to dirmngr/.Werner Koch2015-10-221-0/+15
| | | | | | | | | | | | * common/srv.c: Merge into dirmngr/dns-stuff.c. Delete file. * common/srv.h: Merge into dirmngr/dns-stuff.h. Delete file. * common/Makefile.am (common_sources): Remove srv.c and srv.h. * g10/keyserver.c: Do not include srv.h. The code using it is anyway disabled. * dirmngr/http.c: Remove header srv.h and stubs. * dirmngr/t-dns-stuff.c: Add option --srv. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Implement a getaddrinfo wrapper.Werner Koch2015-10-211-0/+31
| | | | | | | | | | | | | | | | | | | * dirmngr/dns-stuff.h: Include some header files. (dns_addinfo_t, dns_addrinfo_s): New. * dirmngr/dns-stuff.c: Always include DNS related headers. (free_dns_addrinfo): New. (resolve_name_standard): New. (resolve_dns_name): New. * dirmngr/t-dns-stuff.c: Include netdb.h. (main): Keep old default mode with no args but else print outout of resolve_dns_name. Revamp option parser. -- This wrapper allows us to switch to ADNS and thus Tor for standard name resultion. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Rename file dns-cert.c.Werner Koch2015-10-211-0/+63
* dirmngr/dns-cert.c: Rename to dirmngr/dns-stuff.c. * dirmngr/dns-cert.h: Rename to dirmngr/dns-stuff.h and change includers. * dirmngr/t-dns-cert.c: Rename to dirmngr/t-dns-stuff.c. * dirmngr/Makefile.am: Adjust. Signed-off-by: Werner Koch <[email protected]>