aboutsummaryrefslogtreecommitdiffstats
path: root/dirmngr/dns.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* dirmngr: Fix libdns with 127.0.0.1.NIIBE Yutaka2025-04-071-6/+6
| | | | | | | | | | | * dirmngr/dns.c (dns_so_check): Ifdef-out Linux specific code. Remove retrying udp_connect_retry when ECONNREFUSED. -- Fixes-commit: bcdbf8b8ebe9d61160e0b007dabe1b6462ffbc93 GnuPG-bug-id: 4021 Signed-off-by: NIIBE Yutaka <[email protected]>
* indent: Fix spellingDaniel Kahn Gillmor2024-05-311-1/+1
| | | | | | | | | | | | | -- These are non-substantive corrections for minor spelling mistakes within the GnuPG codebase. With something like this applied to the codebase, and a judiciously tuned spellchecker integrated as part of a standard test suite, it should be possible to keep a uniform orthography within the project. GnuPG-bug-id: 7116
* dirmngr:dns,doc,gpg: Fix for noreturn for C11.NIIBE Yutaka2022-09-161-1/+1
| | | | | | | | | | | * dirmngr/dns.c: Use __noreturn__. * doc/yat2m.c: Likewise. * g10/main.h: Likewise. -- GnuPG-bug-id: 4002 Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr:dns: Fixes for function prototypes.NIIBE Yutaka2022-09-141-59/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | * dirmngr/dns.c (dns_a_parse0, dns_a_push0, dns_a_cmp0): New. (dns_a_print0, dns_aaaa_parse0, dns_aaaa_cmp0): New. (dns_aaaa_print0, dns_mx_parse0, dns_mx_push0, dns_mx_cmp0): New. (dns_mx_print0, dns_mx_cname0, dns_ns_parse0, dns_ns_push0): New. (dns_ns_cmp0, dns_ns_print0, dns_ns_cname0, dns_cname_parse0): New. (dns_cname_push0, dns_cname_cmp0, dns_cname_print0): New. (dns_cname_cname0, dns_soa_parse0, dns_soa_push0): New. (dns_soa_cmp0, dns_soa_print0, dns_srv_parse0, dns_srv_push0): New. (dns_srv_cmp0, dns_srv_print0, dns_srv_cname0, dns_opt_parse0): New. (dns_opt_push0, dns_opt_cmp0, dns_opt_print0, dns_ptr_parse0): New. (dns_ptr_push0, dns_ptr_cmp0, dns_ptr_print0, dns_ptr_cname0): New. (dns_sshfp_parse0, dns_sshfp_push0, dns_sshfp_cmp0): New. (dns_sshfp_print0, dns_txt_parse0, dns_txt_push0, dns_txt_cmp0): New. (struct dns_rrtype): Add function prototypes. (dns_rrtypes): Use "0" variant of functions. (DNS_PRAGMA_PUSH, DNS_PRAGMA_POP): Remove. -- Original code was pretty badly written ignoring the type system of C, but modern compiler encourages use of the type system. No architectural changes, but only things mechanically possible. Signed-off-by: NIIBE Yutaka <[email protected]>
* build: Update for newer autoconf.NIIBE Yutaka2021-12-221-1/+1
| | | | | | | | | | | | | | | * configure.ac (AC_PREREQ): Use >= 2.69. (AC_CONFIG_HEADERS): Use it, instead of AC_CONFIG_HEADER. (AC_HEADER_STDC, AC_HEADER_TIME): Remove obsolete macros. (sys/time.h): Add the check of the header. (time_t): Don't use TIME_WITH_SYS_TIME. * acinclude.m4 (AC_HEADER_TIME): Don't require. Don't use TIME_WITH_SYS_TIME. * dirmngr/dns.c: Don't use TIME_WITH_SYS_TIME. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* dns: Make reading resolv.conf more robust.NIIBE Yutaka2021-10-151-1/+6
| | | | | | | | | | * dirmngr/dns.c (dns_resconf_loadfile): Skip "search" which begins with '.'. -- GnuPG-bug-id: 5657 Signed-off-by: NIIBE Yutaka <[email protected]>
* dns: Fix memory use-after-free.NIIBE Yutaka2020-08-191-0/+6
| | | | | | | | | | * dirmngr/dns.c (dns_res_stub): Fix RESCONF usage. -- Note that this is dead code. It is for making a static analyzer happy. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: dns: Fix allocation of string buffer in stack.NIIBE Yutaka2020-05-201-23/+29
| | | | | | | | | | | | | | | | | | | | | * dirmngr/dns.h (dns_strsection, dns_strclass) (dns_strtype): Change APIs. * dirmngr/dns.c (dns_p_lines): Use __dst for dns_strsection. (dns_rr_print): Use __dst for dns_strclass and dns_strtype. (dns_trace_dump): Likewise. (dns_ai_print): Use __dst for dns_strtype. (dns_strsection): Add an argument __dst for storage. (dns_strclass, dns_strtype): Likewise. (parse_packet): Use __dst for dns_strsection. (send_query): Use __dst for dns_strtype. (isection): Use __dst for dns_strsection. (iclass): Use __dst for dns_strclass. (itype): Use __dst for dns_strtype. GnuPG-bug-id: 4934 Reported-by: Tomas Mraz Fixes-commit: 455ef62d29a112de05897139716265d07e4c6ae3 Signed-off-by: NIIBE Yutaka <[email protected]>
* Spelling cleanup.Daniel Kahn Gillmor2020-02-181-2/+2
| | | | | | | | | | | | | | | | No functional changes, just fixing minor spelling issues. --- Most of these were identified from the command line by running: codespell \ --ignore-words-list fpr,stati,keyserver,keyservers,asign,cas,iff,ifset \ --skip '*.po,ChangeLog*,help.*.txt,*.jpg,*.eps,*.pdf,*.png,*.gpg,*.asc' \ doc g13 g10 kbx agent artwork scd tests tools am common dirmngr sm \ NEWS README README.maint TODO Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* dns: Fix irrelevant use of tmpfile.NIIBE Yutaka2019-08-221-2/+0
| | | | | | | * dirmngr/dns.c (dns_trace_open): Don't use tmpfile. GnuPG-bug-id: 4228 Signed-off-by: NIIBE Yutaka <[email protected]>
* libdns: Don't use _[A-Z] which are reserved names.NIIBE Yutaka2019-03-251-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]>
* libdns: Avoid using compound literals (7).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals (6).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals (5).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals (4).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals (3).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals (2).NIIBE Yutaka2019-02-261-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]>
* libdns: Avoid using compound literals.NIIBE Yutaka2019-02-261-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]>
* Silence a few compiler warnings new with gcc 8.Werner Koch2018-12-171-5/+12
| | | | | | | | * dirmngr/dns.c: Include gpgrt.h. Silence -Warray-bounds also gcc. * tools/gpg-pair-tool.c (command_respond): Init two vars to silence gcc. Signed-off-by: Werner Koch <[email protected]>
* all: fix spelling and typosDaniel Kahn Gillmor2018-10-241-2/+2
| | | | Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* libdns: For SOCKS connection, just fails.NIIBE Yutaka2018-07-021-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. -- 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]>
* libdns: Let kernel to decide the local port.NIIBE Yutaka2018-06-191-0/+3
| | | | | | | | | | | | | | | | | | | * dirmngr/dns.c (LEAVE_SELECTION_OF_PORT_TO_KERNEL): New. (dns_socket): Don't select ephemeral port in user space. -- 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]>
* libdns: Fix for non-FQDN hostname.NIIBE Yutaka2018-06-181-5/+8
| | | | | | | | | | * dirmngr/dns.c (dns_resconf_open): Clear search[0] for non-FQDN hostname. -- GnuPG-bug-id: T3803 Signed-off-by: NIIBE Yutaka <[email protected]>
* libdns: Fix connect and try next nameserver when ECONNREFUSED.NIIBE Yutaka2018-06-151-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. -- GnuPG-bug-id: T3374 Signed-off-by: NIIBE Yutaka <[email protected]>
* libdns: Clear struct sockaddr_storage by zero.NIIBE Yutaka2018-06-151-0/+4
| | | | | | | | | | | | | | * dirmngr/dns.c (dns_resconf_pton): Clear SS. (dns_resconf_setiface): Clear ->IFACE. (dns_hints_root, send_query): Clear SS. -- 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]>
* libdns: Sync to upstream.NIIBE Yutaka2018-06-141-10/+2
| | | | | | | | | | | | * dirmngr/dns.c (dns_nssconf_loadfile): Handle exclamation mark. -- Reverting local change, merge upstream's debug-tracing branch. (commit 21281fc1b63bb74d51762b8e363c49b1a258783d) Fixes-commit: d4c0187dd93163f12e9f953366adef81ecf526a6 Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Add annotation for fallthrough.NIIBE Yutaka2017-07-251-41/+41
| | | | | | * dirmngr/dns.c: Add /* FALL THROUGH */ to clarify. Signed-off-by: NIIBE Yutaka <[email protected]>
* dnsmngr: Fix use of CPP.NIIBE Yutaka2017-07-201-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]>
* dirmngr: Implement querying nameservers over IPv6.Justus Winter2017-06-131-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]>
* 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 aliasing problem in dns.c.NIIBE Yutaka2017-04-251-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]>
* dirmngr: More fix for Windows.NIIBE Yutaka2017-04-131-1/+5
| | | | | | | * dirmngr/dns.c (socket_fd_t, STDCALL): New. (dns_te_initname): Use. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Fix possible null reference.NIIBE Yutaka2017-04-121-2/+3
| | | | | | * dirmngr/dns.c (dns_error_t dns_trace_fput): Check NULL. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Fix plus1_ns.NIIBE Yutaka2017-04-121-1/+4
| | | | | | | | | * dirmngr/dns.c (plus1_ns): Fix the initial implementation. -- Fixes-commit: 64904ce627b6b0661acf15b5b70103c4842bb0f3 Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Use a function to increment network short.NIIBE Yutaka2017-04-121-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]>
* libdns: Hack to skip negation term.Gaetan Bisson2017-01-231-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
* libdns: Silence -Wstrict-prototypes on some function ptrs.Werner Koch2017-01-121-0/+13
| | | | | | * dirmngr/dns.c (dns_rrtype): Ignore -Wstrict-prototypes warning. Signed-off-by: Werner Koch <[email protected]>
* libdns: Provide replacement for EPROTO.Werner Koch2017-01-121-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]>
* dirmngr,w32: Hack around a select problem.Werner Koch2016-12-191-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]>
* dirmngr: New libdns snapshotJustus Winter2016-12-141-61/+154
|
* dirmngr: Add basic libdns supportJustus Winter2016-12-141-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]>