Commit Graph
2830 Commits
Author SHA1 Message Date
Daan De Meyer 87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Jelle van der Waa 2a3f05400a resolve: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
No functional change, just refactoring.
2025-11-21 17:34:58 +01:00
Zbigniew Jędrzejewski-Szmek 5220bb8c3f meson: automatically add 'extract' to 'sources'
In all cases, everything that we list in 'extract', we also list in
'sources'. We can simplify things by automatically appending the first
list to the second.

In the listings, move 'extract' key right below 'sources', since now
they are both "sources", just with slightly different meanings.
2025-11-20 10:03:48 +09:00
Yu Watanabe 4f9f6a8517 resolve: voidify one function call
Fixes CID#1643235.
2025-11-16 14:06:26 +09:00
Yu Watanabe 8c236eca78 resolve: fix typo
Follow-up for 8209f4adcd.
2025-11-16 11:13:56 +09:00
Lennart Poettering 8209f4adcd resolved: add hook api
This introduces /run/systemd/resolve.hook/ as a new directory that local
(privileged) programs can bind a Varlink socket into. If they do they'll
get a method call for each attempted resolved lookup, which they can
then either process themselves (and generate new records for, or return
errors to block stuff) or let pass so that the regular resolution is
done.

Usecase for this is primarily two things:

1. in machined we can add local resolution of machine names to their IP
   addresses, similar in fashion to nss-mymachines, but working also if
   the non-NSS interfaces to name resolution are used, i.e. the local
   DNS responder. In fact, I think we should eventually remove
   nss-mymachines from our tree, as soon as this code in resolved is
   setlled.

2. in networkd we can add local resolution of names specified in DHCP
   leases we hand out.

But beyond that there should be many other uses, for example people
could write "dns firewalls" with this if they like where they
dynamically block certain names from resolution.

Fixes: #8518
2025-11-15 07:44:24 +01:00
Luca Boccassi 555d878749 varlink: say which socket failed to bind in log message
Makes it a lot easier to debug failures
2025-11-15 10:02:10 +09:00
Yu Watanabe b1a95a3aa7 resolvectl: drop an empty line between function call and error handling
Follow-up for 0536b37629.
2025-11-10 11:02:51 +09:00
Yu Watanabe f2f89678ec resolvectl: use string table
Follow-up for 0536b37629.
2025-11-10 11:02:51 +09:00
Yu Watanabe fa05718dea resolvectl: rename STATUS_PRIVATE -> STATUS_DNS_OVER_TLS 2025-11-10 11:02:51 +09:00
Yu Watanabe 6f841e58b1 resolve: do not dump cache entries when not necessary
Follow-up for 306375c368.
2025-11-10 11:02:51 +09:00
Yu Watanabe c6b6ac63ea resolve: drop unnecessary preparation of empty arrays 2025-11-10 11:01:39 +09:00
Yu Watanabe a37239d05f resolve: use JSON_BUILD_PAIR_TRISTATE_NON_NULL for default_route 2025-11-10 11:01:38 +09:00
Nick Rosbrook 0536b37629 resolvectl: implement --json flag for resolvectl status
Add --json support for all status commands in resolvectl by making use
of the new DumpDNSConfiguration varlink method. E.g,

$ resolvectl --json=pretty status eth0
[
	{
		"ifname" : "eth0",
		"ifindex" : 9,
		"defaultRoute" : true,
		"currentServer" : {
                        "addressString" : "10.148.181.1",
			"address" : [
				10,
				148,
				181,
				1
			],
			"family" : 2,
			"port" : 53,
			"ifindex" : 9,
			"accessible" : true
		},
		"servers" : [
			{
                                "addressString" : "10.148.181.1",
				"address" : [
					10,
					148,
					181,
					1
				],
				"family" : 2,
				"port" : 53,
				"ifindex" : 9,
				"accessible" : true
			}
		],
		"searchDomains" : [
			{
				"name" : "local",
				"routeOnly" : false,
				"ifindex" : 9
			}
		],
		"dnssec" : "allow-downgrade",
		"dnsOverTLS" : "no",
		"llmnr" : "no",
		"mDNS" : "no",
		"scopes" : [
			{
				"protocol" : "dns",
				"ifindex" : 9,
				"ifname" : "eth0",
				"dnssec" : "allow-downgrade",
				"dnsOverTLS" : "no"
			}
		]
	}
]

Like the regular status output, fields are omitted all together when
empty, unless explicitly requested via one of the sub-commands dns,
domain, nta, etc.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 01278ceba0 resolve: add DumpDNSConfiguration to varlink API
Add io.systemd.Resolve.DumpDNSConfiguration. This provides the same
information as io.systemd.Resolve.Monitor.SubscribeDNSConfiguration,
but just returns the configuration once without the subscription logic.

In order to use the same definitions for DNSConfiguration et al. between
both interfaces, move the definitions to io.systemd.Resolve, and include
them in io.systemd.Resolve.Monitor.

