Commit graph

1436 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 3614df0575 meson,resolved: make default LLMNR= and MulticastDNS= values configurable
For https://fedoraproject.org/wiki/Changes/systemd-resolved.
2020-04-15 14:37:21 +02:00
Lennart Poettering 9afe05c149
Merge pull request #14930 from tomhughes/dnssec-canonicalise
Canonicalise names in DNS responses per RFC4034 requirements
2020-04-07 17:07:04 +02:00
Giedrius Statkevičius aa5408e2e8 resolve: reload /etc/hosts on inode change
On certain distributions such as NixOS the mtime of `/etc/hosts` is
locked to a fixed value. In such cases, only checking the last mtime of
`/etc/hosts` is not enough - we also need to check if the st_ino/st_dev
match up. Thus, let's make sure make sure that systemd-resolved also
rereads `/etc/hosts` if the inode or the device containing `/etc/hosts` changes.

Test script:

```bash
hosts="/etc/hosts"
echo "127.0.0.1 testpr" > "hosts_new"
mv "hosts_new" "$hosts"
resolvectl query testpr || exit 1
mtime="$(stat -c %y "$hosts")"
echo "127.0.0.1 newhost" > "hosts_tmp"
touch -d "$mtime" "hosts_tmp"
install -p "hosts_tmp" "$hosts"
sleep 10
resolvectl query newhost || exit 1
rm -f "hosts_tmp"
```

Closes #14456.
2020-04-03 17:34:10 +02:00
Zbigniew Jędrzejewski-Szmek 7b43295346 tests: move unit files to units/ subdirectory
We have a bazillion of those unit files, and keeping them all directly in tests/
has become rather unwieldy.
2020-03-19 16:23:27 +01:00
Jörg Thalheim eec394f10b systemd-resolved: use hostname for certificate validation in DoT
Widely accepted certificates for IP addresses are expensive and only
affordable for larger organizations. Therefore if the user provides
the hostname in the DNS= option, we should use it instead of the IP
address.
2020-03-07 01:37:30 +09:00
Zbigniew Jędrzejewski-Szmek 105a1a36cd tree-wide: fix spelling of lookup and setup verbs
"set up" and "look up" are the verbs, "setup" and "lookup" are the nouns.
2020-03-03 15:02:53 +01:00
Yu Watanabe df70539f9f resolve: error handling improvements 2020-03-01 14:02:23 +01:00
Tom Hughes 4e58741d55 Canonicalise names in DNS responses per RFC4034 requirements
Section 6.2 of RFC4034 requires that "all uppercase US-ASCII letters in
the DNS names contained within the RDATA are replaced by the corresponding
lowercase US-ASCII letters" for a long list of RR types.

Fixes #14891
2020-02-24 10:56:13 +00:00
Tom Hughes 19be3da991 Remove dnssec_canonicalize function which is no longer used 2020-02-24 10:20:12 +00:00
Lennart Poettering 269e4d2d6b shared: split out polkit stuff from bus-util.c → bus-polkit.c
It's enough, complex stuff to warrant its own source file.

No other changes, just splitting out.
2020-01-22 12:34:10 +01:00
Lennart Poettering f1f20764f9 resolved: drop DNSSEC root key that is not valid anymore
I guess we can drop this now, the key is no longer valid until
2019-01-11, hence there's no point in still including it in our trust
anchor.
2020-01-21 15:06:53 +01:00
Yu Watanabe 29e15e98c7 resolvectl: use format-table.[ch] 2020-01-15 11:52:40 +09:00
Zbigniew Jędrzejewski-Szmek 957d9df388 resolvectl: minor optimizations to allocate less 2020-01-12 11:24:35 +01:00
Zbigniew Jędrzejewski-Szmek d308bb99d2 Resolve alternative ifnames wherever we would resolve an interface name
To keep the names manageable, "ifname_or_ifindex" is replaced by "interface".
2020-01-12 11:24:35 +01:00
Zbigniew Jędrzejewski-Szmek 5c3fa98db6 util-lib: move things that parse ifnames to shared/
In subsequent commits, calls to if_nametoindex() will be replaced by a wrapper
that falls back to alternative name resolution over netlink. netlink support
requires libsystemd (for sd-netlink), and we don't want to add any functions
that require netlink in basic/. So stuff that calls if_nametoindex() for user
supplied interface names, and everything that depends on that, needs to be
moved.
2020-01-11 12:07:28 +01:00
Zbigniew Jędrzejewski-Szmek 597da51bae tree-wide: make parse_ifindex simply return the index
We don't need a seperate output parameter that is of type int.  glibc() says
that the type is "unsigned", but the kernel thinks it's "int".  And the
"alternative names" interface also uses ints. So let's standarize on ints,
since it's clearly not realisitic to have interface numbers in the upper half
of unsigned int range.
2020-01-11 12:06:08 +01:00
Topi Miettinen 07317d6e34
resolved, networkd: don't resolve the user if not root
If a daemon is not started as root, most likely it also can't create its
directory and let's not try to resolve the user in that case either.

