Commit Graph
100 Commits
Author SHA1 Message Date
Nick Rosbrook cf31d92de3 resolvectl: implement log-level with varlink methods 2026-08-24 13:32:42 -04:00
Nick Rosbrook 071f10991c shared: add varlink_{get,set}_log_level_string helpers to verb-log-control.c
Most of the time, the CLI tools that will use this helper are dealing
with the string representation of log levels, so just add string-based
helpers for now.
2026-08-24 13:32:42 -04:00
Nick Rosbrook 0420097525 varlink: introduce io.systemd.service.GetLogLevel
We already have io.systemd.service.SetLogLevel. Add a getter so that
CLI tools with `log-level` subcommands can be more easily implemented
with varlink.

Bind this method to all services that already bind io.systemd.service.SetLogLevel.
2026-08-24 11:54:44 -04:00
Nick Rosbrook 3a09ba33e2 resolvectl: use io.systemd.Resolve.Monitor.ResetServerFeatures
Use the new varlink method instead of dbus.
2026-08-21 11:54:32 -04:00
Nick Rosbrook 6c248546df resolve: introduce io.systemd.Resolve.Monitor.ResetServerFeatures
Add varlink version of ResetServerFeatures.

Add this to io.systemd.Resolve.Monitor, since that interface already
handles many manager related things.
2026-08-21 11:54:32 -04:00
Nick Rosbrook 85dd7a2170 resolvectl: use io.systemd.Resolve.Monitor.FlushCaches
Use the new varlink method instead of dbus.
2026-08-21 11:54:32 -04:00
Nick Rosbrook 881ab94dd0 resolve: introduce io.systemd.Resolve.Monitor.FlushCaches
Add varlink version of FlushCaches.

Add this to io.systemd.Resolve.Monitor, since that interface already
handles many cache and manager related things.
2026-08-21 10:27:03 -04:00
Nick Rosbrook f195b1c1a8 meson: add build option for /var/log mode
In Ubuntu, rsyslog is (a) part of the minimal image and (b) does not run
as root. To facilitate this, the rsyslog package configures /var/log
to be writeable by the syslog group.

There are currently conflicts in the Ubuntu packaging due to the way
tmpfiles are handled in package scripts: when systemd-tmpfiles is
invoked with both configurations (or for all configurations), things
work fine. But if invoked with only var.conf, which is the default case
for package upgrades, rsyslog is broken.

One suggestion to approach this was to make rsyslog's tmpfile
configuration use ACLs instead of trying to change the owning group and
directory mode. This can work, but since the ACL mask is stored in the
group permission bits, the effective mask for rsyslog becomes r-x again
when var.conf is invoked, because it sees that 0775 != 0755, and chmods
the directory.

Hence, for /var/log write permisssions to be extendable with ACLs,
the mode must be at least 0775. Rather than change the default,
add a build option to configure the /var/log mode.
2026-07-28 21:23:18 +09:00
Nick Rosbrook 2e89b19aa1 test: reduce number of disks in TEST-64-UDEV-STORAGE-simultaneous_events on Debian/Ubuntu
This test never finishes in Ubuntu autopkgtest with the current values,
and is currently skipped all together on Debian. When running on either,
reduce the number of disks to make the test more reliable.
2026-06-30 16:24:06 +01:00
Nick Rosbrook fa6fe468f4 resolvectl: use varlink instead of dbus for ResolveService 2026-06-26 16:03:18 -04:00
Nick Rosbrook 4e1943a209 nss-resolve: use resolve-varlink-util.h helpers
Re-factor using the shared code introduced for resolvectl.
2026-06-26 16:03:18 -04:00
Nick Rosbrook 3ecf3aba94 test: relax grep for DNS query refusal
The punctuation is not strictly important for the error.
2026-06-26 16:03:18 -04:00
Nick Rosbrook cfac7ec169 resolvectl: use varlink instead of dbus for ResolveRecord 2026-06-26 16:03:18 -04:00
Nick Rosbrook 5ff17fb750 resolvectl: use varlink instead of dbus for ResolveAddress 2026-06-26 16:03:18 -04:00
Nick Rosbrook 35d611622a resolvectl: use varlink instead of dbus for ResolveHostname 2026-06-26 16:03:18 -04:00
Nick Rosbrook cc6bc699c7 resolve: add query string field to io.systemd.Resolve.DNSError
This is preparation for using varlink methods more in resolvectl. In
particular, this is helpful for proving more accurate error messages,
and maintaining compatibility with existing error messages from the
DBus API.
2026-06-26 09:12:10 -04:00
Nick Rosbrook 3f73f1ef75 json-util: introduce json_dispatch_in_addr_data
Generalize json_dispatch_address from nss-resolve, and add support for
strings to be compatible with the existing json_dispatch_{in,in6}_addr
helpers. This will be used in a later commit.
2026-06-26 09:12:10 -04:00
Nick Rosbrook c5f08a2e5c json-util: generalize json_dispatch_address_family
There are several places where address family is dispatched from JSON,
so take json_dispatch_address_family from networkd and put it in
json-util.c.