This will be used to implement --json for resolvectl status.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 0d9e5b39d3 resolve: add formatted address string to DNSServer
Although the JSON output is mostly intended to be machine readable,
humans also consume the output through logs and scripts.

Add an addressString field to DNSServer to improve human-readability.
2025-11-06 05:17:59 -05:00
Nick Rosbrook f5d5ef9cb4 resolve: add fallback servers list to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 9f9264e3f6 resolve: add resolv.conf mode to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook ed4d43f88f resolve: add all protocol modes to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 306375c368 resolve: add DNS scope info to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Nick Rosbrook a80f9291cc resolve: add negative trust anchors to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Nick Rosbrook 34be1fadde resolve: add delegate info to DNSConfiguration
This is one of several commits to expand the DNSConfiguration varlink
type to include the necessary information for resolvectl status output.
2025-11-06 05:17:58 -05:00
Nick Rosbrook 994b350860 resolve: add {global,link}_dns_configuration_json_append() helpers
No functional change, just add these helpers to improve readability in
dns_configuration_json_append(). This is preparation for later commits.
2025-11-06 05:17:58 -05:00
Yu Watanabe c29e304562 Several OpenSSL related cleanups (#39455) 2025-11-02 17:21:51 +09:00
Yu Watanabe 4f589e8a50 resolvectl: fix typo
Follow-up for 7517e41a49.
2025-11-02 17:00:23 +09:00
Yu Watanabe a47a403ca2 resolvectl: return earlier from openpgp command when OpenSSL support is disabled
When OpenSSL is disabled, string_hashsum_sha256()/_sha224() in
resolve_openpgp() will fail anyway. Let's return earlier.
2025-11-02 16:07:46 +09:00
Lennart Poettering 7517e41a49 resolvectl: do not use strjoina() on user provided strings 2025-11-02 04:41:07 +09:00
Septatrix 93b6d43253 Remove dns0.eu from default DNS servers
The service has ceased operation.
Partially reverts 02527e95b5.
2025-10-22 01:39:41 +02:00
Lennart Poettering 5751b236a5 resolved: move DNS RR/key/answer/question/packet tools to shared/
We want to reuse these generic DNS concepts in resolved hook
implementations, hence move them to shared code.

(This also enables us to immediately remove som SVCB record handling
duplicate definitions.)

No real code changes, just some moving around of things.
2025-10-20 10:35:23 +02:00
Daan De Meyer b8ee7c2206 tree-wide: Various forward header cleanups
- Make sure forward headers have the iwyu pragma to always keep them
- Make sure we always include the daemon specific forward header
  instead of shared-forward.h
- Remove shared-forward.h include where the daemon specific forward
  header is already included
2025-10-17 21:11:23 +09:00
Daan De Meyer f102bc3e5f tree-wide: Introduce sd-forward.h and shared-forward.h headers
Let's not leak details from src/shared and src/libsystemd into
src/basic, even though you can't actually do anything useful with
just forward declarations from src/shared.

The sd-forward.h header is put in src/libsystemd/sd-common as we
don't have a directory for shared internal headers for libsystemd
yet.

Let's also rename forward.h to basic-forward.h to keep things
self-explanatory.
2025-10-16 17:00:29 +02:00
Lennart Poettering b7f6bdbbd3 service-util: add generic parser for runtime scope 2025-09-25 22:43:59 +02:00
Mantas Mikulėnas 6cae201ca1 resolve: undo change to return code of next_search_domain() (#39119)
This caused resolved to only consider the 1st search domain of every
interface and ignore the rest.

Fixes a regression caused by 81ae2237c1 (v258).
Fixes #39118.
2025-09-26 04:52:18 +09:00
Daan De Meyer 9adb4685df tree-wide: Remove unused includes 2025-09-19 14:46:55 +02:00
Yu Watanabe 600c757b5f resolve/varlink: use sd_json_dispatch_const_string() at more places 2025-09-18 09:07:36 +09:00
Yu Watanabe 6c135f7ace resolve/varlink: replace json_dispatch_address() with json_dispatch_byte_array_iovec() 2025-09-18 09:06:48 +09:00
Yu Watanabe a5527e2228 resolve: shorten conf parser name and realign gperf table 2025-09-17 22:07:27 +09:00
Antonio Alvarez Feijoo 134fde8666 resolvectl: add missing error check
Follow-up for 45817e9245
2025-08-28 14:09:14 +02:00
Nick Rosbrook 6d22472089 resolve: re-create link unicast scopes on reload
On reload, resolved does not apply new DNSSEC= (or DNSOverTLS=) settings
on links, because the link unicast scopes are not re-created. However,
the servers and link states are updated correctly, so resolvectl and link
state files do show the new setting, leading users to believe the change
took effect immediately, the same way `resolvectl dnssec` does.

Fix this by freeing all of the link unicast scopes during reload, so
that they are re-created with the new settings in link_allocate_scopes().
2025-08-27 22:33:38 +09:00
Nick Rosbrook 71da422058 resolve: include DNSSEC and DNSOverTLS modes in dumps
This is useful for testing and debugging. E.g., one can examine the
active DNSSEC mode of the scope using:

$ resolvectl show-cache
2025-08-27 22:33:38 +09:00
Luca Boccassi e9caf17f63 Revert "resolved: don't wait for TLS close_notify replies unnecessarily"
This change introduced a regression that stops DNSOverTLS from working
after some time. Revert it for now, as there's no fixup available at
the moment.

Fixes https://github.com/systemd/systemd/issues/38509

This reverts commit 4b6dbd4ea5.
2025-08-20 14:04:27 +02:00
Yu Watanabe 40f597555a resolve: fix index of comments and rebreak comments 2025-08-17 02:06:42 +09:00
Luca Boccassi 855b6b77e0 test: fix typo in comment 2025-08-16 10:53:07 +01:00
Yu Watanabe 948b186f46 test-dns-question: use ASSERT_OK_POSITIVE/ZERO() rather than ASSERT_TRUE/FALSE()
Similar to 100a98960a.

E.g. dns_question_contains_key() may return negative errno, hence we
should not use ASSERT_TRUE/FALSE() for the function.

This also has bunch of cleanups:
- call functions in ASSERT_NOT_NULL(),
- add short comments for constant function arguments,
- merge several test cases,
- use memstream, rather than temporal files.

Fixes CID#1619185.
2025-08-04 11:35:03 +01:00
Yu Watanabe 100a98960a test-dns-answer: fix misuse of ASSERT_TRUE/FALSE()
E.g. dns_answer_match_key() may return negative errno, hence we should
use ASSERT_OK_POSITIVE/ZERO().

This also has bunch of cleanups:
- call functions in ASSERT_NOT_NULL(),
- add short comments for constant function arguments,
- merge several test cases,
- use memstream, rather than temporal files.
2025-08-02 11:02:31 +01:00
Yu Watanabe 0d229ef102 resolve: bump *_SEARCH_DOMAIN_MAX to 1024
As prompted by #38393, search domains may be large when a complicated
network setting is used, especially when VPN is used. Let's bump the
limit to 1024.

Note, this does not bump the maximum number of DNS servers, as setting
thousands of DNS servers is spurious and mostly meaningless. Let's keep
the maximum for a while until someone requests to also bump them.

Continuation of b950ee06e6.

Closes #38393.
2025-07-30 18:57:09 +01:00
Zbigniew Jędrzejewski-Szmek 858cb6e49e tree-wide: use ERRNO_NAME almost everywhere
We had errno_to_name() which works for "known" errnos, and returns NULL for
unknown ones, and then ERRNO_NAME which always returns an answer, possibly just
a number as a string, but requires a helper buffer.

It is possible for the kernel to add a new errno. We recently learned that some
architectures define custom errno names. Or for some function to unexpectedly
return a bogus errno value. In almost all cases it's better to print that value
rather than "n/a" or "(null)". So let's use ERRNO_NAME is most error handling
code. Noteably, our code wasn't very good in handling the potential NULL, so
in various places we could print "(null)". Since this is supposed to be used
most of the time, let's shorten the names to ERRNO_NAME/errno_name.

There are a few places where we don't want to use the fallback path, in
particular for D-Bus error names or when saving the error name. Let's rename
errno_to_name() to errno_name_no_fallback() to make the distinction clearer.
2025-07-29 18:05:20 +02:00
Yu Watanabe 4d13e4dcbb resolved: use usec_add() at one more place
Follow-up for 8458b7fb91.
Fixes CID#1612580.
2025-07-26 03:44:49 +09:00
Zbigniew Jędrzejewski-Szmek c5dcbd073e meson: use files() not find_program() for helper scripts
We went back and forth between 'prog.sh', files('prog.sh'), and
find_program('prog.sh'). We want to use files() or find_program() so that we
get a good error message if the file is missing. Behaviour of meson changed
over time, and in the past not all forms could be used in all places. For
example 0f4c4f3824 added find_program() in many
places to avoid repeated messages. But it seems that all recent meson versions
work fine with files().

find_program prints silly messages:
  Program tools/make-man-index.py found: YES
       (/home/zbyszek/src/systemd/tools/make-man-index.py)
  Program tools/meson-render-jinja2.py found: YES
       (/home/zbyszek/src/systemd/tools/meson-render-jinja2.py)
  ...
We know that those files will be found, they are part of the git checkout.
With files() this is gone and the meson output is easier to read.
2025-07-25 14:04:17 +02:00
Yu Watanabe 5c34d85c74 tree-wide: normalize usage of %m 2025-07-22 03:05:54 +09:00