Commit Graph

58315 Commits

Author SHA1 Message Date
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
Mike Yuan
f04023d35f vmspawn: clean up OVMF secure boot support check a bit
find_ovmf_config() would do filtering based on arg_secure_boot
already, hence the mismatch can only occur if we're using
user-specified firmware. So be explicit about this in log.
2026-02-20 21:21:01 +01:00
Mike Yuan
39a5b957e1 vmspawn: use parse_tristate_argument_with_auto() 2026-02-20 21:21:01 +01:00
Mike Yuan
577e5e9a5e parse-argument: make parse_tristate_argument() do something useful
I expressed the issue I have with parse_tristate_argument()
in #37751: it doesn't add any value to direct use of parse_tristate();
on the contrary, it doesn't support means to reset the arg to "auto"/-1 state.
The mere reason it existed is that we need a int type ret param.

Since the previous attempt to address this mess failed, let's
try to make the function more useful by making it accept "auto".
I figure this is useful on its own.

As requested in
https://github.com/systemd/systemd/pull/40652#discussion_r2831833996,
the function name is suffixed with _with_auto() to establish
that "auto" is handled internally.
2026-02-20 21:20:45 +01:00
Michael Vogt
8471eca549 machine: switch CleanPool to SD_VARLINK_REQUIRES_MORE
The CleanPool requires --more to be set and checks that in
`vl_method_clean_pool`. By switching to SD_VARLINK_REQUIRES_MORE
this will automatically be handled and is more clear to
the varlink users.