Update the all instances in the tree to use this new function, adding
SD_JSON_RELAX to the dispatch flags if AF_UNSPEC should be allowed
in that case.
2026-06-26 09:12:10 -04:00
Nick Rosbrook 3405c9da33 mkosi: copy packaged test-fdstore if not built locally
On Ubuntu autopkgtest, TEST-91-LIVEUPDATE fails because test-fdstore is
not found in the dummy container.
2026-06-19 18:35:15 +01:00
Nick Rosbrook 55ba38cefc test: fix check for updatectl
The have_updatectl variable is meant to gracefully handle the case where
updatectl is missing. But, because the script runs with -e, it fails
immediately in that case instead. Moreover, expanding $have_updatectl
when it is present actually executes updatectl, rather than simply
checking for its existence.

Re-factor this check so that it does handle a missing updatectl.
2026-06-11 15:17:36 +01:00
Nick Rosbrook 37adb410a2 units: order networkd resolve hook After=network-pre.target
Without this, the socket is available well before systemd-networkd.service
is able to start, because of its own After=network-pre.target ordering.
Then, if resolved handles queries before network-pre.target, it will
hang waiting for networkd to reply to hook queries.

This is currently happening in the wild with cloud-init.
2026-04-24 17:59:54 +01:00
Nick Rosbrook da18a5cfd6 test: do not use nanoseconds width specifier in date command
Using the format specifier +%s%6N with GNU date is honored, and only
prints 6 digits of the nanoseconds portion of the seconds since epoch.
The uutils implementation of date does not honor this, and always prints
all 9 digits. This is a known bug[1], but can be worked around by
adapting this test to use nanoseconds instead of microseconds.

[1] https://github.com/uutils/coreutils/issues/11658
2026-04-14 14:54:32 +01:00
Nick Rosbrook cceddc41fd network-generator: support BOOTIF= and rd.bootif=0 options
The network generator currently supports many of the options described
by dracut.cmdline(7), but not everything.

This commit adds support for the BOOTIF= option (and the related
rd.bootif= option) used in PXE setups.

This is implemented by treating BOOTIF as a special name/placeholder
when used as an interface name, and expecting a MAC address to be set in
the BOOTIF= parameter. The resulting .network file then uses MACAddress=
in the [Match] section, instead of Name=.
2026-03-30 10:48:55 -04:00
Nick Rosbrook caeec0de6d ether-addr-util: introduce hw_addr_is_valid()
Take this from udev, and adapt it to make it re-usable elsewhere.
2026-03-30 10:48:54 -04:00
Nick Rosbrook 83359c4da0 socket-util: filter out VMADDR_CID_ANY in vsock_get_local_cid()
It has been observed on some systems[1] that ssh-issue may print out:

 Try contacting this VM's SSH server via 'ssh vsock%4294967295' from host.

