aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dns.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2019-03-25libdns: Don't use _[A-Z] which are reserved names.NIIBE Yutaka1-40/+40
* dirmngr/dns.c: Use the identifiers of "*_instance" instead of reserved "_[A-Z]". -- GnuPG-bug-id: 4420 Signed-off-by: NIIBE Yutaka <[email protected]>
2019-03-07libdns: Avoid using compound literals (7).NIIBE Yutaka1-5/+10
* dirmngr/dns.h (DNS_OPTS_INIT, dns_opts): Remove. * dirmngr/dns-stuff.c (libdns_res_open): Use zero-ed, and initialized automatic variable for opts. * dirmngr/dns.c (send_query, resolve_query, resolve_addrinfo): Likewise. -- In fact, DNS_OPTS_INIT was only needed when args are none. With partially specified initialization, C99 guarantees zero-ed other members just like static object. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit d661acd483236d34720a4959fc816d05f89c2cb7)
2019-03-07libdns: Avoid using compound literals (6).NIIBE Yutaka1-26/+47
* dirmngr/dns.h (dns_rr_i_new): Remove. (dns_rr_i_init): Remove unused second argument. * dirmngr/dns.c (dns_p_dump, dns_hints_query, print_packet) (parse_packet): Use automatic variable for struct dns_rr_i. (dns_d_cname): No need to call dns_rr_i_init after memset 0. (dns_rr_i_init): Remove unused second argument. Return nothing. * dirmngr/dns-stuff.c (resolve_addr_libdns, get_dns_cert_libdns) (getsrv_libdns): Follow the change of dns_rr_i_init. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 6501e59d3685bb58753c9caea729a4b0eca3942a)
2019-03-07libdns: Avoid using compound literals (5).NIIBE Yutaka1-1/+2
* dirmngr/dns.h (dns_rr_foreach): Don't use dns_rr_i_new. Call dns_rr_grep with NULL. * dirmngr/dns.c (dns_rr_grep): Support NULL for error_. -- Here we still use C99 feature of struct member initialization in dns_rr_foreach, for struct dns_rr_i. Note that in C99, it guarantees non-specified member fields are initialized by zero. So, there's no need to use dns_rr_i_new at all. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit a1ccfe2b37847cce0db2fb94a7365c9fa501eda4)
2019-03-07libdns: Avoid using compound literals (4).NIIBE Yutaka1-2/+6
* dirmngr/dns.h (dns_d_new*): Remove. * dirmngr/dns.c (parse_packet): Use dns_d_init with automatic variable. (parse_domain): Likewise. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 7313a112f9c7ada61d24285313d2e2d069a672e8)
2019-03-07libdns: Avoid using compound literals (3).NIIBE Yutaka1-9/+18
* dirmngr/dns.h (dns_p_new): Remove. * dirmngr/dns.c (dns_hosts_query): Use dns_p_init with automatic variable. (dns_hints_query, dns_res_glue, parse_packet, query_hosts) (send_query, show_hints, echo_port): Likewise. -- Implicit automatic allocation by compound literals is confusing for C90 code. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 72efb7840258808cd892b90d871ea1cc1c31d7f5)
2019-03-07libdns: Avoid using compound literals (2).NIIBE Yutaka1-6/+9
* dirmngr/dns.h (dns_strsection1, dns_strsection3): Remove. (dns_strclass1, dns_strclass3): Remove. (dns_strtype1, dns_strtype3): Remove. (dns_strsection, dns_strclass, dns_strtype): Directly use the function. * dirmngr/dns.c (dns_strsection): Use automatic variable. (dns_strclass, dns_strtype): Likewise. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 455ef62d29a112de05897139716265d07e4c6ae3)
2019-03-07libdns: Avoid using compound literals.NIIBE Yutaka1-5/+10
* dirmngr/dns.c (dns_inet_pton, dns_so_tcp_keep): Use automatic variables. (dns_poll, dns_send_nopipe): Likewise, adding const qualifier. -- Compound literals is a feature of C99. Because we only use C90 plus some limited features, in the project, it's better to avoid it. Besides, we make sure when it's read-only. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 1c405499388fd5bed0968ab5c6c5d1b3373537b9)
2018-12-18Silence compiler warnings new with gcc 8.Werner Koch1-5/+12
* dirmngr/dns.c: Include gpgrt.h. Silence -Warray-bounds also gcc. * tests/gpgscm/scheme.c: Include gpgrt.h. (Eval_Cycle): Ignore -Wimplicit-fallthrough. -- The funny use of case and labels in the CASE macro seems confuse the fallthrough detection. Signed-off-by: Werner Koch <[email protected]>
2018-07-02libdns: For SOCKS connection, just fails.NIIBE Yutaka1-1/+1
* dirmngr/dns.c (dns_res_exec): If it's DNS_SO_SOCKS_CONN, don't iterate to other server, but return the error immediately. -- Cherry picked from master commit: 1aacd12471935a354cfd85ee1805edc7eb16e6c5 In the function libdns_switch_port_p in dns-stuff.c, this patch allows to fallback using TOR_PORT2 correctly. Fixes-commit: bcdbf8b8ebe9d61160e0b007dabe1b6462ffbc93 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-06-20libdns: Let kernel to decide the local port.NIIBE Yutaka1-0/+3
* dirmngr/dns.c (LEAVE_SELECTION_OF_PORT_TO_KERNEL): New. (dns_socket): Don't select ephemeral port in user space. -- Cherry picked from master commit: 861f1da0731bf29dcb9221c4f22c76b40ec15a78 There is no good reason to bind local port aggressively. It might be some reason to do so, then, a user can specify it in /etc/resolv.conf by the second argument of "interface" directive. At least, it causes a problem on Windows. Binding a specified port in user space can trigger the Firewall dialog on Windows. Since it can be considered valid question, it is better not to bind with an ephemeral port which is selected in user space, by default. GnuPG-bug-id: 3610 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-06-18libdns: Fix for non-FQDN hostname.NIIBE Yutaka1-5/+8
* dirmngr/dns.c (dns_resconf_open): Clear search[0] for non-FQDN hostname. -- Cherry pick from master commit: a4a054bf14fa855715faee01a152755c4e2a74f7 GnuPG-bug-id: T3803 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-06-18libdns: Fix connect and try next nameserver when ECONNREFUSED.NIIBE Yutaka1-2/+23
* dirmngr/dns.c (dns_so_check): When EINVAL, release the association by connect with AF_UNSPEC and try again. Also try again for ECONNREFUSED. (dns_res_exec): Try next nameserver when ECONNREFUSED. -- Cherry pick from master commit: bcdbf8b8ebe9d61160e0b007dabe1b6462ffbc93 GnuPG-bug-id: T3374 Signed-off-by: NIIBE Yutaka <[email protected]>
2018-06-18libdns: Clear struct sockaddr_storage by zero.NIIBE Yutaka1-0/+4
* dirmngr/dns.c (dns_resconf_pton): Clear SS. (dns_resconf_setiface): Clear ->IFACE. (dns_hints_root, send_query): Clear SS. -- Cherry pick from master commit: 1c0b6681e4f322b88ac35d1f21c03d3cfc35fc23 POSIX requires clear the structure of struct sockaddr_in6. On macOS, in some case like bind, it is better to clear even for struct sockaddr_in. Signed-off-by: NIIBE Yutaka <[email protected]>
2018-06-18libdns: Sync to upstream.NIIBE Yutaka1-10/+2
* dirmngr/dns.c (dns_nssconf_loadfile): Handle exclamation mark. -- Cherry pick from master commit: 3e6ad302eaf3a4a9f3e60379133b3dfdbe0e1b2d Reverting local change, merge upstream's debug-tracing branch. (commit 21281fc1b63bb74d51762b8e363c49b1a258783d) Fixes-commit: d4c0187dd93163f12e9f953366adef81ecf526a6 Signed-off-by: NIIBE Yutaka <[email protected]>
2017-07-25dirmngr: Add annotation for fallthrough.NIIBE Yutaka1-41/+41
* dirmngr/dns.c: Add /* FALL THROUGH */ to clarify. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-07-20dnsmngr: Fix use of CPP.NIIBE Yutaka1-5/+23
* dirmngr/dns.c (HAVE_STATIC_ASSERT, HAVE___ATOMIC_FETCH_ADD) (DNS_HAVE_SOCKADDR_UN, HAVE_SOCK_NONBLOCK): Don't use defined to be expanded for expression evaluation. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-06-13dirmngr: Implement querying nameservers over IPv6.Justus Winter1-1/+179
* dirmngr/dns.c (dns_so_check): Reinitialize sockets on address family mismatch. (enum dns_res_state): New states for querying over IPv6. (dns_res_exec): Implement the new states by copying and modifying the IPv4 variants. Branch to their respective counterparts if the current list of resolvers using the current address family is exhausted. -- This allows dirmngr to resolve names on systems where the nameservers are only reachable via IPv6. GnuPG-bug-id: 2990 Signed-off-by: Justus Winter <[email protected]>
2017-04-28Spelling fixes in docs and comments.NIIBE Yutaka1-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]>
2017-04-25dirmngr: Fix aliasing problem in dns.c.NIIBE Yutaka1-16/+18
* dirmngr/dns.c (dns_ai_setent): Care about aliasing. -- Co-authored-by: Tomas Mraz GnuPG-bug-id: 3105 Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-13dirmngr: More fix for Windows.NIIBE Yutaka1-1/+5
* dirmngr/dns.c (socket_fd_t, STDCALL): New. (dns_te_initname): Use. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-12dirmngr: Fix possible null reference.NIIBE Yutaka1-2/+3
* dirmngr/dns.c (dns_error_t dns_trace_fput): Check NULL. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-12dirmngr: Fix plus1_ns.NIIBE Yutaka1-1/+4
* dirmngr/dns.c (plus1_ns): Fix the initial implementation. -- Fixes-commit: 64904ce627b6b0661acf15b5b70103c4842bb0f3 Signed-off-by: NIIBE Yutaka <[email protected]>
2017-04-12dirmngr: Use a function to increment network short.NIIBE Yutaka1-4/+13
* dirmngr/dns.c (plus1_ns): New. (dns_p_push): Use it. -- On OpenBSD, htons and ntohs are expanded to GCC's statement expressions where local variable is allowed. Consecutive use of htons and ntohs causes problem of variable name. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-01-23libdns: Hack to skip negation term.Gaetan Bisson1-1/+9
* dirmngr/dns.c (dns_nssconf_loadfile): Skip negation terms in nsswitch.conf parser. -- This small patch was submitted along with this comment: We've been having issues over at Arch Linux with the new libdns code. Our /etc/nsswitch.conf contains the following line: hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname And it turns out dirmngr fails to parse the negation statement (the bang in !UNAVAIL). This results in gnupg not being able to resolve any name. Looking at dirmngr/dns.c it was unclear to me how to properly handle such negations. The dns_anyconf_scan calls used in dns_nssconf_loadfile do not allow to store a negation bit easily... In the meantime, I wrote the attached patch which ignores those statements altogether. It makes libdns work as expected for us. Commit log written by wk
2017-01-12libdns: Silence -Wstrict-prototypes on some function ptrs.Werner Koch1-0/+13
* dirmngr/dns.c (dns_rrtype): Ignore -Wstrict-prototypes warning. Signed-off-by: Werner Koch <[email protected]>
2017-01-12libdns: Provide replacement for EPROTO.Werner Koch1-0/+4
* dirmngr/dns.c (EPROTO) ![EPROTO]: Define to EPROTONOSUPPORT. -- This is the same replacement we use in Libassuan (commit 8ab3b9273524bd344bdb90dd5d3bc8e5f53ead6e) to make it work on OpenBSD and may other BSD based OSes. Signed-off-by: Werner Koch <[email protected]>
2016-12-19dirmngr,w32: Hack around a select problem.Werner Koch1-2/+3
* dirmngr/dns.c (FD_SETSIZE): Bump up to 1024. (dns_poll): Return an error instead of hitting an assertion failure. -- For unknown reasons socket() return fd with values 244, 252, 268. The latter is above the FD_SETSIZE of 256. It seems that select has been build with a highler FD_SETSIZE limit. Bump up to a reasonable large value. A better solution would be to grab some code from npth_eselect to replace select. We could also use npth_eselect direclty in dns-stuff.c instead of using dns_res_poll. Signed-off-by: Werner Koch <[email protected]>
2016-12-14dirmngr: New libdns snapshotJustus Winter1-61/+154
2016-12-14dirmngr: Add basic libdns supportJustus Winter1-0/+11152
* 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]>