Based on the comment from Lennart in
https://github.com/systemd/systemd/pull/40650#discussion_r2832378002
and the work done by Mike in 09388a6b9e (thanks!).
2026-02-20 18:01:08 +01:00
Luca Boccassi
699007a44f repart: Report correct current disk size and error (#39813) 2026-02-20 17:00:28 +00:00
Antonio Alvarez Feijoo
16e7869cf3 mstack: parse --mkdir option
```
systemd-mstack: unrecognized option '--mkdir'
```

Follow-up for 8187cd18d6
2026-02-20 16:56:16 +01:00
Julian Sparber
f94d3180b0 repart-varlink: Consider only managed parititions for size errors
Report DiskTooSmall only if partitions managed by repart don't fit the
disk. Because if the disk is already full with forigin partitions we
would always report DiskTooSmall instead of InsufficentFreeSpace.
2026-02-20 11:36:35 +01:00
Julian Sparber
9ee029c8f6 repart-varlink: Calculate the size of foreign partitions
To decide whether the disk is to small or has insufficient free space we
need to know how much of the disk is filled with foreign partitions.
The calculated size is used in a future commit.
2026-02-20 11:23:09 +01:00
Julian Sparber
5036c9f596 repart: Sum partitions size to get current disk size instead of using total size
When working on disks the disk may have a total size bigger then the
actual allocated size, therefore sum up the current partitions to
calculate the current disk size instead of asuming that the entire disk
is currently allocated.
2026-02-20 11:19:10 +01:00
Yu Watanabe
c871afd311 Several fixlets for issues found by Coverity (#40765) 2026-02-20 19:13:37 +09:00
Lennart Poettering
b33669da2b systemd-report: show some love (#40735) 2026-02-20 10:21:31 +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
cd961ea209 report: use JSON-SEQ when outputing a series of json objects
We do this in our other tools that output a large number of JSON objects
in a potentially streamable way, hence do so here too.
2026-02-20 08:25:12 +01:00
Lennart Poettering
fc5537635d report: fix log level of connection log messages
Let's also rename the "metric_prefix" to "name", because it's actually
the servce name, and by giving it this generic name we can use it
reasonably in log messages.
2026-02-20 08:25:12 +01:00
Lennart Poettering
bbb151da78 report: add --no-legend
Like most of our other tools, add a --no-legend switch.
2026-02-20 08:25:12 +01:00
Lennart Poettering
e83cbc9372 report: implement filtering for metrics 2026-02-20 08:25:12 +01:00
Lennart Poettering
ec2cd403f4 report: tighten rules on metrics names
Let's stay close to Varlink's naming rules and insist that metrics
prefixes must be valid varlink interface names, and suffixes are valid
varlink field names.

The former rule is clear: because a metric <x>.<y> can only be provided
by a varlink service <x>, it is obvious we should validate them the
same way. Validating the suffix via varlink field rules is not that
obvious, but I think it makes sense to stay close to Varlink naming
rules if we already started out at one place.
2026-02-20 08:25:12 +01:00
Lennart Poettering
5617ebb096 report: we don't use inline in .c files, the compiler can figure this out better on its own 2026-02-20 08:25:12 +01:00
Lennart Poettering
442040e716 report: add -j shortcut
json output is going to be used very frequently, hence provide a
shortcut for it, like many our tools do it.
2026-02-20 08:25:12 +01:00
Lennart Poettering
39225c9904 report: also dump metrics in tabular output
JSON output is great, but let's show the metrics by default in a more
human readable fashion.
2026-02-20 08:25:12 +01:00
Lennart Poettering
e1f7f33713 report: add 'list-sources' verb for enumerating metrics sources 2026-02-20 08:25:12 +01:00
Lennart Poettering
0e05a03577 report: split out service enumeration logic
We want to reuse it later to list all services, hence make it generic.

(Also, allow symlinked services too)
2026-02-20 08:23:11 +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
Yu Watanabe
ecf9f81af4 mstack: coding style cleanups 2026-02-20 16:22:00 +09:00
Yu Watanabe
b78db85bca mstack: fix resource leak on failure path
This makes the mstack_load() requires 'ret', as clearing the loaded
mstack without use is meaningless. All callers already pass non-NULL for
the argument.

Follow-up for 8343032a86.
Fixes CID#1645105.
2026-02-20 16:21:48 +09:00
Lennart Poettering
5344bede1e report: adjust indentation to our usual style 2026-02-20 08:15:30 +01:00
Lennart Poettering
b01dfa2c83 report: add comment explaining that metric_startswith_prefix() does a true prefix match 2026-02-20 08:15:30 +01:00
Lennart Poettering
9841786581 metrics: show metrics 'keys' before 'values'
In a way, metrics are a key-value concept, where the key is a triplet of
metrics family name, object name, and "fields". Let's put them together
in the varlink call, and put the value last, separately from that.

Also, update docs a bit, i.e be explicit about the metrics *family* name
everyhwere.
2026-02-20 08:15:29 +01:00
Lennart Poettering
22cc1625e7 format-table: add a new JSON cell type
This formats the specified json variant as a string, and displays it in
a cell.
2026-02-20 08:15:29 +01:00
Lennart Poettering
a98fc72e29 json: add json_variant_compare() helper for comparint two json variants by order 2026-02-20 08:15:29 +01:00
Yu Watanabe
298fc56641 import: fix NULL pointer dereference
Follow-up for a9f6ba0496.
Fixes CID#1645106.
2026-02-20 16:12:36 +09:00
Daan De Meyer
0dbdbed03f uid-range: Handle same userns in uid_range_load_userns_by_fd()
If we're asked to look up our own user namespace mapping, don't go
via fd as trying to setns() to our own user namespace in
userns_enter_and_pin() would fail with EPERM as the kernel doesn't
allow switching to your own userns.
2026-02-19 21:33:11 +01:00
Daan De Meyer
d28c96d85e userns-restrict: Remove unused inode argument and rename function 2026-02-19 21:33:11 +01:00
Daan De Meyer
fd99ead01d test-userns-restrict: Migrate to new assertion macros
We also inline the test functions so we get proper line information
in the failure coredumps.
2026-02-19 21:33:11 +01:00
Daan De Meyer
e6be5fb720 ssh-proxy: Support ssh machine/xxx for nspawn containers 2026-02-19 21:32:29 +01:00
Nandakumar Raghavan
fd6506eb9a repart: return 1 from probe_sector_size_prefer_ioctl() on block device success
probe_sector_size() returns 1 when it successfully determines the sector size,
0 when falling back to the default. blockdev_get_sector_size() returns 0 on
success. probe_sector_size_prefer_ioctl() was passing blockdev_get_sector_size()
return value through directly, so caller is checking r > 0 to detect a
successfully probed sector size never saw it for block devices.

In context_load_partition_table(), this caused fs_secsz to stay at 4096 bytes
even on 512-byte sector block devices, making verity hash partition sizes wrong
unless --sector-size=512 was passed explicitly.

Fix by returning 1 on success from the block device path to match probe_sector_size()
convention.
2026-02-19 17:43:56 +01:00
Yu Watanabe
551227e3a0 Python modernization followups (#40755) 2026-02-20 01:33:07 +09:00
Yu Watanabe
fcf5f1db94 mstack: fix typo
Follow-up for 8343032a86.
2026-02-20 01:14:30 +09:00
Yu Watanabe
5d01b27ffc import: fix typo
Follow-up for a9f6ba0496.
2026-02-20 01:13:02 +09:00
Lennart Poettering
0036d62e6e importd: add support for downloading OCI images (#39621)
This adds the ability to download OCI images via importd. 

Not a fan of the OCI format tbh, in particular its security properties
are a bit sad. But I guess it exists and is very popular, hence we might
as well add support for it, even if it comes at much weaker security
properties than DDIs.

Fixes #36447
2026-02-19 16:43:11 +01:00
Zbigniew Jędrzejewski-Szmek
469879aa44 generate-sym-test: skip everything that is not a file
The generator looks for files in the filesystem, and it sometimes fails
on emacs "lock files" which are a symlink. Ignore those.
2026-02-19 15:33:59 +01:00
Yaping Li
b0fba6abd3 metrics: fix casing for metrics names (take 2)
Change the casing for metrics names to mimic properties exposed via
varlink/dbus: Use PascalCase.
2026-02-19 15:30:18 +01:00
Daan De Meyer
b6bdd540f9 machine: Fix cid passed to machine_add_from_params()
The default value is VMADDR_CID_ANY, not zero.
2026-02-19 15:17:10 +01:00
Lennart Poettering
cab2caa170 mountpoint-util: fix typo in comment 2026-02-19 15:08:20 +01:00
Lennart Poettering
6ebaea6990 portable: fix log levels
portable_extract_by_path() and install_image() can't agree whether to be
of the "logging" or "non-logging" kind
2026-02-19 15:08:20 +01:00
Lennart Poettering
968f3ebd20 discover-image: make sure we can remove mstacks 2026-02-19 15:08:20 +01:00
Lennart Poettering
e93fd71094 core: introduce PinnedResource
This introduces PinnedResources as a structure combining pinned
references to a root directory, root image, or root mstack. This is not
only easier to work with, but essential to make certain unpriv things
work, as we need some mechanism to pin resources before we drop into a
userns which might possibly not provide access anymore to those
resources.

Hence this does two things: introduce the new structure, and immediately
hook it up so that we pin things properly before dropping into userns,
and then makes use of this after dropping the right way, and enables
unpriv userns operation.

The concept is generic enough to eventually implement extension images +
mount images with the same structure, but in order to keep the changes
managable this is left for another time.

(This also makes one further clean-up: client-side verity-reuse checks
are moved server side if we are unpriv. Previously we'd do them client
side, but they were doomed to fail because of lack of privs. Hence let's
drop the client side if we are unpriv and purely do them server-side in
that case.)
2026-02-19 15:08:20 +01:00