i.e. it suggests connecting with VMADDR_CID_ANY, which is not valid. It
seems that IOCTL_VM_SOCKETS_GET_LOCAL_CID may return VMADDR_CID_ANY in
some cases, e.g. when vsock is not full initialized or so.

Treat VMADDR_CID_ANY as special in vsock_get_local_cid(), the same as
VMADDR_CID_LOCAL and VMADDR_CID_HOST, and return an error.

[1] https://launchpad.net/bugs/2145027
2026-03-20 11:37:31 -04:00
Nick Rosbrook 4341ba091d ssh-proxy: return an error if user supplies VMADDR_CID_ANY
Right now, if a user tries to pass VMADDR_CID_ANY to systemd-ssh-proxy,
an assert is triggered:

 $ ssh vsock%4294967295
 Assertion 'cid != VMADDR_CID_ANY' failed at src/ssh-generator/ssh-proxy.c:21, function process_vsock_cid(). Aborting.
 mm_receive_fd: recvmsg: expected received 1 got 0
 proxy dialer did not pass back a connection

This is becauase the value returned from vsock_parse_cid is not checked
before being passed to process_vsock_string. Add a check to prevent
that.
2026-03-20 11:37:31 -04:00
Nick Rosbrook 7a1888954c seccomp-util: add lsm_get_self_attr and lsm_list_modules to @default
These syscalls are part of a newer kernel API to replace interaction
with /proc/self/attr, with the goal of allowing LSM stacking. These are
being used now by e.g. libapparmor, so should be more easily available
to services using seccomp filtering.
2026-02-25 11:35:54 +01:00
Nick Rosbrook e28958315f resolvectl: include ifindex when printing link-local DNS server
Historically, resolvectl status has not included the interface
specification for DNS servers with an IPv6 link-local address, since it
is technically somewhat redundant. But, adding this extra bit of
information makes it easier to copy-and-paste to use elsewhere, etc.

For example, the previous output:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7
         DNS Domain: lan

now becomes:

 Link 2 (enp34s0)
     Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
          Protocols: +DefaultRoute LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
 Current DNS Server: fe80::861e:a3ff:feb1:f8e7%2
        DNS Servers: 192.168.1.12 192.168.1.13 fe80::861e:a3ff:feb1:f8e7%2
         DNS Domain: lan
2026-02-07 00:14:37 +01:00
Nick Rosbrook a4750a6612 resolvectl: add print_configuration() to consolidate status logic
There is a lot of duplication across the functions for printing global,
link, and delegate output. Since these all use a common DNSConfiguration
type now, the logic can be consolidated.

Adapt printing and format helper functions to accept a DNSConfiguration
parameter to appropriately format output. Then, add print_configuration(),
a single function that prints the appropriate status output based on the
contents of DNSConfiguration.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 480ebdfddd resolvectl: consolidate JSON and regular status output paths
Now that varlink is always used for status output, consolidate the JSON
and regular status code paths. Add status_full(), which is the single
point that calls DumpDNSConfiguration, filters based on link names and
mode if needed, and prints the output in the appropriate format.

This simplifies status_ifindex(), and removes the need for a separate
status_json().
2026-02-03 15:07:41 -05:00
Nick Rosbrook 67746cd3b2 resolvectl: use varlink to report delegate status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular delegate status output using the DumpDNSConfiguration
varlink method. And, remove the DelegateInfo type and associated functions
which were used to map dbus properties.

Since this is the last type of status output to be switched to varlink,
lots of other code becomes dead with these changes, e.g.
read_dns_server_one(), map_dns_servers_internal(), etc., so remove those
too. Finally, status_all() no longer needs sd_bus, so drop that
parameter.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d076d0f94f resolvectl: use varlink to report link status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular link status output using the DumpDNSConfiguration
varlink method. And, remove the LinkInfo type and associated functions
which were used to map dbus properties.
2026-02-03 15:07:41 -05:00
Nick Rosbrook a56366182e resolvectl: use varlink to report global status
This is an incremental commit to replacing dbus usage with varlink for
all status output.

