1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-31 22:18:03 +02:00
Commit Graph

21 Commits

Author SHA1 Message Date
NIIBE Yutaka
cca92ca534 libdns: For SOCKS connection, just fails.
* 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:
    1aacd12471

In the function libdns_switch_port_p in dns-stuff.c, this patch
allows to fallback using TOR_PORT2 correctly.

Fixes-commit: bcdbf8b8eb
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-07-02 10:47:38 +09:00
NIIBE Yutaka
72a35ffee0 libdns: Let kernel to decide the local port.
* 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:
    861f1da073

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 <gniibe@fsij.org>
2018-06-20 09:14:02 +09:00
NIIBE Yutaka
87d0ecf8a1 libdns: Fix for non-FQDN hostname.
* dirmngr/dns.c (dns_resconf_open): Clear search[0] for non-FQDN
hostname.

--

Cherry pick from master commit:
    a4a054bf14

GnuPG-bug-id: T3803
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-06-18 17:27:07 +09:00
NIIBE Yutaka
699fe4b36f libdns: Fix connect and try next nameserver when ECONNREFUSED.
* 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:
    bcdbf8b8eb

GnuPG-bug-id: T3374
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-06-18 17:26:20 +09:00
NIIBE Yutaka
0c05b08e8b libdns: Clear struct sockaddr_storage by zero.
* 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:
    1c0b6681e4

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 <gniibe@fsij.org>
2018-06-18 17:25:49 +09:00
NIIBE Yutaka
20c289606f libdns: Sync to upstream.
* dirmngr/dns.c (dns_nssconf_loadfile): Handle exclamation mark.

--

Cherry pick from master commit:
    3e6ad302ea

Reverting local change, merge upstream's debug-tracing branch.
(commit 21281fc1b63bb74d51762b8e363c49b1a258783d)

Fixes-commit: d4c0187dd9
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2018-06-18 17:24:57 +09:00
NIIBE Yutaka
d40b4a41a8 dirmngr: Add annotation for fallthrough.
* dirmngr/dns.c: Add /* FALL THROUGH */ to clarify.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-07-25 11:49:23 +09:00
NIIBE Yutaka
cc12cf386b dnsmngr: Fix use of CPP.
* 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 <gniibe@fsij.org>
2017-07-20 13:19:18 +09:00
Justus Winter
15d2a00993
dirmngr: Implement querying nameservers over IPv6.
* 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 <justus@g10code.com>
2017-06-13 11:33:06 +02:00
NIIBE Yutaka
5c8fe54809 Spelling fixes in docs and comments.
--

In addition, fix trailing spaces in tests/inittests.

GnuPG-bug-id: 3121
Reported-by: ka7 (klemens)
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-28 10:06:33 +09:00
NIIBE Yutaka
247932f367 dirmngr: Fix aliasing problem in dns.c.
* dirmngr/dns.c (dns_ai_setent): Care about aliasing.

--

Co-authored-by: Tomas Mraz
GnuPG-bug-id: 3105
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-25 21:00:41 +09:00
NIIBE Yutaka
5af104b541 dirmngr: More fix for Windows.
* dirmngr/dns.c (socket_fd_t, STDCALL): New.
(dns_te_initname): Use.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-13 09:52:19 +09:00
NIIBE Yutaka
7ae1857c90 dirmngr: Fix possible null reference.
* dirmngr/dns.c (dns_error_t dns_trace_fput): Check NULL.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-12 15:58:11 +09:00
NIIBE Yutaka
60d9a9e6b4 dirmngr: Fix plus1_ns.
* dirmngr/dns.c (plus1_ns): Fix the initial implementation.

--

Fixes-commit: 64904ce627
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2017-04-12 11:44:10 +09:00
NIIBE Yutaka
64904ce627 dirmngr: Use a function to increment network short.
* 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 <gniibe@fsij.org>
2017-04-12 09:11:20 +09:00
Gaetan Bisson
d4c0187dd9
libdns: Hack to skip negation term.
* 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-23 12:46:35 +01:00
Werner Koch
97372b39cd
libdns: Silence -Wstrict-prototypes on some function ptrs.
* dirmngr/dns.c (dns_rrtype): Ignore -Wstrict-prototypes warning.

Signed-off-by: Werner Koch <wk@gnupg.org>
2017-01-12 09:22:14 +01:00
Werner Koch
0fadff9cdd
libdns: Provide replacement for EPROTO.
* 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 <wk@gnupg.org>
2017-01-12 09:20:49 +01:00
Werner Koch
d51499fdc5
dirmngr,w32: Hack around a select problem.
* 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 <wk@gnupg.org>
2016-12-19 16:39:17 +01:00
Justus Winter
f8ab2c4c70
dirmngr: New libdns snapshot 2016-12-14 15:56:58 +01:00
Justus Winter
f6acd04264
dirmngr: Add basic libdns support
* 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 <justus@g10code.com>
2016-12-14 15:56:31 +01:00