aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dns-stuff.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* dirmngr: First patch to re-enable Tor support.Werner Koch2016-12-151-32/+100
| | | | | | | | | | | | * dirmngr/dns-stuff.c (SOCKS_PORT, TOR_PORT, TOR_PORT2): New constants. (libdns_init): Start adding tor support. (resolve_name_libdns): Pass socks hosts to dns_res_open. (get_dns_cert_libdns): Ditto. (getsrv_libdns): Ditto. (get_dns_cname_libdns): Ditto. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New configure option --disable-libdns.Werner Koch2016-12-141-5/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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: Implement CERT record lookup via libdns.Werner Koch2016-12-141-2/+188
| | | | | | | * dirmngr/dns-stuff.c (get_dns_cert_libdns): New. (get_dns_cert_standard): Fix URL malloc checking. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Implement CNAME and SRV record lookup via libdns.Werner Koch2016-12-141-64/+283
| | | | | | | | | | | | * dirmngr/dns-stuff.c (dns_free): New macro. (libdns): Move var to the top. (libdns_error_to_gpg_error): Map error codes to the new gpg-error codes. (resolve_name_libdns): Restructure code. (getsrv_libdns): New. (get_dns_cname_libdns): New. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Fix bugs in the standard resolver code.Werner Koch2016-12-141-24/+60
| | | | | | | | | | | | | | | * dirmngr/dns-stuff.c: Include dirmngr-err.h to set the correct error source. (get_h_errno_as_gpg_error): New. (get_dns_cert_libdns): Fix error code. (getsrv_libdns): Add arg R_COUNT and return an error code. (getsrv_standard): Ditto. Fix handling of res_query errors and provide the correct size for the return buffer. (getsrv): Adjust for changed worker functions. (get_dns_cname_standard): Fix handling of res_query errors and provide the correct size for the return buffer. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Add basic libdns supportJustus Winter2016-12-141-11/+219
| | | | | | | | | | | | | | | | * dirmngr/dns.c: New file. * dirmngr/dns.h: New file. * dirmngr/Makefile.am (dirmngr_SOURCES): Add new files. * dirmngr/dns-stuff.c: Include dns.h.xxx use libdns (libdns): New global var for the libdns state. (libdns_error_to_gpg_error): New. (libdns_init): New. (resolve_name_libdns): New. (get_dns_cert_libdns): New stub. (getsrv_libdns): New stub. (get_dns_cname_libdns): New stub. Signed-off-by: Justus Winter <[email protected]>
* dirmngr,build: Remove support for ADNS.Justus Winter2016-12-141-484/+24
| | | | | | | | | | | | | | | * autogen.rc: Remove '--with-adns' argument. * configure.ac: Remove check for ADNS. * dirmngr/dns-stuff.c: Remove all code that uses ADNS. * dirmngr/server.c (cmd_getinfo): Update status line. * doc/dirmngr.texi: Do not mention ADNS. -- We used ADNS to support queries over Tor. However, our patch to ADNS that adds Tor support was never accepted upstream. Furthermore, there are other shortcomings that let us to consider alternatives. Signed-off-by: Justus Winter <[email protected]>
* dirmngr: Add option --standard-resolver.Werner Koch2016-12-011-299/+394
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* dirmngr: Improve concurrency in the non-adns case.Werner Koch2016-11-101-2/+24
| | | | | | | | * dirmngr/dns-stuff.c (map_adns_status_to_gpg_error): New. (resolve_name_adns, get_dns_cert, get_dns_cname): Use that function. (getsrv) [!USE_ADNS]: Call res_query outside of nPth. 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: ADNS error handling fix.NIIBE Yutaka2016-10-271-4/+4
| | | | | | | | | | * dirmngr/dns-stuff.c (resolve_name_adns, get_dns_cert, get_dns_cname): Use gpg_error and gpg_err_code_from_errno to compose the error value. -- This fixes commits 6f1d8123d61b3efac94b4c61ee75bd947790ba42. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: More ADNS error fix.NIIBE Yutaka2016-10-271-4/+4
| | | | | | | | | * dirmngr/dns-stuff.c (get_dns_cert, getsrv, get_dns_cname): Fix return value. -- GnuPG-bug-id: 2745 Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Fix error return for ADNS.NIIBE Yutaka2016-10-271-1/+1
| | | | | | | | | | | * dirmngr/dns-stuff.c (resolve_name_adns): Use RET for return value. -- There are cases where libadns returns an error without setting the variable ERRNO. GnuPG-bug-id: 2745 Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Fix type.Justus Winter2016-09-201-1/+1
| | | | | | * dirmngr/dns-stuff.c (get_dns_cert): Fix type in fallback code. Signed-off-by: Justus Winter <[email protected]>
* dirmngr: fix for memory alignment.NIIBE Yutaka2016-02-151-6/+14
| | | | | | | | | * dirmngr/dns-stuff.c (get_dns_cert): Cast through void *. (getsrv, get_dns_cname): Make sure it's aligned for HEADER. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Build fix for FreeBSD (EAI macros)Werner Koch2016-01-271-0/+4
| | | | | | | | | * dirmngr/dns-stuff.c (map_eai_to_gpg_error): Map EAI_NODATA and EAI_ADDRFAMILY only if defined. -- Reported-by: Christoph Moench-Tegeder <[email protected]> Signed-off-by: Werner Koch <[email protected]>
* gpg: Suppress a warning.Neal H. Walfield2015-12-221-0/+2
| | | | | | | | * dirmngr/dns-stuff.c (enable_dns_tormode): Reference new_circuit to avoid a warning when ADNS is not available. -- Signed-off-by: Neal H. Walfield <[email protected]>
* dirmngr: Improve error handling.Justus Winter2015-12-011-3/+2
| | | | | | | | | | * dirmngr/dns-stuff.c (getsrv): Avoid looking at 'header' before checking for errors, but silently ignore errors when looking up SRV records. -- This is a follow-up to 946faaff. Signed-off-by: Justus Winter <[email protected]>
* dirmngr: Fix http lookups when libadns is used.Justus Winter2015-11-231-1/+1
| | | | | | | | * dirmngr/dns-stuff.c (resolve_name_adns): Fill in the port. -- Previously, sin_port was set to zero, making connect fail. Signed-off-by: Justus Winter <[email protected]>
* dirmngr: Fix SRV record lookups when using the system resolver.Justus Winter2015-11-231-2/+2
| | | | | | | | * dirmngr/dns-stuff.c (getsrv): Fix error handling. -- This fixes hkp server pools not using SRV records. Signed-off-by: Justus Winter <[email protected]>
* Fix typos found using codespell.Justus Winter2015-11-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * agent/cache.c: Fix typos. * agent/call-pinentry.c: Likewise. * agent/call-scd.c: Likewise. * agent/command-ssh.c: Likewise. * agent/command.c: Likewise. * agent/divert-scd.c: Likewise. * agent/findkey.c: Likewise. * agent/gpg-agent.c: Likewise. * agent/w32main.c: Likewise. * common/argparse.c: Likewise. * common/audit.c: Likewise. * common/audit.h: Likewise. * common/convert.c: Likewise. * common/dotlock.c: Likewise. * common/exechelp-posix.c: Likewise. * common/exechelp-w32.c: Likewise. * common/exechelp-w32ce.c: Likewise. * common/exechelp.h: Likewise. * common/helpfile.c: Likewise. * common/i18n.h: Likewise. * common/iobuf.c: Likewise. * common/iobuf.h: Likewise. * common/localename.c: Likewise. * common/logging.c: Likewise. * common/openpgp-oid.c: Likewise. * common/session-env.c: Likewise. * common/sexputil.c: Likewise. * common/sysutils.c: Likewise. * common/t-sexputil.c: Likewise. * common/ttyio.c: Likewise. * common/util.h: Likewise. * dirmngr/cdblib.c: Likewise. * dirmngr/certcache.c: Likewise. * dirmngr/crlcache.c: Likewise. * dirmngr/dirmngr-client.c: Likewise. * dirmngr/dirmngr.c: Likewise. * dirmngr/dirmngr_ldap.c: Likewise. * dirmngr/dns-stuff.c: Likewise. * dirmngr/http.c: Likewise. * dirmngr/ks-engine-hkp.c: Likewise. * dirmngr/ks-engine-ldap.c: Likewise. * dirmngr/ldap-wrapper.c: Likewise. * dirmngr/ldap.c: Likewise. * dirmngr/misc.c: Likewise. * dirmngr/ocsp.c: Likewise. * dirmngr/validate.c: Likewise. * g10/encrypt.c: Likewise. * g10/getkey.c: Likewise. * g10/gpg.c: Likewise. * g10/gpgv.c: Likewise. * g10/import.c: Likewise. * g10/keydb.c: Likewise. * g10/keydb.h: Likewise. * g10/keygen.c: Likewise. * g10/keyid.c: Likewise. * g10/keylist.c: Likewise. * g10/keyring.c: Likewise. * g10/mainproc.c: Likewise. * g10/misc.c: Likewise. * g10/options.h: Likewise. * g10/packet.h: Likewise. * g10/parse-packet.c: Likewise. * g10/pkclist.c: Likewise. * g10/pkglue.c: Likewise. * g10/plaintext.c: Likewise. * g10/server.c: Likewise. * g10/sig-check.c: Likewise. * g10/sqlite.c: Likewise. * g10/tdbio.c: Likewise. * g10/test-stubs.c: Likewise. * g10/tofu.c: Likewise. * g10/trust.c: Likewise. * g10/trustdb.c: Likewise. * g13/create.c: Likewise. * g13/mountinfo.c: Likewise. * kbx/keybox-blob.c: Likewise. * kbx/keybox-file.c: Likewise. * kbx/keybox-init.c: Likewise. * kbx/keybox-search-desc.h: Likewise. * kbx/keybox-search.c: Likewise. * kbx/keybox-update.c: Likewise. * scd/apdu.c: Likewise. * scd/app-openpgp.c: Likewise. * scd/app-p15.c: Likewise. * scd/app.c: Likewise. * scd/ccid-driver.c: Likewise. * scd/command.c: Likewise. * scd/iso7816.c: Likewise. * sm/base64.c: Likewise. * sm/call-agent.c: Likewise. * sm/call-dirmngr.c: Likewise. * sm/certchain.c: Likewise. * sm/gpgsm.c: Likewise. * sm/import.c: Likewise. * sm/keydb.c: Likewise. * sm/minip12.c: Likewise. * sm/qualified.c: Likewise. * sm/server.c: Likewise. * tools/gpg-check-pattern.c: Likewise. * tools/gpgconf-comp.c: Likewise. * tools/gpgkey2ssh.c: Likewise. * tools/gpgparsemail.c: Likewise. * tools/gpgtar.c: Likewise. * tools/rfc822parse.c: Likewise. * tools/symcryptrun.c: Likewise. Signed-off-by: Justus Winter <[email protected]>
* dirmngr: Do not block during ADNS calls.Werner Koch2015-11-121-8/+35
| | | | | | | | | | | * dirmngr/dns-stuff.c: Include npth.h (my_unprotect, my_protect): New wrapper. (resolve_name_adns): Put unprotect/protect around adns calls. (get_dns_cert): Ditto. (getsrv): Ditto. (get_dns_cname): Ditto. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: New option --nameserver.Werner Koch2015-11-121-2/+27
| | | | | | | | | | | | * 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-7/+46
| | | | | | | | | | | | | | | | | | * 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: Improve detection of ADNS.Werner Koch2015-11-091-0/+5
| | | | | | * configure.ac (HAVE_ADNS_FREE): New ac_define. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Minor cleanup of the SRV RR code.Werner Koch2015-10-281-3/+11
| | | | | | | * dirmngr/dns-stuff.c: Include unistd.h. (getsrv): Run srand only once. * dirmngr/t-dns-stuff.c (main): Allow passing another name for --srv and change output format.
* dirmngr: Add a getaddrinfo wrapper backend using ADNS.Werner Koch2015-10-281-51/+143
| | | | | | | | | * dirmngr/dns-stuff.c: Replace all use of default_errsource. (my_adns_init): Move to top. (resolve_name_adns): New. (resolve_dns_name) [USE_ADNS]: Divert to new func. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Support Tor hidden services.Werner Koch2015-10-261-0/+14
| | | | | | | | | | | | | | * 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,w32: Remove gethostbyname hack and make it build again.Werner Koch2015-10-261-1/+8
| | | | | | | | | * dirmngr/http.c (connect_server) [W32]: Remove gethostbyname hack; we require getaddrinfo anyway. * dirmngr/dns-stuff.c (AI_ADDRCONFIG): Add replacement if not defined. (map_eai_to_gpg_error) [W32]: Take care of unsupported codes. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Add workaround for broken getaddrinfo.Werner Koch2015-10-251-1/+132
| | | | | | | | | | | | | | | | | | * 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: Better handle systems without IPv6 or IPv4.Werner Koch2015-10-251-1/+2
| | | | * dirmngr/dns-stuff.c (resolve_name_standard): Use AI_ADDRCONFIG.
* dirmngr: Implement a getnameinfo wrapper.Werner Koch2015-10-251-15/+169
| | | | | | | | | | | | | | | | | | | * 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: Implement Tor mode for SRV RRs.Werner Koch2015-10-221-14/+32
| | | | | | | | | | | * dirmngr/dns-stuff.c (get_dns_cert): Factor adns init out to... (my_adns_init): new. (getsrv)[USE_ADNS]: Use my_adns_init. (getsrv)[!USE_ADNS]: Return an error if Tor mode is active. * dirmngr/t-dns-stuff.c: Add option --use-tor. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Do not use MAXDNAME.Werner Koch2015-10-221-2/+2
| | | | | | | | | | | | | | | | | | | * 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-3/+253
| | | | | | | | | | | | * 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: Check that getaddrinfo is available.Werner Koch2015-10-211-0/+4
| | | | | | | | | | | | | | | | * 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 <[email protected]>
* Change capitalization of TOR to Tor.Werner Koch2015-10-211-1/+1
| | | | --
* dirmngr: Implement a getaddrinfo wrapper.Werner Koch2015-10-211-11/+146
| | | | | | | | | | | | | | | | | | | * 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/+451
* 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]>