Re-implement regular global status output using the DumpDNSConfiguration
varlink method. And, remove the GlobalInfo type and associated functions
which were used to map dbus properties.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 7bfc82bf5a dns-configuration: use OrderedSet for servers and domains
This only has a small effect, which mostly matters for generating status
output. It ensures that the order of servers and domains displayed
matches the order they are stored on the daemon side, which keeps the
new resolvectl output consistent with the old.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 8894f29a4e dns-configuration: add DNSSEC support boolean to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d9757721ab dns-configuration: add in_addr_union field to DNSServer type
This makes it easier to use DNSServer with helpers from in-addr-util.h.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 8731d33b58 dns-configuration: dispatch delegate name to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 3afb9c20b6 dns-configuration: dispatch scopes to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.

Introduce a DNSScope type, and all required JSON dispatching helpers.
2026-02-03 15:07:41 -05:00
Nick Rosbrook e90180f50c dns-configuration: dispatch resolv conf mode to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 4a8f4efd44 dns-configuration: dispatch negative trust anchors to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook d3b60567d7 dns-configuration: dispatch fallback servers to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook fb0bd15d15 dns-configuration: dispatch all protocol modes to DNSConfiguration
This is one of several commits to dispatch all fields of the
DNSConfiguration JSON.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 271f7630a2 shared: move wait-online's dns-configuration.[ch] to shared 2026-02-03 15:07:41 -05:00
Nick Rosbrook 9b2f263f30 resolve: add DNSConfiguration field to indicate DNSSEC support
The varlink API is currently missing the "DNSSEC supported" field, which
is required for to re-implement the existing resolvectl status output
with varlink instead of dbus.

Add this field to DNSConfiguration.
2026-02-03 15:07:41 -05:00
Nick Rosbrook 7c9c34514a test: disable pipefail again in monitor_check_rr()
Partially reverts d6b3793704.

On Ubuntu 26.04 devel, TEST-75-RESOLVED often fails at this stage,
despite the matching query apparently being found:

 + monitor_check_rr '2025-12-18 16:02:54' 'follow10.so.close.signed.test IN CNAME follow11.yet.so.far.signed.test'
  + set +x
  Dec 18 16:02:54 ns1.unsigned.test resolvectl[552]: ← A: follow10.so.close.signed.test IN CNAME follow11.yet.so.far.signed.test
 + monitor_check_rr '2025-12-18 16:02:54' 'follow11.yet.so.far.signed.test IN CNAME follow12.getting.hot.signed.test'
  + set +x
  Dec 18 16:02:54 ns1.unsigned.test resolvectl[552]: ← A: follow11.yet.so.far.signed.test IN CNAME follow12.getting.hot.signed.test
 + monitor_check_rr '2025-12-18 16:02:54' 'follow12.getting.hot.signed.test IN CNAME follow13.almost.final.signed.test'
  + set +x
  Dec 18 16:02:54 ns1.unsigned.test resolvectl[552]: ← A: follow12.getting.hot.signed.test IN CNAME follow13.almost.final.signed.test
 + monitor_check_rr '2025-12-18 16:02:54' 'follow13.almost.final.signed.test IN CNAME follow14.final.signed.test'
  + set +x
  Dec 18 16:02:54 ns1.unsigned.test resolvectl[552]: ← A: follow13.almost.final.signed.test IN CNAME follow14.final.signed.test

Unsetting pipefail, as was done before d6b3793704, appears to fix the
problem.
2026-01-30 09:36:53 -05:00
Nick Rosbrook 9dcfd6e8fe test: cope with uutils coreutils flag parsing for date command
With GNU coreutils, one can pass an argument to the "set" flag like:

 date -s "-3 days"

With uutils coreutils, that gives an error:

 error: unexpected argument '-3' found
    tip: to pass '-3' as a value, use '-- -3'

That's a bug (https://github.com/uutils/coreutils/issues/9679), but both
implementations accept --set="-3 days" just fine, so use that instead.
2026-01-30 09:30:20 -05:00
Nick Rosbrook a8efad14f8 test: use journalctl -n option instead of piping to head
On Ubuntu's test infrastructure for the development series, this test
often fails when piping the journal output to head. The cause is
unclear, but possibly related to Ubuntu's use of uutils coreutils.

