Commit Graph

1478 Commits

Author SHA1 Message Date
Frantisek Sumsal 15dd451535 tree-wide: codespell fixes
Another batch of codespell fixes as reported by Fossies.org
2020-05-25 10:29:28 +02:00
Zbigniew Jędrzejewski-Szmek b3d15d90c0
Merge pull request #15804 from poettering/hostnamed-instant-part1
four likely safe commits split out of #15624
2020-05-18 15:26:24 +02:00
Benjamin Robin b9c54c4665 tree-wide: Initialize _cleanup_ variables if needed 2020-05-13 22:56:42 +02:00
Lennart Poettering 61c12865f5 resolved: port to stat_inode_unmodified() 2020-05-13 16:57:44 +02:00
Lennart Poettering 9e45fb09bf netlink: port to recvmsg_safe()
This also makes sure the control buffer is properly aligned. This
matters, as otherwise the control buffer might not be aligned and the
cmsg buffer counting might be off. The incorrect alignment is becoming
visible by using recvmsg_safe() as we suddenly notice the MSG_CTRUNC bit
set because of this.

That said, apparently this isn't enough to make this work on all
kernels. Since I couldn't figure this out, we now add 1K to the buffer
to be sure. We do this once already, also for a pktinfo structure
(though an IPv4/IPv6) one. I am puzzled by this, but this shouldn't
matter much. it works locally just fine, except for those ubuntu CI
kernels...

While we are at it, make some other changes too, to simplify and
modernize the function.
2020-05-12 10:47:06 +02:00
Lennart Poettering 2d5996c175
Merge pull request #15460 from elmarco/network-dhcp-resolve1
network: fallback on resolve1 DNS for DHCP
2020-05-11 16:16:06 +02:00
Zbigniew Jędrzejewski-Szmek 8acb7780df
Merge pull request #15623 from poettering/cmsg-cleanup
various CMSG_xyz clean-ups, split out of #15571
2020-05-08 11:05:06 +02:00
Marc-André Lureau 2d95d81f7b shared: move in_addr_ifindex_name_from_string_auto() there 2020-05-07 22:36:52 +02:00
Vito Caputo 5e55340ad4
Merge pull request #15681 from vcaputo/buslocator
*: switch to BusLocator-oriented helpers
2020-05-07 09:46:01 -07:00
Vito Caputo d96f9abc95 resolve: switch to BusLocator-oriented helpers
Mechanical substitution reducing some verbosity
2020-05-07 08:46:44 -07:00
Zbigniew Jędrzejewski-Szmek 5cea17a177
Merge pull request #15635 from keszybz/set-put-strdup
Let set_put_strdup() allocate the set and related changes
2020-05-07 17:01:59 +02:00
Lennart Poettering fb29cdbef2 tree-wide: make sure our control buffers are properly aligned
We always need to make them unions with a "struct cmsghdr" in them, so
that things properly aligned. Otherwise we might end up at an unaligned
address and the counting goes all wrong, possibly making the kernel
refuse our buffers.

Also, let's make sure we initialize the control buffers to zero when
sending, but leave them uninitialized when reading.

Both the alignment and the initialization thing is mentioned in the
cmsg(3) man page.
2020-05-07 14:39:44 +02:00
Lennart Poettering a258f4915a tree-wide: use CMSG_SPACE() (and not CMSG_LEN()) to allocate control buffers
We need to use the CMSG_SPACE() macro to size the control buffers, not
CMSG_LEN(). The former is rounded up to next alignment boundary, the
latter is not. The former should be used for allocations, the latter for
encoding how much of it is actually initialized. See cmsg(3) man page
for details about this.

Given how confusing this is, I guess we don't have to be too ashamed
here, in most cases we actually did get this right.
2020-05-07 14:39:44 +02:00
Daan De Meyer d402edb764 resolved: Fix build error due to missing include. 2020-05-07 03:05:50 -07:00
Daan De Meyer be28f72d6a resolved: Break include cycles 2020-05-07 09:00:48 +02:00
Zbigniew Jędrzejewski-Szmek be32732168 basic/set: let set_put_strdup() create the set with string hash ops
If we're using a set with _put_strdup(), most of the time we want to use
string hash ops on the set, and free the strings when done. This defines
the appropriate a new string_hash_ops_free structure to automatically free
the keys when removing the set, and makes set_put_strdup() and set_put_strdupv()
instantiate the set with those hash ops.

hashmap_put_strdup() was already doing something similar.

(It is OK to instantiate the set earlier, possibly with a different hash ops
structure. set_put_strdup() will then use the existing set. It is also OK
to call set_free_free() instead of set_free() on a set with
string_hash_ops_free, the effect is the same, we're just overriding the
override of the cleanup function.)