Create /run/systemd/netif/lldp with tmpfiles.d like other netif directories.

This is also very helpful for preparing a RootImage for the daemons as NSS crud
is not needed.
2019-12-07 18:55:54 +02:00
Guilhem Lettron 2e22a54f4e Implement SNI when using DNS-over-TLS
Some DNS providers need SNI to identify client.

This can be used by adding #name to a DNS.
Example:
[Resolve]
DNS=192.168.1.1#example.com
2019-12-04 23:24:06 +09:00
Zbigniew Jędrzejewski-Szmek 7f95bb22d3 resolve: rename define fixing a typo 2019-11-21 12:45:25 +01:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Yu Watanabe a4dca9836b tree-wide: drop gcrypt.h when gcrypt-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 99e0d09731 tree-wide: drop glob.h when glob-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe f5947a5e92 tree-wide: drop missing.h 2019-10-31 17:57:03 +09:00
Iwan Timmer 7f2f4faced resolved: check for IP in certificate when using DoT with GnuTLS
Validate the IP address in the certificate for DNS-over-TLS in strict mode when GnuTLS is used. As this is not yet the case in contrast to the documentation.
2019-10-29 20:32:18 +01:00
Iwan Timmer 38e053c58f resolved: require at least version 3.6.0 of GnuTLS for DNS-over-TLS
Increase the required version to ensure TLS 1.3 is always supported when using GnuTLS for DNS-over-TLS and allow further changes to use recent API additions.
2019-10-29 20:26:05 +01:00
Zbigniew Jędrzejewski-Szmek 4a6f996c01 resolved: emit change for CurrentDNSServer 2019-10-25 16:41:25 +02:00
Zbigniew Jędrzejewski-Szmek 86c0411ee5 resolved: emit change for LLMNRHostname 2019-10-25 16:41:25 +02:00
Zbigniew Jędrzejewski-Szmek 5f3340ca5b resolved: send out notifications about DNS property
Notifications are only sent for the top object, and not for individual
links. This should be enough for the most obvious cases where somebody
just cares about the effective set of servers.

Fixes #13721.
2019-10-25 16:40:54 +02:00
Zbigniew Jędrzejewski-Szmek 8e97dc676f resolved: make two functions static 2019-10-25 16:37:22 +02:00
Zbigniew Jędrzejewski-Szmek b2c1554625 resolved: one less {} 2019-10-25 16:37:22 +02:00
Zbigniew Jędrzejewski-Szmek 0a6c074568 resolved: avoid allocation
While at it, constify the argument.
2019-10-25 16:37:22 +02:00
Dan Streetman 1c089741d3 resolved: set stream type during DnsStream creation
The DnsStreamType was added to track different types of DNS TCP streams,
instead of refcounting all of them together.  However, the stream type was
not actually set into the stream->type field, so while the reference count
was correctly incremented per-stream-type, the reference count was always
decremented in the cleanup function for stream type 0, leading to
underflow for the type 0 stream (unsigned) refcount, and preventing new
type 0 streams from being created.

Since type 0 is DNS_STREAM_LOOKUP, which is used to communicate with
upstream nameservers, once the refcount underflows the stub resolver
no longer is able to successfully fall back to TCP upstream lookups
for any truncated UDP packets.

This was found because lookups of A records with a large number of
addresses, too much to fit into a single 512 byte DNS UDP reply,
were causing getaddrinfo() to fall back to TCP and trigger this bug,
which then caused the TCP fallback for later large record lookups
to fail with 'connection timed out; no servers could be reached'.

The stream type was introduced in commit:
652ba568c6
2019-10-25 13:36:29 +09:00
Peter Wu 6880558020 resolved: fix connection failures with TLS 1.3 and GnuTLS
Prefer TLS 1.3 before TLS 1.2 for DNS-over-TLS support, otherwise
servers compliant with RFC 8446 might end up agreeing TLS 1.2 plus a
downgrade signal which is not expected by GnuTLS clients. This manifests
in the following error:

    Failed to invoke gnutls_handshake: An illegal parameter has been received.