Workaround this by just using journalctl's -n flag, which removes the
need for piping output to head.
2026-01-30 09:30:20 -05:00
Nick Rosbrook e06ee11150 test: check that currentServer field is set in resolvectl JSON status 2026-01-19 13:48:07 -05:00
Nick Rosbrook d990b426b9 resolve: include current DNS server in JSON again
The current_dns_server_json object in dns_configuration_json_append() is
always NULL, because the logic to dump the current DNS server to JSON
was removed by mistake in a re-factoring commit. Add that logic back.

Fixes c6b6ac63ea ("resolve: drop unnecessary preparation of empty arrays").
2026-01-19 13:29:52 -05:00
Nick Rosbrook 0eaddf8c82 mkosi: stop using noble-proposed for qemu
The qemu update migrated to noble-updates a couple weeks ago, so it is
no longer necessary to enable noble-proposed (or add the associated apt
pinning config).
2026-01-06 04:47:27 +09:00
Nick Rosbrook 75890d949f ukify: omit .osrel section when --os-release= is empty
The primary motivation for this is to allow users of ukify to build
UKI-like objects, without having them later be detected as a UKI by
tools like kernel-install and bootctl.

The common code used by these tools to determine if a PE binary is a UKI
checks that both .osrel and .linux sections are present. Hence, adding
a mechansim to skip .osrel provides a way to avoid being labeled a UKI.
2026-01-06 04:44:43 +09:00
Nick Rosbrook 39d3f63782 mkosi: use qemu from noble-proposed instead of ppa
This is also temporary, but demonstrates that the version of qemu
currently in noble-proposed fixes https://launchpad.net/bugs/2127974,
which will ultimately allow for the fix to be released to noble-updates.
2025-12-15 19:16:57 +00:00
Nick Rosbrook 7d23e27e4c test: skip test-reread-partition-table if missing privileges
Right now, this test runs inside unprivileged chroots, despite the
running_in_chroot() check. This is because running_in_chroot() fails
with -EACCES, which is ignored.

Hence, check for privileges before calling running_in_chroot(),
otherwise call is inconclusive. Note, the test will fail later on if
running without privileges anyways.
2025-11-21 19:28:05 +00:00
Nick Rosbrook 40a6069f9a test: adjust timeouts for testcase_15_wait_online_dns
Do not set a timeout on the wait-online call, since there are timeout
calls later that will prevent the test from blocking forever. Increase
those timeout calls for slower CI runs.
2025-11-14 14:46:16 -05:00
Nick Rosbrook be394fcaff test: increase timeout waiting for zone DS records setup
This test is flaky on the infrastructure due to this setup step timing
out. As a naive step, just increase the timeout to 60s.

Part 1 of #39602
2025-11-14 14:46:16 -05:00
Nick Rosbrook 3d6eb1ed42 test: wait for interface to come online before checking DNS scopes
The current test is flaky because it creates a new interface definition,
calls networkctl reload, and then calls resolvectl show-cache. If
resolved has not received the changes and setup the DNS scopes for the
interface, show-cache will be empty for that interface.

Part 2 of #39602
2025-11-15 04:04:51 +09:00
Nick Rosbrook 313d216662 test: expand testcases to include resolvectl --json usage 2025-11-06 05:17:59 -05: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 d49a0bd1da wait-online: ignore unused DNSConfiguration fields when dispatching JSON
The io.systemd.Resolve.Monitor.DNSConfiguration type is being expanded,
but we do not need the extra information for determining online status.