No functional change intended.
2020-05-06 16:54:06 +02:00
Zbigniew Jędrzejewski-Szmek 0894f08bf1 resolve: fix type of parameter and update man page
The "a" got dropped in eff7c2d3c9.
2020-05-06 15:02:38 +02:00
Zbigniew Jędrzejewski-Szmek ba5a389d24 Merge pull request #15473 from keszybz/bus-introspection 2020-05-06 15:00:07 +02:00
Daan De Meyer eff7c2d3c9 sd-bus: Add a nicer way of specifying sd-bus vtable method arguments
SD_BUS_NAMES_WITH_ARGS is a less error-prone way of specifying D-Bus
method arguments.
2020-05-06 10:22:54 +02:00
Zbigniew Jędrzejewski-Szmek 8d1280897b resolved: convert to the new scheme 2020-05-05 22:36:37 +02:00
Zbigniew Jędrzejewski-Szmek d4cc0edfce importd,logind: add --bus-introspect= option 2020-05-05 22:34:17 +02:00
Zbigniew Jędrzejewski-Szmek fc021a5bbf logind,importd,hostnamed,localed,timedated,machined,resolved: add option parsing stubs
--help and --version are implemented in the usual style.
help() prints full path, since the program is not expected to
be in $PATH.
2020-05-03 10:55:51 +02:00
Lennart Poettering 268f5a5463 tree-wide: support a bunch of additional specifiers 2020-04-28 22:47:21 +02:00
Lennart Poettering 0f4a141744
Merge pull request #15504 from poettering/cmsg-find-pure
just the recvmsg_safe() stuff from #15457
2020-04-23 17:28:19 +02:00
Lennart Poettering a9ab5cdb50
Merge pull request #15472 from keszybz/dbus-api-docs
A few more dbus api documentation updates
2020-04-23 17:01:11 +02:00
Lennart Poettering 3691bcf3c5 tree-wide: use recvmsg_safe() at various places
Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.

This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.

(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
2020-04-23 09:41:47 +02:00
Zbigniew Jędrzejewski-Szmek 4ee40eefce
Merge pull request #15516 from poettering/nspawn-resolv-conf
beef up --resolv-conf= options of systemd-nspawn
2020-04-23 08:01:46 +02:00
Lennart Poettering 082814743f resolve: move resolv.conf path definitions to shared header
That way we can use it from nspawn.
2020-04-22 19:38:04 +02:00
Lennart Poettering 4c4520789d resolved: replace private log level control API with generic one
The property was just added, let's replace it again. Given that it was
never released this should not be an API breakage.
2020-04-21 17:08:02 +02:00
Zbigniew Jędrzejewski-Szmek 38b38500c6 tree-wide: use "hostname" spelling everywhere
It's not that I think that "hostname" is vastly superior to "host name". Quite
the opposite — the difference is small, and in some context the two-word version
does fit better. But in the tree, there are ~200 occurrences of the first, and
>1600 of the other, and consistent spelling is more important than any particular
spelling choice.
2020-04-21 16:58:04 +02:00
Lennart Poettering f9411d5d5f
Merge pull request #15495 from keszybz/resolve-debugging-and-stub-handling
Resolve debugging and stub handling
2020-04-21 09:34:21 +02:00
Zbigniew Jędrzejewski-Szmek ca8b81d923 resolve: when the stub listener is disabled, symlink stub-resolv.conf to resolv.conf
When the stub listener is disabled, stub-resolv.conf is useless. Instead of
warning about this, let's just make stub-resolv.conf point to the private
resolv.conf file. (The original bug report asked for "mirroring", but I think
a symlink is nicer than a copy because it is easier to see that a redirection
was made.)

Fixes #14700.
2020-04-20 15:50:40 +02:00
Zbigniew Jędrzejewski-Szmek 965228a846 resolve: when writing of private resolv.confs fails, do not remove old copies
All callers ignore the return value.

This is almost entirely theoretical, since writing to /run is unlikely to
fail..., but the user is almost certainly better off keeping the old copy
around and having working dns resolution with an out-of-date dns server list
than having having a dangling /etc/resolv.conf symlink.
2020-04-20 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek 5c35cd5f47 resolved: include actual path in error message
An error with a full path is immediately clear. OTOH, a user might not be
familiar with concenpt like "private resolv.conf".

I opted to use %s-formatting for the path, because the code is much easier to
read this way. Any difference in t speed of execution is not important.
2020-04-20 15:43:33 +02:00
Zbigniew Jędrzejewski-Szmek e53b8cc521 resolved: return org.freedesktop.resolve1.DnsError.NXDOMAIN on LLMNR resolution failure
Fixes #14922.
2020-04-20 15:33:18 +02:00
Zbigniew Jędrzejewski-Szmek df9578498f resolve: allow setting the log level dynamically as in pid1
This is useful to raise the log level for a single transaction or a few,
without affecting other state of the resolved as a restart would.
The log level can only be set, I didn't bother with having the ability
to restore the original as in pid1.
2020-04-20 15:33:18 +02:00
Zbigniew Jędrzejewski-Szmek 3d334c40b4 resolved: fix minor confusion in comment
Suffixing != prefixing.
2020-04-20 12:16:56 +02:00
Lennart Poettering 09f8722801
Merge pull request #15396 from keszybz/dbus-api-docs
D-bus API docs
2020-04-17 23:40:50 +02:00
Lennart Poettering 4444e8533f
Merge pull request #15454 from keszybz/codespell-fixes
Spelling fixes based on codespell suggestions
2020-04-17 15:53:01 +02:00
Zbigniew Jędrzejewski-Szmek a942084057 resolved: fix typo in an unused function and add comment
Follow-up for 2615691003.
2020-04-16 20:30:50 +02:00
Zbigniew Jędrzejewski-Szmek edc6a8031e resolved: add dbus parameter names 2020-04-16 19:46:40 +02:00
Lennart Poettering ce416f425c resolved: tone down comment in /run/systemd/{stub-,}resolve.conf
There are legitimate reasons to access the file directly, as currently
discussed on fedora-devel. Hence tone things down from "must" to "should
typically not".

Also, let's use fputs() instead of fputs_unlocked() here,
fopen_temporary_label() turns off stdio locking anyway for the whole
FILE*, hence no need to do this manually each time.
2020-04-16 19:43:00 +02:00
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