7302 Commits
Author SHA1 Message Date
Daan De Meyer 1773505f7e update-helper: connect to user managers through their private socket
The helper reaches a user manager with the uid@ machine transport. That
transport runs systemd-run, which opens a PAM login session for the user.
In that session, systemd-stdio-bridge connects to the user's D-Bus broker.
rpm runs the helper once per package scriptlet. A large transaction therefore
opens many login sessions for every logged-in user. The operations also fail
whenever the user's D-Bus broker is not running.

The user manager accepts connections from root on its private socket, and
systemctl --user uses the same socket. Connect to
/run/user/UID/systemd/private directly with bus_connect_user_systemd_by_uid().
The user owns /run/user/UID. The function therefore refuses a socket that the
user does not own or that a process of another user listens on. Otherwise a
user could point the helper at the private socket of the system manager.
2026-10-10 22:53:03 +02:00
Lennart Poettering 8c64c6ad90 test: cover logind metrics 2026-10-10 10:40:03 +02:00
Lennart Poettering 202a1ea32d test: cover journald message counter metrics 2026-10-10 10:40:03 +02:00
Lennart Poettering 5ad26e0080 tests: some minor CI fixes (#44097)
Some fixes for flakiness seen on CI
2026-10-09 18:17:25 +02:00
Lennart Poettering e42ad4c3b6 test: silence SC2329 for trap-invoked cleanup() in TEST-17-UDEV.sanity-check
cleanup() is only called via 'trap cleanup EXIT', which newer shellcheck
versions report as SC2329 rather than SC2317. Disable both, like the other
test scripts do.
2026-10-09 09:41:22 +02:00
Lennart Poettering 0c2366a159 report: Add network statistics metrics generator
One of the fundamental counters we need to cover in metrics are
packet/byte counters on network interfaces. Let's add this.

We do this separately from networkd, to not unnecessarily affect
networkd operations.
2026-10-09 07:55:32 +02:00
Lennart Poettering 3d367b352b report: add nonce concept
While systemd-report is conceptually designed to provide freshness
guarantees without nonces (for example via TPM clock, TSA or generation
counters), it sometimes is useful to provide a nonce, when talking
directly and synchronously to a node, instead of asynchronously.

Hence, let's just extend the Generate Varlink calls with a nonce
argument.
2026-10-09 07:11:34 +02:00
Lennart Poettering 743754e083 report: expose file system birth time of /var/ as DeploymentTimestampNSec
The birth time of the root inode of the file system backing /var/ is a
good approximation of when the system was deployed, i.e. when its
persistent file system was created. If /var/ is not a mount point of its
own, use the root file system instead.

The metric is skipped if the file system does not record birth times.
2026-10-08 21:23:51 +02:00
Lennart Poettering 076f689180 report: expose CLOCK_MONOTONIC/CLOCK_BOOTTIME as metrics, as a way to determine system uptime
And while we are at it, let's also expose CLOCK_REALTIME, all in nsec
accuracy.

(The realtime clock is also included in the report header, but in
calendar format with second granularity.)
2026-10-08 20:55:16 +02:00
Lennart Poettering 4da00a0432 report: suppress some metrics of hw owned by the host on containers 2026-10-08 17:30:21 +02:00
Jonghyun An a83a0d2fc4 systemctl: quote command arguments in status output
The Process lines in systemctl status join argv with spaces, making
multi-word arguments ambiguous and empty arguments invisible.

Use quote_command_line() with SHELL_ESCAPE_EMPTY to retain argument
boundaries. Leave the formatted string NULL for an empty argv vector so
that strna() prints n/a. Cover whitespace, empty arguments and literal
dollar signs in TEST-26-SYSTEMCTL.

Fixes #43938.
2026-10-08 16:33:04 +02:00
Zbigniew Jędrzejewski-Szmek 14ad01ddf3 Configuration options for experimental programs (#44056) 2026-10-08 12:39:58 +02:00
Chris Coulson f1e73ac21a report: Add PCR values to the TPM2 report signature
The "pcr" component currently only contains the attested PCR digest.
Whilst the PCR values can be reconstructed from the accompanying log,
the "nvpcr" components already contain NvPCR values. This adds the
attested PCR values alongside the TPM quote for consistency.
2026-10-08 11:39:17 +02:00
Armaan Sandhu c5ca4cd0f3 systemctl: query each unit only once in list-dependencies
In tree mode, list-dependencies prints a unit once for every path that
leads to it. The "units" strv is only a stack of the current path, used
for cycle detection, so every time a unit shows up again its
dependencies (a GetAll() call) and its active state (a Get() call) were
fetched from the manager again. With --all the number of paths grows far
faster than the number of units: on a stock Fedora desktop,
"list-dependencies --all sockets.target" prints 30152 lines for roughly
260 distinct units, and spends about 20 seconds doing synchronous D-Bus
round trips for units it had already asked about.

unit_get_dependencies() now also reads ActiveState, which comes with the
same GetAll() reply, and returns both in a UnitDependencyInfo.
list-dependencies keeps these in a single hashmap keyed by unit name and
takes every unit's state from there, so each distinct unit costs exactly
one D-Bus call per invocation. The dependency list is sorted once when it
is cached. With --all this also halves the number of D-Bus calls compared
to querying dependencies and state separately (311 -> 157 messages for
sockets.target).

While at it, append_unit_dependencies() no longer passes an
uninitialized pointer to strv_extend_strv_consume() when
unit_get_dependencies() fails; it now skips the unit instead.

The output is unchanged; the only difference is that the state of a unit
that appears several times now comes from a single snapshot instead of
being re-read on every occurrence.

  list-dependencies --all sockets.target    20.45s -> 0.12s
  list-dependencies --all basic.target      25.03s -> 0.20s

--plain, --type= and --state= already visit each unit only once and are
unaffected.
2026-10-08 10:21:21 +02:00
Chris Down aa97813bb1 update-helper: Various improvements and fixes (#44055) 2026-10-08 00:00:14 +02:00
Chris Down 7375b19240 core: Don't abort when canceling a job through the private bus (#44045)
Messages on the private bus have no sender. As it is now, when a job is
canceled through it, as "systemctl cancel" does when run as root, we
pass a NULL name to sd_bus_track_contains(), which fails an
assert_return(). In developer builds, that makes PID 1 abort. Otherwise
it's only logged at debug level, and we consult polkit, as we should.

Let's only check whether the sender owns the job if there is a sender.
Jobs enqueued through the private bus aren't tracked anyway.
2026-10-07 23:58:42 +02:00
Chris Down 09d08b8799 test: Cover BPF link replacement when re-realising cgroups 2026-10-07 21:48:11 +02:00
Chris Down 32bf569541 TEST-03-JOBS: Test cancelling a job through private bus 2026-10-07 21:44:15 +02:00
Daan De Meyer dce960bc49 test: add an integration test for systemd-update-helper
The only test of systemd-update-helper is part of the rpm upgrade test,
which only runs on rpm-based distributions and only covers removing units
from a frozen user manager. Test the commands on the system manager and on
the user manager of a lingering user, the per-user disable on removal,
template units, a symlink in place of the private socket of a user manager,
and a frozen user manager.
2026-10-07 20:59:29 +02:00
Yu Watanabe bb0d825dda core/device: rework Device.found flags handling (#43930)
Fixes #43767.
2026-10-07 23:22:52 +09:00
Zbigniew Jędrzejewski-Szmek e008bd7781 meson: add config switch for systemd-report
This prog is still labelled as experimental and we didn't
have a way to disable its build. With the addition of this option,
all experimental components can be disabled.
2026-10-07 15:49:45 +02:00
Zbigniew Jędrzejewski-Szmek b9d52d9ded meson: add config switch for systemd-measure
This prog is still labelled as experimental and we didn't
have a way to disable its build.
2026-10-07 10:42:54 +02:00
Luca Boccassi 556eaafd1d portable: Fail attach/reatach if the profile doesn't exist (#43990)
This PR just gives an error if the profile used to attach a portable
service doesn't exist.

The work is basically in "portable: fail attach/reattach if the profile
does not exist"
A small fix found along the way is in "portable: log the right error
when the profile lookup fails"

I put below the description of "portable: fail attach/reattach if the
profile does not exist"

---

Before this commit, if you attach a portable service using a profile
that doesn't exist, it just doesn't add the profile dropin and no
warning nor anything is shown:

	$ portablectl attach -p nonexistent xxx
	  (Matching unit files with prefix 'xxx'.)
	  Created directory /etc/systemd/system.attached.
	  Created directory /etc/systemd/system.attached/xxx-capsule.service.d.
Written
/etc/systemd/system.attached/xxx-capsule.service.d/20-portable.conf.
	  Copied /etc/systemd/system.attached/xxx-capsule.service.
	  Created symlink /etc/portables/xxx.raw → /var/lib/portables/xxx.raw.

	$ ls /etc/systemd/system.attached/xxx-capsule.service.d/
	  20-portable.conf

The 10-profile.conf is not added.

If no profile is attached, the /run bind mount is not added and then lot
of things inside fail in ways that don't make sense.

This patch just makes portable_attach() and reattach check the profile
exists. If it doesn't exist, it shows this error now:

	# portablectl -p doesntexists reattach xxx
	(Matching unit files with prefix 'xxx'.)
ReattachImage failed: Profile 'doesntexists' does not exist, refusing.
(Available profiles are: default, nonetwork, strict, trusted)

In reattach we do it early, before detach, so we don't detach and then
fail to attach it and leave the service detached.

Please note that we don't change install_profile_dropin(), as that skips
non-existing profiles because that is done at the unit type level and
it's okay if it doesn't exist for some unit types. For example,
/usr/lib/systemd/portable/profile/trusted/ ships a service.conf, but not
timer.conf, socket.conf, etc.
2026-10-06 22:24:21 +02:00
Daan De Meyer 4fdede3d2a rpm: Rewrite systemd-update-helper in C (#39415) 2026-10-06 10:37:42 +02:00
Daan De Meyer 5546bb38fa vmspawn: put the ephemeral overlay next to the image
vmspawn creates the ephemeral overlay of an --image= in the runtime directory,
which is usually on tmpfs, and falls back to a memfd. The guest's writes
therefore use up host memory. Create the overlay next to the image after
following symlinks. nspawn puts its ephemeral copy of an image there too, and
vmspawn puts the snapshot for --directory= next to the directory.

If the image is a block device, use the directory for large temporary files
instead, because /dev/ is a devtmpfs. Do the same if the image is a deleted
file or a memfd, because a deleted file or a memfd has no directory. Also do
the same if the overlay cannot be created next to the image, for example
because the directory is read-only.

Disable copy-on-write on the overlay, because small random writes fragment a
copy-on-write file on btrfs.
2026-10-06 10:17:16 +02:00
Yu Watanabe 68b57ad2d9 Make networkctl a multicall binary (#43795) 2026-10-06 05:55:20 +09:00
Yu Watanabe c84aeed2b7 TEST-17-UDEV: wait for queued events to be processed before calling next udevadm lock
Hopefully fixes the following race:
```
TEST-17-UDEV.sh[11202]: + for i in /dev/block/*
TEST-17-UDEV.sh[11202]: + udevadm lock --device /dev/block/252:3 --print
TEST-17-UDEV.sh[11778]: /dev/vda
TEST-17-UDEV.sh[11202]: + udevadm lock --device /dev/block/252:3 true
TEST-17-UDEV.sh[11780]: Device '/dev/vda' is currently locked, waiting…
TEST-17-UDEV.sh[11782]: + udevadm lock --device /dev/block/252:3 false
TEST-17-UDEV.sh[11202]: + for i in /dev/block/*
TEST-17-UDEV.sh[11202]: + udevadm lock --device /dev/block/259:1 --print
TEST-17-UDEV.sh[11787]: Failed to find whole block device for '/dev/block/259:1': No such file or directory
```
2026-10-06 05:33:07 +09:00
Yu Watanabe 2216c70740 TEST-17-UDEV: add tests for device unit state transitions with devlinks
Add an integration test that exercises .device unit state transitions for
loopback block device partitions and their udev devlinks (SYMLINK+=),
together with services bound to them via BindsTo=.

The following cases are covered:
- basic setup with daemon-reload/reexec (testcase_loopdev_basic),
- devlink updates on change events (testcase_loopdev_change_devlink),
- devlink priority changes reassigning shared devlinks
  (testcase_loopdev_change_devlink_priority),
- SYSTEMD_READY toggling (testcase_loopdev_systemd_ready),
- ID_PROCESSING handling during daemon-reload/reexec
  (testcase_loopdev_id_processing),
- switch-root emulation (testcase_loopdev_switching_root),
- device removal during switching-root
  (testcase_loopdev_remove_on_switching_root).
2026-10-06 05:33:07 +09:00
Yu Watanabe 1ac7d20002 TEST-17-UDEV: drop redundant test cases
All test cases are covered by TEST-17-UDEV.device-unit-state-transition-netif.sh
added in the previous commit.
2026-10-06 05:33:07 +09:00
Yu Watanabe e54d1e011b TEST-17-UDEV: add tests for device unit state transitions with aliases
Add an integration test that exercises .device unit state transitions
for a network interface and its SYSTEMD_ALIAS device units, together
with services bound to them via BindsTo=.

The following cases are covered:
- basic setup with daemon-reload/reexec (testcase_netif_basic),
- alias updates on change events (testcase_netif_change_alias),
- SYSTEMD_READY toggling (testcase_netif_systemd_ready),
- ID_PROCESSING handling during daemon-reload/reexec
  (testcase_netif_id_processing),
- switch-root emulation (testcase_netif_switching_root),
- device removal during switching-root
  (testcase_netif_remove_on_switching_root),
- interface renaming (testcase_netif_rename_*).

This includes reproducers for issues #35329 and #43767.
2026-10-06 05:33:07 +09:00
Yu Watanabe 04c4fe7930 test: introduce several helper functions 2026-10-06 05:33:07 +09:00
Yu Watanabe 4ef7744c2e test: show name of failed test case 2026-10-06 05:33:07 +09:00
Daan De Meyer b6a28a2604 test: Beef up TEST-88-UPGRADE a little
- Only download distro systemd packages in mkosi.prepare, set up the
devel sytemd packages in mkosi.postinst so that they're always up to
date.
- Use systemd-analyze for version comparisons
- Add test to make sure units are stopped on downgrade
- Add test to make sure removing a package with a frozen user session
doesn't blow up
2026-10-05 19:36:16 +02:00
Daan De Meyer 74800e4d52 rpm: Rewrite systemd-update-helper in C
Let's rewrite the script in C, which gives us access to
libsystemd-shared for implementing future features.

We immediately make use of libsystemd-shared to add a new --stdin
option, allowing the script to read units to operate on as unit file
paths from stdin. This allows using the script with various hook/trigger
features provided by package managers such as pacman and rpm.

As a bonus, the amount of forks is reduced by not shelling out to
systemctl multiple times which could matter for a script that's
executed quite a few times during every dnf system upgrade.
2026-10-05 19:36:16 +02:00
Paul Meyer 2fb82c0d48 test: wire subtest results via TAP to meson test output (#43949)
We had the concept of subtests in our integration test suit for some
time, but it wasn't wired to meson test, which only understood the top
level test cases. With this change, we use the TAP protocol to report
subtest results to meson so meson gets understanding of it and subtest
results become part of the native meson output.
2026-10-05 17:46:04 +02:00
Paul Meyer ac52e61158 test: verify snp attestation report (#43940) 2026-10-05 17:32:03 +02:00
Rodrigo Campos 430f8962cf test: cover attaching with a profile that does not exist
Both attach and reattach must fail, and the latter must not detach the
image first.
2026-10-05 17:14:20 +02:00
Paul Meyer 3e18b29cbe test: report integration test subtests via TAP
Switch the integration tests to meson's TAP protocol, fed by the
wrapper's --tap output. Subtest results and skips now show up in meson's
own reporting, e.g. "OK ... 5 subtests passed", instead of being visible
only inside the test log.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 13:30:59 +02:00
Paul Meyer 04ffe27a37 test: teach the integration test wrapper to emit TAP
With --tap, report per-subtest results extracted from the forwarded
journal as a TAP stream on stdout: one point per subtest, skips as SKIP
directives, and skip gates as a skipped plan. Tests without subtest
records collapse to a single point mirroring the overall verdict, and a
failure no subtest accounts for is reported as a point of its own.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 13:30:59 +02:00
Paul Meyer 36a0a64017 test: verify snp attestation report
Sign a system report through the io.systemd.Report pipeline in the
SNP guest and export the resulting signed report to the host. The host
takes the role of a remote verifier: the tsm signature record must carry
the digest of the signed report bytes, that digest must be embedded in
the REPORT_DATA field of the enclosed SNP attestation report, and the
attestation report must verify against the AMD certificate chain with
snpguest, which is added to the Fedora test image. Certificates must be
pre-provisioned on the host in a sirectory named 'snp-certs' and bound
into the test container via $TEST_BIND_DIRS.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 13:14:36 +02:00
Paul Meyer 7471c5b02d test: bind extra host dirs into the test container
Directories listed in $TEST_BIND_DIRS are bound read-only into the
boot-mode container at /work/<basename>, so a test can consume
host-provided data that cannot be baked into the image, such as a
machine's pre-provisioned AMD certificates for coco attestation.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 13:14:36 +02:00
Paul Meyer 4a4587538d test: reserve the integration test wrapper's stdout
Route the streamed test output (the mkosi console) and coredump to
stderr. Diagnostics belong there anyway, and it frees stdout to carry
machine-readable results for meson's TAP protocol.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 11:59:40 +02:00
Paul Meyer 89107d83bb test: log machine-readable subtest results to the journal
Log one structured record per executed subtest under a fixed MESSAGE_ID,
so the integration test wrapper can extract per-subtest results from the
forwarded journal. Best-effort: without a reachable journal the records
are simply absent.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-10-05 11:59:40 +02:00
Armaan Sandhu 08be867753 report: make report-files listing and lookup agree on masked entries
The metric list is built with conf_files_list_strv(), but each metric's
value is then looked up again by walking report_files_dirs[] by hand,
and the two disagreed whenever an earlier directory had an entry that is
not a regular file:

 - conf_files_list_strv() skipped such an entry and listed the one from
   a later directory, so the metric was advertised by Describe();
 - file_metric_generate() only moved on to the next directory on
   -ENOENT, so it hit the non-regular entry, logged a warning and
   produced nothing.

The practical case is masking a vendor-supplied entry with a symlink to
/dev/null: the metric kept being described, was never listed, and every
scrape logged "Failed to open ..., skipping: File descriptor in bad
state".

Honour masks in the enumeration via CONF_FILES_FILTER_MASKED_BY_SYMLINK,
as other conf dirs do, and make the lookup skip non-regular entries the
same way the enumeration does. Document the masking in the man page and
cover both cases in TEST-74-AUX-UTILS.report.
2026-10-03 13:57:06 +02:00
Martin Pitt 9c582182e1 vmspawn: actually enable io_uring for disks
vmspawn never used `aio=io_uring` for disks, even when QEMU supports it.
Commit 1a7b6fd9dd added a blockdev probe node named `__io_uring_probe`.
QEMU rejects that name ("Invalid node-name"), as node names have to
start with a letter. The probe then reported io_uring as unsupported.

Use a valid name, following the "vmspawn-" prefix of the other node names.
Check the multi-drive test's debug log for rejected node names to catch
this and similar issues in the future.

Signed-off-by: Martin Pitt <martin@amutable.com>
2026-10-03 08:13:37 +02:00
Ivan Kruglov 0794ba0045 test: add integration tests for io.systemd.Unit.EnqueueJob 2026-10-03 00:09:19 +02:00
Daan De Meyer b231b43ff0 systemctl: honour --root= in "is-enabled --full"
We have a root argument, let's make sure we honour it
in this case.
2026-10-02 23:23:17 +02:00
Yu Watanabe 11880923dd mkosi: update mkosi and rename postmarketOS to Nura (#43887) 2026-10-03 02:23:49 +09:00
LevitatingBusinessMan (Rein Fernhout)andYu Watanabe e9090fe180 mkosi,test: rename postmarketos to nura
Recently, postmarketOS is renamed to Nura:
See https://postmarketos.org/blog/2026/09/27/nura-rename/

mkosi already renamed postmarketOS to Nura:
https://github.com/systemd/mkosi/commit/580c4d94d75ef18f2a0983626cfd80bea9c44ece

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2026-10-02 21:16:22 +09:00
Kai Lüke 3bebfc9d85 test: Cover sysext/confext ordering
The ordering matters at unit startup and when we refresh on updates.
For now, just add a test for the update refresh ordering.
2026-10-02 10:27:57 +02:00