Ignore these fields when dispatching JSON to avoid "Unrecognized object field"
messages adding noise to systemd-networkd-wait-online debug output.
2025-11-06 05:17:59 -05:00
Nick Rosbrook 5e777155d5 wait-online: dispatch DNSConfiguration with SD_JSON_ALLOW_EXTENSIONS
Currently if an unknown field is encountered in the JSON, it is a fatal
error. Dispatch with SD_JSON_ALLOW_EXTENSIONS to avoid this.
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
Nick Rosbrook 9fe168a92c basic: validate timezones in get_timezones()
Depending on the packaging of tzdata, /usr/share/zoneinfo/tzdata.zi may
reference zones or links that are not actually present on the system.
E.g. on Debian and Ubuntu, there is a tzdata-legacy package that
contains "legacy" zones and links, but they are still referenced in
/usr/share/zoneinfo/tzdata.zi shipped by the main tzdata package.

Right now, get_timezoes() does not validate timezones when building the
list, which makes the following possible:

 $ timedatectl list-timezones | grep "US/Alaska"
 US/Alaska

 $ timedatectl set-timezone US/Alaska
 Failed to set time zone: Invalid or not installed time zone 'US/Alaska'

which feels buggy. Hence, simply validate timezones in get_timezones()
to avoid listing timezones that are not installed.
2025-09-18 21:33:24 +02:00
Nick Rosbrook 1be088c299 test: ensure that reload updates DNSSEC and DNSOverTLS on link scopes 2025-08-27 22:33:38 +09:00
Nick Rosbrook f818c3d6b6 test: use numeric prefixes in resolved.conf.d overrides
There are a lot of resolved.conf.d drop-ins used in these tests. Use
proper numeric prefixes, especially to avoid confusion with sorting
relative to test.conf.

Make the test base config 10-test.conf, and use 90-*.conf elsewhere.
2025-08-27 22:33:38 +09: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
Nick Rosbrook c6b4f1c8f8 timedate: print better errors when systemd-timesyncd.service unavailable
If the error is a common bus error indicating the service is not
available, print a more user-friendly message indicating so.
2025-05-28 04:40:08 +09:00
Nick Rosbrook 906145d53f shared: add optional error parameter in bus_print_all_properties()
While here, remove the unused found_properties parameter.

This is preparation for another commit.
2025-05-28 04:40:08 +09:00
Nick Rosbrook 0e0d3ed93a networkd-test: stop resolved socket units in setUpModule()
Avoid warnings about the socket units when stopping systemd-resolved.
2025-05-01 01:52:28 +01:00
Nick Rosbrook 3ea04a9432 test: add a test for resolved and wait-online interactions
Specifically, add a test case that ensures systemd-networkd-wait-online --dns
is robust against (a) systemd-resolved absence, and (b) systemd-resolved
restarts.
2025-04-30 11:12:15 -04:00
Nick Rosbrook 5e67cb3bed wait-online: attempt to re-connect after varlink disconnects
Now that systemd-resolved has socket activation for it's varlink
sockets, this should should be enough to make the DNS configuration
logic robust against systemd-resolved stops and restarts.
2025-04-30 11:12:15 -04:00
Nick Rosbrook 0fa188307b resolved: support socket activation via varlink sockets
Add two new socket units, one for each of systemd-resolved's varlink
servers:

 systemd-resolved-varlink.socket
 systemd-resolved-monitor.socket

Add logic to grab socket fds via sd_varlink_server_listen_name(), but
fallback to the existing sd_varlink_server_listen_address() calls if no
fds were given.

This will be used to make systemd-networkd-wait-online --dns more robust
against systemd-resolved restarts etc.
2025-04-30 11:12:15 -04:00
Nick Rosbrook 971fb3b0bc polkit: use -EBUSY to indicate shortcut after error or denial
Commit 536c18e5c3 ("bus-polkit: shortcut auth. after first denial")
added logic to async_polkit_query_check_action() that returns
-EALREADY when a failure or denial decision was made for a previous
action.

