Commit Graph

6441 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
04d2a86e66 manager: add needs-stop/needs-start (#40709)
Intend to use these in the deb packaging scriptlets

Fixes: #19755
2026-02-24 00:36:06 +01:00
Lennart Poettering
ab83c7489d sysupdated: Split Update() into Acquire() and Install() D-Bus methods (#40628)
These mirror the `sysupdate acquire` and `sysupdate install` verbs,
which are themselves a split of `sysupdate update` into downloading and
installing stages.

I have dropped the existing `Update()` method in the final commit, as
per the suggestion on
https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/2004#note_2145880.
If the D-Bus API for `sysupdated` is considered stable now, though, I
can drop that commit.

CC @AdrianVovk

Fixes https://github.com/systemd/systemd/issues/34814
2026-02-23 22:08:37 +01:00
Philip Withnall
7537717aed test: Expand sysupdate test to test updatectl update
This further expands the sysupdate test to run the suite a fourth time,
testing that `updatectl update` behaves the same as `sysupdate update`
and `sysupdate acquire; sysupdate update --offline`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-23 16:35:15 +00:00
Philip Withnall
b0ca987cd9 updatectl: Expose partial/pending updates in the updatectl list output
And expand the tests to catch if any more JSON fields are added to the
sysupdated output in future without being added to `updatectl`’s parser.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Helps: https://github.com/systemd/systemd/issues/34814
2026-02-23 16:35:10 +00:00
Luca Boccassi
f3a34fcc3a manager: add 'needs-stop/needs-start' markers
Useful for packaging scripts, when units are removed.
When multiple markers are assigned without +/-, the last one wins.
When using +/-, the job merging logic is followed to the extent possible.
2026-02-23 13:05:23 +00:00
Lennart Poettering
3a7486c9fc journalctl: add new varlink GetEntries endpoint (#40650)
journalctl: add new varlink read service to get entries

We already have some varlink support for the journal to perform
some actions like `Rotate`. It would be nice to be able to query
the journal via varlink too so this commit adds a new varlinkctl
based journal service that exposes a single GetEntries() call
to retrieve journal entries. Basic filtering is supported and
we can expand the API as needed.

This is a separate `io.systemd.JournalControl` [1] service from the
existing `io.systemd.Journald` to decouple read and write (thanks
to Lennart for suggesting this).

This also extracts some shared helper so that we do not duplicate
code when generating the json or when adding the filters.

[1] The name mirrors the bootctl->io.systemd.BootControl naming.
2026-02-22 15:14:09 +01:00
Luca Boccassi
05f5156ad1 core: validate ref_uid before checking in AttachProcesses method
ref_uid is initialized to invalid, and is only set in some
circumstances. The AttachProcesses will attempt to check it,
and assert that it is valid. Check beforehand.

Reported as YWH-PGM9780-89

Follow-up for 59857b672c
2026-02-22 15:13:02 +01:00
Michael Vogt
a109189fab journalctl: add new varlink read service to get entries
We already have some varlink support for the journal to perform
some actions like `Rotate`. It would be nice to be able to query
the journal via varlink too so this commit adds a new varlinkctl
based journal service that exposes a single GetEntries() call
to retrieve journal entries. Basic filtering is supported and
we can expand the API as needed.

This is a separate `io.systemd.JournalControl` [1] service from the
existing `io.systemd.Journald` to decouple read and write (thanks
to Lennart for suggesting this).

This also extracts some shared helper so that we do not duplicate
code when generating the json or when adding the filters.

[1] The name mirrors the bootctl->io.systemd.BootControl naming.
2026-02-21 13:02:38 +01:00
Lennart Poettering
9277393d7b report: install systemd-report binary to /usr/lib/systemd/ for now
The tool should not be considered stable, and those things we usually
place in /usr/lib/systemd, and not in $PATH.

We can move that to $PATH once we are confident it's gonna stay the way
it is.
2026-02-20 08:25:12 +01:00
Lennart Poettering
f3aff0c20a ci: add proper CI test for systemd-report 2026-02-20 08:25:12 +01:00
Lennart Poettering
5046a12fbc report: switch to "verbs" command line interface, and add 'describe-metrics'
Let's prepare for a future where the "systemd-report" tool can do more
than enumerate metrics: let's introduce our usual "verbs" style
interface.

Let's also add a second command right-away: "describe-metrics" shows the
description of the metrics.
2026-02-20 08:23:11 +01:00
Lennart Poettering
c86a72af04 ci: drop 'Ex' suffix from transient props
The "Ex" is mostly internal, and our parsers will append it
automatically when needed
2026-02-19 15:08:20 +01:00
Lennart Poettering
e31ee582fc ci: add test for OCI downloading 2026-02-19 15:08:20 +01:00
Luca Boccassi
9204838724 test: skip dnf signature checks in TEST-88-UPGRADE
Fixes failure on Rawhide:

TEST-88-UPGRADE.sh[512]: Transaction failed: Rpm transaction failed.
TEST-88-UPGRADE.sh[512]: Warning: skipped OpenPGP checks for 15 packages from repository: @commandline
TEST-88-UPGRADE.sh[512]:   - package systemd-shared-260~devel-20260218150812.fc45.x86_64 does not verify: no signature
2026-02-18 21:41:49 +00:00
Luca Boccassi
af9a5121a1 test: cover both verity verification mechanisms in TEST-70-TPM2-nvpcr
Follow-up for 521a523ce0
2026-02-18 16:20:33 +00:00
Luca Boccassi
b9813d6c95 test: move check for verity kernel keyring support to util.sh 2026-02-18 16:11:34 +00:00
Luca Boccassi
7112e4755e test: do not fail TEST-86-MULTI-PROFILE-UKI if full TPM2 support not available
On a mkosi run on GHA:

[    9.547863] TEST-86-MULTI-PROFILE-UKI.sh[458]: + /usr/lib/systemd/systemd-measure --current
[    9.552790] TEST-86-MULTI-PROFILE-UKI.sh[463]: Measuring boot phases: enter-initrd, enter-initrd:leave-initrd, enter-initrd:leave-initrd:sysinit, enter-initrd:leave-initrd:sysinit:ready
[    9.553086] TEST-86-MULTI-PROFILE-UKI.sh[463]: Found container virtualization none.
[    9.553308] TEST-86-MULTI-PROFILE-UKI.sh[463]: Reading EFI variable /sys/firmware/efi/efivars/LoaderTpm2ActivePcrBanks-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f.
[    9.553486] TEST-86-MULTI-PROFILE-UKI.sh[463]: Loaded shared library 'libtss2-esys.so.0' via dlopen().
[    9.553676] TEST-86-MULTI-PROFILE-UKI.sh[463]: Loaded shared library 'libtss2-rc.so.0' via dlopen().
[    9.553867] TEST-86-MULTI-PROFILE-UKI.sh[463]: Loaded shared library 'libtss2-mu.so.0' via dlopen().
[    9.554050] TEST-86-MULTI-PROFILE-UKI.sh[463]: Sorry, system lacks full TPM2 support.
[FAILED] Failed to start TEST-86-MULTI-PROFILE-UKI.service - TEST-86-MULTI-PROFILE-UKI.
2026-02-18 15:39:13 +00:00
Zbigniew Jędrzejewski-Szmek
ba67af7efb Bump minimum version of python to 3.9 (#40711) 2026-02-18 13:33:29 +01:00
Jörg Behrmann
761f1ef2f3 Bump minimum version of python to 3.9
This was announced in fd8c620751 and every
still-supported distributo release provides at least 3.9, as tracked by #38608.
2026-02-18 18:47:15 +09:00
Yaping Li
23c639be6d metrics: add networkd related metrics 2026-02-18 17:58:33 +09:00
Yu Watanabe
6109cf8b61 meson,test: sort unit files 2026-02-18 17:57:17 +09:00
Lennart Poettering
521a523ce0 ci: add simple test that ensures the verity nvpcr measurements are made 2026-02-17 22:00:14 +01:00
Zbigniew Jędrzejewski-Szmek
f9dbf6fd5a core: add SetProperties varlink method (#40356)
Start with Markers as a property, more can be added in the future as
needed
2026-02-17 10:57:09 +01:00
r-vdp
e271497d97 dns-delegates: add support for setting a firewall mark
This makes it possible to have DNS requests for certain domains routed
differently than normal requests, which is for instance useful when
using policy routing to route traffic over a VPN but DNS requests for
the VPN endpoint itself, should be routed differently.

It doesn't make much sense to configure a firewall mark at the level of
a network interface, but at the level of a DNS delegate it can be very
useful.
2026-02-16 11:09:48 +01:00
Daan De Meyer
4e77671be7 mkosi: Remove some packages from the image
Let's slim down the image size a bit. None of the removed packages
should be required.
2026-02-15 12:51:00 +00:00
Yu Watanabe
a1c8e5e338 Allow non-system users/groups in networkd and udevd again (#40612) 2026-02-14 05:41:01 +09:00
Luca Boccassi
0e1c4de235 core: add SetProperties varlink method
Initial support for 'Markers' only
2026-02-13 19:16:13 +00:00
Daan De Meyer
71de0a22ff core/service: support credentials refreshing on reload (#40093)
Closes https://github.com/systemd/systemd/issues/21099
Closes https://github.com/systemd/systemd/issues/35227
2026-02-13 10:21:44 +01:00
Yu Watanabe
559dabbbde Two portabled fixes (#40664) 2026-02-13 16:53:29 +09:00
Daan De Meyer
48f0f1fd81 TEST-72-SYSUPDATE: Use some very long partition names
To catch issues like https://github.com/systemd/systemd/issues/40658.
The commit that fixes that issue can make the name even longer to ensure
we don't regress again in this regard.
2026-02-13 15:46:52 +09:00
Luca Boccassi
03f6a8b9d9 portable: do not apply extension image policy if not attaching image
Image policy is only for images, so skip for other types

Follow-up for d059615492
2026-02-12 23:20:47 +00:00
Luca Boccassi
d07aa23c87 portable: fix --force flag combination with directory extension
The check for image type uses the wrong variable, so it's applied
when it shouldn't.

Follow-up for 06768b90a3
2026-02-12 23:20:47 +00:00
DaanDeMeyer
ba37ed9634 dissect: Introduce --copy-ownership= to configure chown behavior
Currently, if we're copying a file, we won't copy the owner UID/GID
from the source. If we're copying a directory, we will copy the owner
UID/GID from the source. Let's give users a bit more control over this
behavior by introducing --copy-ownership= which will default to the
current behavior but allows users to explicitly enable/disable copying
of ownership.
2026-02-12 09:45:13 +01:00
Zbigniew Jędrzejewski-Szmek
5c05a339c6 udev-rules: downgrade error about non-system user/group in OWNER=/GROUP=
This reverts (in sprit) commit f5cdf9515a,
"udev-rules: ignore non-system user/group in OWNER=/GROUP=".

The original change was done to clean up a situation where we added a
new group, but the group could already have been used for some other
purposes, and now the some unexpected entity would own the device.
Unfortunately, this check doesn't really address the issue, since the
existing account might as well be a system account, which might be
equally bad. In addition, this change is a big compatiblity break,
causing existing rules to stop working. Since quite a lot of systems
have local configuration to assign devices to users for various
purposes, this is very noticable to users. In a way, the original change
to add a new group was the compat break, and follow-up patch to cahnge
the rule parsing evolved a small compat break into a much bigger one.
There is merit to the change though, since device nodes shouldn't be
owned by users and groups and different mechanisms should be used
instead. To avoid breaking users systems, and since the original goal
cannot be achieved by this patch, let's downgrade this to a warning
to guide users towards different solutions.
2026-02-11 11:24:37 +01:00
Mike Yuan
7d551b00e3 TEST-54-CREDS: add test cases for credential refreshing 2026-02-10 23:21:11 +01:00
Philip Withnall
6015c6cd6f test: Expand sysupdate test to cover split acquire/install updates
This essentially means the sysupdate tests are now run twice: once with
a monolithic update (`sysupdate update`) and once with a split update
(`sysupdate acquire; sysupdate install`).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2026-02-09 12:05:20 +00:00
Lennart Poettering
a1d3fd1202 test: add superficial test for list-registry 2026-02-09 10:54:18 +01:00
Daan De Meyer
7d4ea41bd1 bootctl parts of installer PR (#40447)
This contains the "bootctl install" related work from the #38764 split
out, but also includes the preparatory work already split out into
#40446.

I'll rebase this PR once the prep work is merged.

This has a simple CI test already, and has docs
2026-02-09 09:46:39 +01:00
Mike Gilbert
a304f6c9db meson: use printf instead of echo
The echo builtin provided by some shells (mksh) will interpret \x2d as
an escape sequence. This causes meson to fail:

```
test/fuzz/meson.build:93:52: ERROR: File fuzz-unit-file/dm-back-slash.swap does not exist.
```

Bug: https://bugs.gentoo.org/969789
2026-02-09 09:36:26 +01:00
Matteo Croce
c1bf450fa0 oomd: implement a prekill varlink event
When a cgroup is selected for termination, send varlink messages
to hooks registered in `/run/systemd/oomd.prekill-hooks/`.
oomd waits up to `PreKillHookTimeoutSec=` seconds for response
before proceeding with the kill.
2026-02-09 02:05:57 +01:00
Lennart Poettering
1dad3b6762 bootctl: add test case for bootctl install via varlink 2026-02-06 23:17:02 +01:00
Lennart Poettering
ab89fad427 test: bump disk sizes for some test cases
In my testing I switched building my locally run CI integration tests to
ArchLinux and realized that for that the default sizes don't work
anymore, the images are larger than the space allocated. Let's bump the
size by 50% for the relevant disk images.
2026-02-06 18:19:33 +01:00
Lennart Poettering
dd2676c1ab tests: don't use "dd" to allocate empty files
Let's use truncate -s … to create empty files (if they can be sparse)

Let's use fallocate -l … to create empty non-sparse files.

This should reduce the disk footprint of our tests a bit, given that in
most cases we won't use the allocate disk space in full, not even
remotely.
2026-02-06 18:19:33 +01:00
Cathy Hu
d3761f1509 journal-remote test: add -Z for mkdir in general
Otherwise on SELinux enabled systems with the "targeted" policy
the type is not set correctly when run via unconfined user and
the test fails.
2026-02-06 15:15:10 +09:00
Lennart Poettering
823054d079 pcrextend: fix varlink API to match what we actually take
(Change test case slightly, to ensure we don't regress on this)
2026-02-06 15:08:51 +09:00
Zbigniew Jędrzejewski-Szmek
e047394797 [metrics] Introduce metrics API (#39202)
See the [design
doc](https://github.com/systemd/systemd/issues/38023#issue-3192567450)
by @ikruglov

This PR introduces the metrics API framework, adds some basic system
wide/per unit/service metrics, and a basic CLI. The PR is broken into
two commits as described below.

### Deviations from the original design
- Introduced top level field "object" for ease of filtering. Instead of
having `fields: { unit: "foo", unit_type: "service" }`, we now have
`object: foo.service` as the top level field.


### First commit

The first commit includes:
- Metrics API definitions
- Code to set up the varlink server
- The describe method which shows all the metrics families
- The list method which lists all the metrics
- Type definitions related to MetricFamily
- Common code to build json objects

### Second commit
The second commit adds some basic metrics, a basic CLI (systemd-report)
which
lists the metrics, and integration tests.

**System wide metrics:**
- units_by_type_total
- units_by_state_total

**Two per unit metrics:**
- unit_active_state
- unit_load_state

**A service state metric:**
- nrestarts

### Sample outputs

**units_by_type_total**:

```
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 52,
        "fields" : {
                "type" : "target"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 82,
        "fields" : {
                "type" : "device"
        }
}
{
        "name" : "io.systemd.Manager.units_by_type_total",
        "value" : 2,
        "fields" : {
                "type" : "automount"
        }
}
```
**units_by_state_total**:
```
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 216,
        "fields" : {
                "state" : "active"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 0,
        "fields" : {
                "state" : "reloading"
        }
}
{
        "name" : "io.systemd.Manager.units_by_state_total",
        "value" : 120,
        "fields" : {
                "state" : "inactive"
        }
}
```
**unit_active_state**:
```
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "multi-user.target",
        "value" : "active"
}
{
        "name" : "io.systemd.Manager.unit_active_state",
        "object" : "systemd-sysusers.service",
        "value" : "inactive"
}
```
**unit_load_state**:
```
{
        "name" : "io.systemd.Manager.unit_load_state",
        "object" : "multi-user.target",
        "value" : "loaded"
}

```
**nrestarts**:
```
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user@0.service",
        "value" : 0
}
{
        "name" : "io.systemd.Manager.nrestarts",
        "object" : "user-runtime-dir@0.service",
        "value" : 0
}
```
2026-02-04 16:31:55 +01:00
Kai Lueke
23115eeaf1 sysext: Skip refresh if no changes are found
When the extensions for the final system are already set up from the
initrd we should avoid disrupting the boot process with the remount
(which currently isn't atomic) and the daemon reload for
systemd-confext and systemd-sysext. Similarly, when sysupdate ran and
updated extensions it's best to avoid the remount and daemon reload if
no changes are found.
To do this, encode the current extension state in more detail than
before where only the names of the extensions where encoded in the
overlay mount. This can also be used to provide more details about the
extension origin in "systemd-sysext status (--json=)". During the
refresh add a check whether the old state matches the new state and in
this case skip the refresh unless the user provides a flag to always
refresh. Besides the extension name and the resolved path the best
method for identification is the verity hash but that is not available
for plain image files or directories. Therefore, also include data to
check for file/directory replacements. The creation/modification times
are not always real on reproducible images or extracted archive content.
The file handle together with the unique mount ID is the next best
identifier we can use when we have no verity hash. Fall back to an inode
when we get no handle. With the creation/modification time and the path
this should be good enough. Using a unique mount ID is important (with
a fallback to the regular non-unique mount ID) instead of st_dev because
st_dev gets reused too easily, e.g., by a loop device mount and the
mount ID helps to catch this. For the mount ID to be valid it has to be
resolved before we enter the new mount namespace. Thus, it gets provided
by the image dissect logic and handed over to the sysext subprocess
which runs in a new mount namespace.
Luckily, we can rule out online modification of directories or image
files because this is anyway not well supported with overlay mounts, so
we don't do a file checksum nor do we recurse into a directory to look
for the most recently touched files.  But, as said, with the
always-refresh flag one can force a reload.
2026-02-04 00:05:24 +01:00
Yu Watanabe
eb5b797d7c journal: check validity of PID field in syslog/kmsg earlier
Then, let's make syslog_parse_identifier() returns PID as pid_t, rather
than the string.

This also makes the function refuse ridiculously long identifier.

Fixes #40456.
Fixes oss-fuzz#477990732 (https://issues.oss-fuzz.com/issues/477990732).
2026-02-03 21:55:49 +09:00
Yu Watanabe
0dcbb30f49 fuzz: assume all reproducers as binary
Even if parsers expect text data, reproducers may not be suitable
for being handled as a text file.
2026-02-03 21:43:17 +09:00
Yaping Li
c498f3790f [metrics] Add a basic CLI
systemd-report will list all the metrics.
2026-02-02 08:03:56 -08:00