Commit graph

40 commits

Author SHA1 Message Date
Lennart Poettering 088c136384 resolve-tool: provide resolvconf(8) compatibility
This turns resolve-tool into a multi-call binary. When invoked as
"resolvconf" it provides minimal compatibility with the resolvconf(8)
tool of various distributions (and FreeBSD as it appears).

This new interface understands to varying degrees features of the two
major implementations of resolvconf(8): Debian's original one and
"openresolv". Specifically:

Fully supported:

        -a -d (supported by all implementations)
        -f    (introduced by openresolv)

Somewhat supported:

        -x    (introduced by openresolv, mapped to a '~.' domain entry)

Unsupported and ignored:

        -m -p (introduced by openresolv, not really necessary for us)

Unsupported and resulting in failure:
        -u    (supported by all other implementations)
        -I -i -l -R -r -v -V
              (all introduced by openresolv)
        --enable-updates --disable-updates --updates-are-enabled
              (specific to Debian's implementation)

Of course, resolvconf(8) is a tool with multiple backends, in our
implementation systemd-resolved is the only backend.

Fixes: #7202
2018-03-02 15:48:46 +01:00
Lennart Poettering 650f401123
Merge pull request #8336 from poettering/coccinelle-reallocarray
reallocarray() coccinellization
2018-03-02 15:40:52 +01:00
Lennart Poettering 9f0454a833 resolve-tool: propagate sensible errors from due to dns_name_is_valid() check failures 2018-03-02 12:43:12 +01:00
Lennart Poettering 27d8af3e39 resolve-tool: trivial coding style improvements 2018-03-02 12:43:12 +01:00
Lennart Poettering 3209c8e650 resolve-tool: use reallocarray() where appropriate 2018-03-02 12:39:07 +01:00
ott 4cbfd62b46 resolve: Adjust and unify D-Bus call timeout (#7847)
DNS queries have a timeout of DNS_TRANSACTION_ATTEMPTS_MAX *
DNS_TIMEOUT_MAX_USEC = 120 s. Calls to the ResolveHostname method of
the org.freedesktop.resolve1.Manager interface have various call
timeouts that are smaller than 120 s. So it seems correct to adjust
the call timeout to the maximum query timeout and to unify the call
timeout among all callers.

A timeout of 120 s might seem large, in particular since BIND does seem
to have a query timeout of 10 s. However, it seems match the timeout
value of 120 s of Unbound. Moreover, the query and timeout handling of
resolve have problems and might be improved in the future, so this
change is at best an interim solution.
2018-01-23 09:53:31 +09:00
Lennart Poettering 14965b94f2
resolve: extend systemd-resolve so that it can push per-interface DNS configuration into systemd-resolved (#7576)
This is useful to debug things, but also to hook up external post-up
scripts with resolved.

Eventually this code might be useful to implement a
resolvconf(8)-compatible interface for compatibility purposes. Since the
semantics don't map entirely cleanly as first step we add a native
interface for pushing DNS configuration into resolved, that exposes the
correct semantics, before adding any compatibility interface.

See: #7202
2017-12-14 20:13:14 +01:00
Carsten Strotmann f75707dbcb Fixed Type nmnds-ipv4 -> nmdns-ipv4 (#7435) 2017-11-23 13:12:00 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Lennart Poettering d55b0463b2 resolved: add support for explicitly forgetting everything we learnt about DNS server feature levels
This adds "systemd-resolve --reset-server-features" for explicitly
forgetting what we learnt. This might be useful for debugging
purposes, and to force systemd-resolved to restart its learning logic
for all DNS servers.
2017-10-05 16:56:50 +02:00
Lennart Poettering 5102765695 resolved: rework how we handle truncation in the stub resolver
When we a reply message gets longer than the client supports we need to
truncate the response and set the TC bit, and we already do that.
However, we are not supposed to send incomplete RRs in that case, but
instead truncate right at a record boundary. Do that.

This fixes the "Message parser reports malformed message packet."
warning the venerable "host" tool outputs when a very large response is
requested.

See: #6520
2017-10-05 12:22:43 +02:00
Yu Watanabe 44ccb3d723 resolve: add missing space in output message (#5574) 2017-03-12 20:12:03 -04:00
Lennart Poettering 74a3ed7408 resolved: extend various timeouts
Let's increase a number of timeouts as they apparently are too short for
some real-world lookups.

See:

https://github.com/systemd/systemd/issues/4003#issuecomment-279842616

In particular we change the following timeouts:

1) The first UDP retry we increase 500ms → 750ms. This is a good idea,
   since some servers need relatively long responses for trivial lookups,
   and giving up our first attempt also has the effect of trying a
   different server for the next attempt which has the side effect that
   we'll run two down-grade iterations in parallel, on both servers.
   Hence, let's give servers a bit more time in the first iteration.

2) Permit 24 retries instead of just 16 per transactions. If we end up
   downgrading all the way down to UDP for a lookup we already need 5
   iterations for that. If we want permit a couple of lost packages for
   each (let's say 4), then we already need 20 iterations.

3) Increase the overall query timeout on the service side to 60s (from
   45s), simply because very long and slow DNSSEC + CNAME chains (such as
   us.ynuf.alipay.com) hit this boundary too easily. The client side
   timeout for the bus method call is increased to 90s, in order to have
   room for the dbus reply to go through
2017-02-17 10:25:16 +01:00
Zbigniew Jędrzejewski-Szmek 01c901e257 Merge pull request #4832 from rojkov/mdns 2017-02-12 15:38:51 -05:00
Lennart Poettering f9e0eefc7c tree-wide: make bus_map_all_properties return a proper sd_bus_error
And then show it, to make things a bit friendlier to the user if we fail
acquiring some props.

In fact, this fixes a number of actual bugs, where we used an error
structure for output that we actually never got an error in.
2017-02-09 16:13:07 +01:00
Dmitry Rozhkov 062aabb924 resolve: Add support for mDNS to systemd-resolve utility
Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2017-01-19 11:51:21 +02:00
Susant Sahani 10452f7c93 core: introduce parse_ip_port (#4825)
1. Listed in TODO.
2. Tree wide replace safe_atou16 with parse_ip_port incase
   it's used for ports.
2016-12-06 12:21:45 +01:00
Thomas H. P. Andersen f68c9dd5c6 resolve: remove unsed counter (#4349)
It was introduced but never used in 45ec7efb.
2016-10-11 13:51:03 -04:00
Stefan Schweter a60f4d0b44 systemd-resolve: use sha256 for local-part of openpgp key (#4193) 2016-10-08 13:59:34 +02:00
Zbigniew Jędrzejewski-Szmek 90b4a64d77 nspawn,resolve: short --help output to fit within 80 columns
make dist-check-help FTW!
2016-08-04 09:03:42 -04:00
Zbigniew Jędrzejewski-Szmek 96ace31dcd systemd-resolve: remove spurious newline with no global settings 2016-07-17 19:58:02 -04:00
Zbigniew Jędrzejewski-Szmek 7b7c1aacf6 systemd-resolve: use plural "DNS Servers"
Usually multiple DNS servers are configured, and it looks strange to have
singular in the heading.
2016-07-17 19:58:02 -04:00
Lennart Poettering be371fe039 resolve: add "systemd-resolve --status" command
The new command shows the per-link and global DNS configuration currently in
effect. This is useful to quickly see the DNS settings resolved acquired from
networkd and that was pushed into it via the bus APIs.
2016-06-21 13:20:47 +02:00
Lennart Poettering 145fab1eae resolve: port resolve tool to in_addr_ifindex_{from_string_auto|to_string}()
We can reuse some code here, so let's do it.
2016-06-14 23:27:30 +02:00
Lennart Poettering ba35662fbd resolved: also add a way to flush all caches via the bus
And expose it in "resolve-tool --flush-caches".
2016-06-10 23:26:53 +02:00
Lennart Poettering 3c6f7c3402 util-lib: make localed's nonempty() generic, rename it to empty_to_null() and make use of it everywhere 2016-05-30 17:59:43 +02:00
Zbigniew Jędrzejewski-Szmek b68f10bf1f build-sys: fix build with libgrcypt disabled
- Move gcrypt.h include inside grcrypt-util.h.
- Allow gcrypt-util.[ch] to be compiled even without gcrypt.
This allows the logic in files using gcrypt to be simplified.

- Fix compilation of systemd-resolve without gcrypt.
systemd-resolved already supported that.

Fixes #2711.
2016-03-27 21:51:44 -04:00
Alexander Kuleshov 5883ff6017 tree-wide: use SET_FLAG() macro to make code more clear 2016-03-05 18:26:01 +06:00
Zbigniew Jędrzejewski-Szmek 82d1d24093 systemd-resolve: easy querying of TLSA records
$ systemd-resolve --tlsa fedoraproject.org
_443._tcp.fedoraproject.org IN TLSA 0 0 1 GUAL5bejH7czkXcAeJ0vCiRxwMnVBsDlBMBsFtfLF8A=
        -- Cert. usage: CA constraint
        -- Selector: Full Certificate
        -- Matching type: SHA-256

$ systemd-resolve --tlsa=tcp fedoraproject.org:443
_443._tcp.fedoraproject.org IN TLSA 0 0 1 GUAL5bejH7czkXcAeJ0vCiRxwMnVBsDlBMBsFtfLF8A=
        ...

$ systemd-resolve --tlsa=udp fedoraproject.org
_443._udp.fedoraproject.org: resolve call failed: '_443._udp.fedoraproject.org' not found

v2:
- use uint16_t
- refuse port 0
2016-02-18 11:41:40 -05:00
Zbigniew Jędrzejewski-Szmek dab48ea63a systemd-resolve: allow whole packets to be dumped in binary form 2016-02-16 19:55:50 -05:00
Zbigniew Jędrzejewski-Szmek 2e74028a5c systemd-resolve: allow keys to be dumped in binary form
$ systemd-resolve --raw --openpgp zbyszek@fedoraproject.org | pgpdump /dev/stdin
2016-02-16 19:24:07 -05:00
Zbigniew Jędrzejewski-Szmek 1ace2438c6 systemd-resolve: reword --help output
The output didn't specify if the default for --cname/--search/--legend and
other options was yes or no. Change the description to be explicit about that.

Also make the --help output and man page closer.
2016-02-16 19:10:25 -05:00
Lennart Poettering 41815a4aa6 resolve: print a noisy warning if we show crypto keys that could not be authenticated
Doing DNS retrieval on non-authenticated crypt keys is useless, hence warn
loudly about it.
2016-02-16 15:30:03 +01:00
Lennart Poettering 91ba5ac7d0 Merge pull request #2589 from keszybz/resolve-tool-2
Better support of OPENPGPKEY, CAA, TLSA packets and tests
2016-02-13 11:15:41 +01:00
Zbigniew Jędrzejewski-Szmek 4ac2ca1bdb systemd-resolve: allow easy querying of openpgp keys
$ systemd-resolve --openpgp zbyszek@fedoraproject.org
d08ee310438ca124a6149ea5cc21b6313b390dce485576eff96f8722._openpgpkey.fedoraproject.org. IN OPENPGPKEY
        mQINBFBHPMsBEACeInGYJCb+7TurKfb6wGyTottCDtiSJB310i37/6ZYoeIay/5soJjlM
        yfMFQ9T2XNT/0LM6gTa0MpC1st9LnzYTMsT6tzRly1D1UbVI6xw0g0vE5y2Cjk3xUwAyn
        ...
2016-02-11 13:12:41 -05:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Zbigniew Jędrzejewski-Szmek ba82da3bb5 resolve-host: add option to list protocols 2016-01-29 12:13:08 -05:00
Lennart Poettering 7405bb3ec0 resolve: fix wording in resolver statistics output
Now that we count both negative and positive validation results, we shouldn't claim we just counted RRsets.
2016-01-25 17:19:19 +01:00
Lennart Poettering 300a716dc4 resolve: minor strings improvements 2016-01-25 17:19:18 +01:00
Lennart Poettering b5eb973b39 resolve: rename "systemd-resolve-host" tool to simply "systemd-resolve"
The tool resolves way more than just hosts, hence give it a more generic name. This should be safe, as the tool is
currently undocumented. Before we add documentation for it, let's get the name right.

This also moves the C source into src/resolve/ (from src/resolve-host/), since the old name is a misnomer now. Also,
since it links directly to many of the C files of resolved it really belongs into resolved's directory anyway.
2016-01-25 16:00:28 +01:00
Renamed from src/resolve-host/resolve-host.c (Browse further)