Fixes: #13528
Fixes: v242-962-g9c0624dcdb ("resolved: support TLS 1.3 when using GnuTLS for DNS-over-TLS")
2019-10-21 20:35:05 +02:00
Zbigniew Jędrzejewski-Szmek ce2529b4a2 Highlight the synopsis and summary in --help
This doesn't cover all the binaries, but I don't know how to script
this, and I run out of steam ;)
2019-10-08 18:21:27 +02:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Lennart Poettering 68c2b5ddb1
Merge pull request #13600 from keszybz/ratelimit
Clean up ratelimit functions and disable /dev/kmsg ratelimit
2019-09-23 12:59:09 +02:00
Zbigniew Jędrzejewski-Szmek 8c227e7f2b Drop RATELIMIT macros
Using plain structure initialization is both shorter _and_ more clearer.
We get type safety for free.
2019-09-20 16:05:53 +02:00
AsciiWolf 984b96aa7a polkit: fix typo 2019-09-20 21:02:47 +09:00
Zbigniew Jędrzejewski-Szmek f731fd5be6 resolved: fix abort when recv() returns 0
https://bugzilla.redhat.com/show_bug.cgi?id=1703598
2019-09-13 13:31:43 +09:00
Zbigniew Jędrzejewski-Szmek ea2552639b polkit: change "revert settings" to "reset settings"
"reset" is more understandable. The verb is "revert", but it might actually be
better to have a description which uses different words instead of duplicating
the name of the command.

379158684a (commitcomment-34992552)
2019-09-12 18:35:49 +02:00
Zbigniew Jędrzejewski-Szmek fd73184f25 resolved: query polkit only after parsing the data
That's what we do everywhere else because it leads to nicer user experience.
2019-08-27 19:49:09 +02:00
Zbigniew Jędrzejewski-Szmek 52aaef0f5d resolved: allow access to Set*Link and Revert methods through polkit
This matches what is done in networkd very closely. In fact even the
policy descriptions are all identical (with s/network/resolve), except
for the last one:
resolved has org.freedesktop.resolve1.revert while
networkd has org.freedesktop.network1.revert-ntp and
org.freedesktop.network1.revert-dns so the description is a bit different.
2019-08-27 19:49:09 +02:00
Zbigniew Jędrzejewski-Szmek ab77c8793b resolved: do not run loop twice
This doesn't matter much, but let's just do the loop once and allocate
the populate the result set on the fly. If we find an error, it'll get
cleaned up automatically.
2019-08-27 19:49:09 +02:00
Lennart Poettering ea582a0f1b
Merge pull request #13047 from niedbalski/fix-5552-pr
resolved: add new option to only cache positive answers
2019-07-17 19:27:16 +02:00
Jorge Niedbalski 37d7a7d984 resolved: switch cache option to a tri-state option (systemd#5552).
Change the resolved.conf Cache option to a tri-state "no, no-negative, yes" values.

If a lookup returns SERVFAIL systemd-resolved will cache the result for 30s (See 201d995),
however, there are several use cases on which this condition is not acceptable (See systemd#5552 comments)
and the only workaround would be to disable cache entirely or flush it , which isn't optimal.

This change adds the 'no-negative' option when set it avoids putting in cache
negative answers but still works the same heuristics for positive answers.

Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
2019-07-17 10:42:53 -04:00
Zbigniew Jędrzejewski-Szmek ab1a1ba5dc Drop trailing slash from assert_cc() definition
We use assert_cc(...); almost everywhere. Let's always require that.

https://github.com/systemd/systemd/issues/12997#issuecomment-510103988
2019-07-17 12:57:20 +02:00
Yu Watanabe 2400ae29a5 resolve: fix memleak 2019-07-17 06:59:12 +09:00
Yu Watanabe 65856bf208 resolvectl: support networkd managed interfaces
Closes #9808.
2019-07-17 06:59:12 +09:00
Yu Watanabe 00d28db322 resolve: expose dns_server_address_valid() 2019-07-17 06:59:12 +09:00
Lennart Poettering b910cc72c0 tree-wide: get rid of strappend()
It's a special case of strjoin(), so no need to keep both. In particular
as typing strjoin() is even shoert than strappend().
2019-07-12 14:31:12 +09:00