Tweak this to return -EBUSY instead of -EALREADY. This hopefully makes
the intent of the error more clear. EALREADY suggests that the request
is OK, but polkit is processing something else, and we should come back
later. EBUSY suggests that polkit is busy or unusable, hence the
request cannot be processed, and we should go away.
2025-03-25 16:15:34 -04:00
Nick Rosbrook bc3a11097f login: add polkit example rules for allowing root to ignore inhibitors
The semantics of strong inhibitors require that POLKIT_ALWAYS_QUERY
always be set when checking if we can allow blocking inhibitors to be
ignored on shutdown, reboot, etc. With the default polkit rules and
policy, users may experience a situation where users in the sudo group
are authorized to run:

 systemctl reboot --check-inhibitors=no

but the root user is not authorized. Instead, the following error is
given:

 Call to Reboot failed: Interactive authentication required.

While this is correct according to the semantics of strong inhibitors,
it is confusing. To help the situation, provide example polkit rules
that allow root to perform these actions.

Finally, when root receives SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED
when calling e.g. systemctl reboot, print a message explaining that this
is due to the current polkit policy, and point to the new example rule.

Related: https://github.com/systemd/systemd/issues/36786
2025-03-25 16:15:34 -04:00
Nick Rosbrook 4b1e7a5822 login: handle -EALREADY from bus_verify_polkit_async_full()
Commit 536c18e5c3 ("bus-polkit: shortcut auth. after first denial")
added logic to async_polkit_query_check_action() that returns
-EALREADY when a failure or denial decision was made for a previous
action.

This has the consequence that root is able to ignore inhibitors and
shutdown etc. even when polkit explicitly denies it. This is because
when systemctl's verb_start_special() calls logind_reboot(), unless
the call succeeds or returns one of -EACCES, -EOPNOTSUPP, or
-EINPROGRESS, a fallback path is taken to attempt the action without
going through logind. Hence, since logind_reboot() started returning
-EALREADY in some cases, the fallback path was taken, and the shutdown
was performed anyways.

For example:

 root@ubuntu:/# cat /etc/polkit-1/rules.d/10-systemd-logind-no-skip-inhibitors.rules
 // Never allow strong inhibitors to be ignored.
 polkit.addRule(function(action, subject) {
     if ((action.id == "org.freedesktop.login1.power-off-ignore-inhibit" ||
          action.id == "org.freedesktop.login1.reboot-ignore-inhibit" ||
          action.id == "org.freedesktop.login1.halt-ignore-inhibit" ||
          action.id == "org.freedesktop.login1.suspend-ignore-inhibit" ||
          action.id == "org.freedesktop.login1.hibernate-ignore-inhibit")) {

         return polkit.Result.NO;
     }
 });
 root@ubuntu:/# systemctl reboot -i
 Call to Reboot failed: Operation already in progress

..but the reboot continues anyways due to the fallback.

To fix this, add logic in systemd-logind's verify_shutdown_creds() to
handle -EALREADY from bus_verify_polkit_async_full(): if we receive
-EALREADY when checking authorization for <action>-multiple-sessions,
and we are blocked on inhibitors, continue on to get the decision for
<action>-ignore-inhibit directly.

While here, add similar logic to method_inhibit(), which may need to
verify multiple polkit actions in a single call.

Fixes 536c18e5c3
2025-03-25 16:15:34 -04:00
Nick Rosbrook 94a5969b31 polkit: fix the ordering of a log message 2025-03-25 16:15:34 -04:00
Nick Rosbrook 5dc89b327f tree-wide: remove some spurious newlines
Specifically, remove double newlines, and newlines before '}'.
2025-01-29 16:17:46 +00:00
Nick Rosbrook d6608da1e6 networkd-test: add basic tests for systemd-networkd-wait-online --dns 2025-01-28 08:49:49 -05:00
Nick Rosbrook 5ee20919a2 test: add test for resolved SubscribeDNSConfiguration API 2025-01-28 08:49:49 -05:00
Nick Rosbrook 266cfdfc77 test: cleanup after testcase_12_resolvectl2 2025-01-28 08:49:49 -05:00
Nick Rosbrook 359db7e9b9 wait-online: add support for waiting for DNS configuration
Add a new flag to systemd-networkd-wait-online, --dns, to allow waiting
for DNS to be configured.

DNS is considered configured when at least one DNS server is accessible.
If a link has the property DefaultRoute=yes (either by explicit
configuration, or because there are no routing-only domains), or if the
search domain '.' is configured, wait for link-specific DNS to be
configured. Otherwise, global DNS servers may be considered.
2025-01-28 08:49:49 -05:00
Nick Rosbrook 54401c6fdf resolved: add SubscribeDNSConfiguration to varlink API
Add a new method to io.systemd.Resolve.Monitor that allows subscribing
to changes in the systemd-resolved DNS configuration. The new method
emits the full DNS configuration (one entry for global configuration,
and one entry for each interface), any time the configuration is
updated.
2025-01-27 19:26:31 -05:00
Nick Rosbrook 2aa1a265bc udev: add input/by-{id,path} symlinks for hidraw devices
Take some of the same rule structure from 60-persistent-input.rules, and
apply it to hidraw devices in 60-persistent-hidraw.rules.

Since one of the motivations for this is being able to easily reference
FIDO tokens, add a special case when ID_FIDO_TOKEN==1, and add 'fido'
to the symlink.
2025-01-27 18:57:13 +00:00
Nick Rosbrook f63acba4ad resolved: add link_get_default_route helper
The dbus property getter for DefaultRoute does not simply check
link->default_route. Instead, if l->default_route is not explicitly
configured, it checks dns_scope_is_default_route(l->unicast_scope).

Add a link_get_default_route() helper with this logic so that it can be
used for consistency.
2025-01-27 09:32:24 -05:00
Nick Rosbrook b9335a329d resolved: add a helper to check if DNS server is accessible
We check this by opening a UDP socket and attempting to connect. We do
not send any traffic on it, but this will tell us if there are routes to
the DNS server.

This will be used in a later commit.
2025-01-27 09:32:24 -05:00
Nick Rosbrook 428c99997d varlink-util: add varlink_many_notify
We already have varlink_many_notifyb. Just re-factor it slightly and add
a plain varlink_many_notify.
2025-01-27 09:32:24 -05:00
Nick Rosbrook cf22b5c5ad resolve: rename varlink_subscription -> varlink_query_results_subscription
No functional change. Make it more clear that these varlink connections
are subscribed to query results. This prepares for adding SubscribeDNS
to the varlink API.
2025-01-27 09:32:24 -05:00
Nick Rosbrook 16f99f5be9 udev: add systemd tag to devices tagged with security-device
This ensures that device units are created for these, which is
convenient for other units that want to declare dependencies on
such devices.
2025-01-22 21:43:44 +01:00
Nick Rosbrook 96c4d9d94d test: skip TEST-69-SHUTDOWN on ubuntu too 2024-12-17 19:04:04 +00:00
Nick Rosbrook 59e5108fb4 test: set nsec3-salt-length=8 in knot.conf
TEST-75-RESOLVED fails on Ubuntu autopkgtest due to this warning from
knot:

 notice: config, policy 'auto_rollover_nsec3' depends on default nsec3-salt-length=8, since version 3.5 the default becomes 0

Explicitly set nsec3-salt-length=8 to silence.
2024-12-11 12:55:37 +00:00
Nick Rosbrook ebc8b9e45b varlinkctl: set SD_JSON_FORMAT_FLUSH when --more is set
This makes it possible to process continuous replies with jq etc.
2024-10-22 12:09:55 -04:00
Nick Rosbrook c89b578f33 varlinkctl: do not clobber format flags in verb_call
Currently, when SD_JSON_FORMAT_OFF is set in verb_call, the json format
flags are set to SD_JSON_FORMAT_PRETTY_AUTO|SD_JSON_FORMAT_COLOR_AUTO,
rather than or'ing those flags in. This means that other flags that may
have been set, e.g. SD_JSON_FORMAT_SEQ when --more is set, will be
clobbered.

Fix this by masking SD_JSON_FORMAT_OFF out, and then or'ing the new
flags in.
2024-10-22 12:09:41 -04:00