Commit Graph
91332 Commits
Author SHA1 Message Date
Paul Menzel ebe4dbf426 journal: log the error that made a journal file unusable
journal_file_open_reliably() recovers from nine distinct errors, but the
warning it emits names none of them:

  systemd-journald[47980]: File /var/log/journal/95790226b8d0779f4b4797314ca986d4/user-7736.journal corrupted or uncleanly shut down, renaming and replacing.

So an administrator cannot tell an unclean journald shutdown (-EBUSY)
from real corruption (-EBADMSG), an incompatible feature flag
(-EPROTONOSUPPORT) or a failing disk (-EIO) — all of which reach this
line. The reason is known at this point, but only reachable through the
log_debug_errno() calls in journal_file_verify_header(), which are off by
default and gone by the time the warning is noticed.

Append %m so the error is part of the message. It now reads

  File /run/log/journal/…/user-7736.journal corrupted or uncleanly shut down, renaming and replacing: Device or resource busy

for a file left online by an unclean journald exit, and

  … renaming and replacing: No data available

for a truncated one.
2026-08-25 10:48:49 +09:00
Martin Pitt b8bcae41ac ukify: add naming a certificate created by genkey
Image builds create a key separate from the SecureBoot one for verity
signing. Its certificate ships inside the image as the sysext trust
anchor.

`genkey` certs had a hardcoded "SecureBoot signing key on host <fqdn of
the build machine>" CN, which describes neither that verity role nor a
meaningful hostname.

Make that name configurable with `SecureBootCertificateCommonName=`,
like mkosi's `--genkey-common-name`. That allows image build tools to
re-use `ukify genkey` for non-SB keys.

Unlike the implicit truncation for the default name, a specified one
which is too long is an error. Add a citation where that limit comes
frm.
2026-08-25 07:22:47 +09:00
Yu Watanabe 2d31e784f1 vconsole: allow to control font scaling
This adds FONT_SCALE= setting in vconsole.conf,
vconsole.font_scale= kernel command line option and credential support.
When 2 or 200% is specified, the console font size will be doubled.

Closes #43273.
2026-08-25 06:58:06 +09:00
dongshengyuan 471e34d5cb homectl: write recovery key file via linkable tmpfile
Create the file with open_tmpfile_linkable_at().
Write the recovery key and trailing newline to the temporary fd.
Set the final mode to 0600 before publishing it.
Link it into place with link_tmpfile_at(..., LINK_TMPFILE_SYNC).
2026-08-25 06:57:32 +09:00
Yu Watanabe 3f72568682 varlink: introduce io.systemd.service.GetLogLevel (#43484)
...and use it to implement `log-level` in `resolvectl`.
2026-08-25 05:44:16 +09:00
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
Lennart Poettering 52d2fe7d83 dissect-image: tighten error path a bit
When we set up a device with LUKS or verity, we so far didn't release
references to the allocated device nodes even though we destructed the
volumes they are for. Let's fix that, and release everything.

This mostly matters for cases where multiple attempts to unlock are made
(for example because of a password issue), without releasing the
DissectedImage.
2026-08-24 16:32:37 +01:00
Luca Boccassi ffb861ef22 man: add some notes regarding security features (#43434) 2026-08-24 15:12:03 +01:00
Christian Glombek f9185464bb resolved: never serve stale cache data on link-local scopes
Serving stale cache data on a retry is a resilience feature for unicast
DNS: when the configured server does not respond, an expired answer beats
no answer. The gate in dns_transaction_go() that switches the cache lookup
into serve-stale mode from the second attempt on only checks
StaleRetentionSec=, not the scope's protocol, so it applies to mDNS and
LLMNR scopes as well. There it is wrong twice over:

 * With StaleRetentionSec= set, a query for a peer that has left the
   network misses the cache on the first attempt (the record's TTL has
   expired), gets no reply, and is then answered from the expired but
   retained record on the retry — for as long as the retention window
   lasts. On the link-local protocols a retry means that no peer
   answered, not that some server is unreachable, and RFC 6762 treats
   TTL expiry as a presence signal: a host whose records lapse is gone.

 * Independently of whether anything stale is cached, a cache hit made
   in serve-stale mode is reported with its TTL clamped to 30s (see
   dns_cache_lookup()) and counted in the served-stale statistics. mDNS
   transactions are retried at 1s, 2s, 4s, ... whenever nobody answers,
   so a record announced or learnt from another transaction in between
   is handed to the client with a 30s TTL instead of its real remaining
   TTL, and logged as a "Serve Stale response" although it never was
   stale.

Hence only enter serve-stale mode on unicast DNS scopes. This is the
lookup-side counterpart of the cache-side change that stops link-local
records from being retained past their TTL at all.
2026-08-24 23:06:26 +09:00
David 'equinox' Lamparter 1aedc8fe5e core/service: document & improve STOPPING=1
`STOPPING=1` is final, explain in the sd_notify man page that this is
the case and log an error if a service attempts to get back out of
STOPPING with another notification.

Fixes #43465 / 98734ac74d
2026-08-24 22:46:01 +09:00
Luca Boccassi dfaa2d3ee1 man: note that blocking w+x memory is required for RestrictFileSystemAccess= 2026-08-24 13:22:56 +01:00
Luca Boccassi 8ae9973783 man: note that overriding TTY isolation with run0 is discouraged 2026-08-24 13:22:56 +01:00
Luca Boccassi 744b7801cb man: note that GPT is implicitly trusted by sd-mountfsd 2026-08-24 13:22:56 +01:00
Luca Boccassi e8e852fa76 man: note that mixing sd-nsresourced and /etc/subuid is unsupported 2026-08-24 13:22:56 +01:00
Yu Watanabe 98b867040e compress: several trivial cleanups (#43490) 2026-08-24 21:12:06 +09:00
Lennart Poettering 9139f3c53f switch-root: do not check fs to sync against allowlist
This drops a good chunk of 21ab2fe6ec
again, which I think is plainly wrong or at the very least too
overengineered.

1. it's wrong to assume that overlayfs layers are mounted elsewhere in
   the fs. it's quite likely they aren't. and overlayfs correctly passes
   through fsync() to the top layer, hence we really should keep syncing
   it.

2. network file systems deserve syncing. This code here runs in the
   initrd, where a very restrictive set of file systems is mounted and
   which runs for a very short time only, i.e. the circumstances haven't
   really changed. Hence I am very sure it's better to sync file systems
   here than not to, we do this for safety reasons after all.
   Reliability always trumps speed here, we should not give up
   correctness over presumed speed improvements.

3. There's zero reason to believe FUSE doesn't need syncing. We live in
   a world where increasingly complex kernel file systems are moved to
   userspace, and hence FUSE can be used to implement *anything*. Hence
   we should sync it. Yes, FUSE means some backing process needs to run,
   but that's a job for the initrd to get right: make sure the process
   runs properly over the switch root if the mount is left in tact over
   the switch root too.

Hence, dumb this all down and drop the weird fine tuning here.
2026-08-24 14:06:59 +02:00
Hijae Song d669464b2a hwdb: add calibration override for AYANEO Flip KB/DS touchscreen
The Goodix Capacitive TouchScreen on the AYANEO Flip KB reports an
invalid calibration range during boot, due to unreliable I2C
communication with the touch controller early in the boot sequence.
Observed values include ABS_X max as high as 65343 and ABS_Y max as
low as 256, far outside the panel's actual resolution.

Confirmed on real hardware across multiple cold boots that the
controller never reports a correct calibration on its own, including
after forcing driver re-probes via unbind/bind. Override the axis
ranges with the panel's real resolution (1200x1920).

Also covers the Flip DS, mostly identical to the Flip KB apart from a
second screen replacing the keyboard. Not independently verified on
Flip DS hardware, but consistent with a community report of the same
Y-axis maximum (1919) for that model's main display, using a
different (and seemingly non-functional) override syntax.

Note: the panel is also mounted rotated relative to the raw sensor
axes; this entry only fixes the calibration range, not rotation (most
desktop environments handle touch rotation automatically when the
display output is rotated, independent of this).
2026-08-24 12:07:42 +01:00
Lennart Poettering 6cff583546 update TODO 2026-08-24 11:56:27 +02:00
Yu Watanabe e036040529 test-compress: extend buffer size
Otherwise, random input cases are not tested:
```
/* test_compress_decompress_blob */
/* testing xz text blob compression/decompression */
Loaded shared library 'liblzma.so.5' via dlopen().
/* testing xz random blob compression/decompression */
compression failed: No buffer space available
/* testing lz4 text blob compression/decompression */
Loaded shared library 'liblz4.so.1' via dlopen().
/* testing lz4 random blob compression/decompression */
compression failed: No buffer space available
/* testing zstd text blob compression/decompression */
Loaded shared library 'libzstd.so.1' via dlopen().
/* testing zstd random blob compression/decompression */
compression failed: No buffer space available
/* testing gzip text blob compression/decompression */
Loaded shared library 'libz.so.1' via dlopen().
/* testing gzip random blob compression/decompression */
compression failed: No buffer space available
/* testing bzip2 text blob compression/decompression */
Loaded shared library 'libbz2.so.1' via dlopen().
/* testing bzip2 random blob compression/decompression */
compression failed: No buffer space available
```
2026-08-24 03:30:52 +09:00
Yu Watanabe 20923e8ddc compress: use dlopen_compress() at one more place 2026-08-24 03:30:52 +09:00
Yu Watanabe 7ea7833b86 compress: shorten code a bit 2026-08-24 03:30:52 +09:00
Yu Watanabe 1e7a69ff87 compress: use decompressor_new() at several more places 2026-08-24 03:30:52 +09:00
Yu Watanabe 87693c7073 compress: make decompressor_new() accept NONE 2026-08-24 03:30:52 +09:00
Yu Watanabe 4e2cb2bdf1 compress: use dlopen_compress() in decompress_stream() 2026-08-24 03:30:52 +09:00
Yu Watanabe 8f0bc58664 compress: introduce dlopen_compress() and friends 2026-08-24 03:30:52 +09:00
Christian Glombek 15458a89f1 resolved: only apply stale retention to unicast DNS cache entries
StaleRetentionSec= is a resilience feature for unicast DNS: when the
configured servers are unreachable, answering from an expired cache
entry beats answering nothing at all. That rationale does not carry
over to the link-local protocols, where there is no configured server
that could be unreachable -- peers simply come and go, and a record's
TTL is the only thing bounding how long a departed peer is still
answered for.

For mDNS the mismatch goes further. RFC 6762 treats record expiry as a
presence signal -- a host or service whose records lapse is to be
considered gone (section 10.1 goodbye packets even force this early by
publishing TTL=0), and the section 5.2 cache maintenance scheme exists
precisely so that expiry happens on time. Retaining expired mDNS
records for StaleRetentionSec= contradicts that: vanished peers linger
in the cache for the whole retention window, are served to clients as
if still present, and DNS-SD browsers do not see their services
disappear when the records' TTL lapses.

Beyond lingering entries, retention also swallows goodbyes outright, as
noted in review of the goodbye re-arm fix [1]: dns_cache_prune() and
dns_cache_expiry_in_one_second() key on the retention-extended "until",
so with StaleRetentionSec= set a goodbye's TTL=1 rewrite lands a full
retention window out -- the one-second prune of RFC 6762 section 10.1
then drops nothing, nothing re-arms, and the withdrawn service stays
listed for the whole window.

LLMNR has no goodbye mechanism, so only the lingering half applies to
it, but it does apply: dns_transaction_cache_answer() passes the
retention through for LLMNR replies just like for unicast DNS, and the
stale-serving gate in the transaction code does not look at the
protocol, so a departed LLMNR peer keeps being answered from cache for
the whole window as well.

Zero the retention centrally in dns_cache_put() for everything but
unicast DNS, which covers both put paths: transaction replies and the
mDNS packets cached directly by on_mdns_packet(). Add tests pinning
both directions, including the goodbye rewrite of an existing mDNS
entry.

[1] https://github.com/systemd/systemd/pull/43259#discussion_r3809488076
2026-08-23 17:45:51 +01:00
Jakub Stasiak 5e96efc8df test: use socat for oomd prekill hooks
Arch rolling now ships Nmap 7.991, which contains Nmap commit
b408fc2, titled "Ignore stdin with recv-only"[1].

That change omits stdin from the Ncat descriptor list in recv-only
mode. For a Unix listener, the listening socket is then its sole
descriptor. Ncat enters its listen loop only when that list has more
than one descriptor or a connection already exists, so it exits
immediately after bind and leaves the socket pathname behind.

systemd-oomd sees that stale pathname, tries to invoke the hook, and
gets ECONNREFUSED. The notification output therefore remains empty
and the jq assertion fails. The problem is visible in trunk's CI
failures[2].

Use socat for these one-way Unix listeners. It remains in accept while
waiting for the hook and is already installed in integration images.

[1] https://github.com/nmap/nmap/commit/b408fc243ce26da7ca497595833c14ce36a5e1a4
[2] https://github.com/systemd/systemd/actions/runs/32622985037/job/97153925154
2026-08-24 01:33:20 +09:00
Aleksa Sarai 44cc69769d hostnamed: expose parsed TAGS in Describe
The DBus API already exposes the parsed machine-tags list via the Tags
property but varlink clients needed to parse the raw TAGS= line from
MachineInformationData (which also required implementing tag name
validation if the tags would later be used with SetTags, to avoid
spurious errors).

So, provide the same information that DBus gets (a list of pre-parsed
tags with bad tags gracefully removed) as a new MachineTags field
returned by Describe -- this does mean that the DBus API now exposes the
same data in two ways but making Describe() consistent is more important
and mirrors the OperatingSystem* class of properties.
2026-08-23 14:10:22 +01:00
Yu Watanabe ded83144eb sd-journal: constify several arguments 2026-08-23 15:27:41 +09:00
Jakub Stasiak 354b51ddbf sd-device: ignore invalid ordinary properties
I had a situation where Dell Wyse 3040 with SK Hynix eMMC stopped booting
after upgrading from Fedora 42 to Fedora 44 with systemd 259.8.

The card reports a product name containing byte 0x92, but the kernel event
also contains the valid module alias needed to load mmc_block:

    MMC_NAME=H8G4a\222
    MODALIAS=mmc:block

I inserted the mmc_block kernel module manually and booted successfully.
Then after enabling udevd debug logging and retriggering the MMC add event
via

    udevadm control -l debug
    udevadm trigger -v -c add -s mmc
    udevadm settle

I saw the failure in the "journalctl -b -u systemd-udevd.service"
output:

    mmc0:0001: sd-device: Refusing invalid property: MMC_NAME=H8G4a\222
    mmc0:0001: sd-device: Failed to add property 'MMC_NAME=H8G4a<92>': Invalid argument
    sd-device-monitor(manager): Failed to create device from received message: Invalid argument

Since PR 41001, strict property validation returns EINVAL for the bad
MMC_NAME. device_new_from_nulstr() propagated that error and discarded
the whole event, so udev never processed MODALIAS and did not load
mmc_block.

Skip ordinary properties whose keys or values fail validation. Do not store
them, but continue processing the remaining properties. Required and typed
properties are handled separately and remain fatal when invalid, as do
malformed records and all other errors.

Closes: https://github.com/systemd/systemd/issues/42930
Related: https://github.com/systemd/systemd/issues/41339
Related: https://github.com/systemd/systemd/issues/43008
Similar: https://github.com/systemd/systemd/pull/42316
Similar: https://github.com/systemd/systemd/pull/43061
Regression: https://github.com/systemd/systemd/pull/41001
2026-08-23 13:23:32 +09:00
lucia-huang7 ed22b5a77f discover-image: rename image sidecar files from old paths
image_rename() updated the Image object name and path before
computing the source paths for auxiliary files. As a result, the
auxiliary rename loop looked for files with the new image name,
while existing sidecars such as .roothash, .verity, and
.raw.tpmstate still used the old image name.

Delay updating the Image object until after renaming its settings
and auxiliary files. This lets image_auxiliary_path() resolve
existing sidecars from the old image name while
rename_auxiliary_file() assigns the new name.

Extend the import test raw image rename coverage to check
representative sidecars are renamed together with the image.
2026-08-22 11:31:55 +09:00
Luca Boccassi cd4379bb54 nsresourced: harden the transient UID/GID write restriction (#43196)
nsresourced hands out transient, recyclable UID/GID ranges to
unprivileged user namespaces, and a BPF-LSM policy is what keeps a
client from leaving inodes owned by its transient range on a file system
that outlives the namespace, so that a later client which gets the same
range can't inherit them.

The old policy decided based on the mount a write went through, which is
forgeable: unshare(CLONE_NEWNS) gives you clones of every mount with
fresh mount IDs but the same superblock, and the mount namespace's owner
is yours to pick. overlayfs sidesteps it entirely. So this reworks the
check to look at where the write actually lands on disk.

The first commit (Christian Brauner's) replaces the per-mount allowlist
with two questions answered from fields the client can't forge and that
survive mount cloning: does the file system die together with the user
namespace (sb->s_user_ns at or below the managed one), and does the
transient ID actually reach the disk, or does an idmapped mount
translate it into something else first. It walks the userns chain
upwards so a nested namespace can't escape it. The map layout changed,
so the pins move to userns-restrict.v2 and the old ones are removed on
install.

The second commit handles overlayfs. A write through an overlay creates
the file on the upper layer via vfs_create(), which only trips the inode
LSM hooks, not the path hooks we attach to, and the one path hook that
does fire sees the overlay mount, which belongs to the managed namespace
and so looks like it dies with it even though the upper may be
persistent. So we judge the upper at mount time in sb_kern_mount and
refuse a writable overlay unless its upper dies with the namespace too.
Reading overlayfs' private ovl_fs/ovl_layer uses CO-RE type flavors
guarded by bpf_core_type_exists(), and the service now orders after
modprobe@overlay.service.

The third commit deals with restarts. The managed set only lives in the
pinned maps, so an upgrade that changes the map layout comes up with
empty maps and every already-running namespace silently loses its
restriction. manager_startup() now re-adds the live registry entries to
the maps in the same pass that reaps the dead ones. The setgroups()
denial is restored from a flag we now store in the registry.

One consequence: a managed namespace can only mount a writable overlay
whose upper dies with it, e.g. a tmpfs it set up itself. If you need a
writable persistent upperdir (mkosi does), use a plain unprivileged user
namespace for that, not a transient nsresourced range.
2026-08-21 22:05:25 +01:00
Yu Watanabe f9558beb18 resolve: add io.systemd.Resolve.Monitor.{FlushCaches,ResetServerFeatures} (#43479)
Some miscellaneous varlink migration for resolved.

These seem to fit better with the io.systemd.Resolve.Monitor interface,
so add them to that.
2026-08-22 04:43:41 +09:00
tunaichao 641c19e21e core: apply UnsetEnvironment= after command line expansion
UnsetEnvironment= was applied to the environment block before the
command line was expanded. Since the expansion looks the variables up
in that same block, any variable listed in UnsetEnvironment= was
already gone when $VAR in ExecStart= and friends was expanded, and a
whole-word $VAR reference was dropped from the command line.

Let the expansion see the full environment block, and apply the
unsetting only to the environment block passed to the executed
process. This way UnsetEnvironment= can hide variables from the
executed process without breaking command lines that reference them.

Extend the exec-unsetenvironment test accordingly: the whole-word
$VAR6 argument must be expanded into a positional parameter for the
shell, while ${VAR6-X} must evaluate to X in the executed process.

Also document in both the UnsetEnvironment= description and the
"Environment Variables in Spawned Processes" section that the
unsetting happens after command line variable expansion.

Fixes: #43343
2026-08-22 04:27:27 +09:00
Chris Ayoub 0b87becb0a core: clear dependency graph before freeing all units
When the manager tears down every unit during reload or shutdown,
unit_free() removes each dependency from both endpoints. This work is
redundant because every dependency map is about to disappear, and it
scales poorly with thousands of synthesized mount units.

Clear all unit dependency maps in one manager-wide pass before invoking
the existing unit_free() cleanup.

With 10,000 bind mounts, this reduced the mean daemon-reload time from
63.558s to 14.708s.
2026-08-22 04:21:35 +09: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
Michael Vogt 3bbf9351dc creds: typo fix in the Credentials.NullKeyNotAllowed description
There is small (but confusing) typo in the description of the
`io.systemd.Credentials.NullKeyNotAllowed` error. This commit
fixes it.
2026-08-21 13:04:05 +02:00
Zbigniew Jędrzejewski-Szmek 16835f02c0 Add "project" field to cli introspection data (#43430) 2026-08-21 11:27:45 +02:00
Zbigniew Jędrzejewski-Szmek 9062186b46 shared/verbs: add "project" field in introspection data
As raised in post-merge review for the addition of COMMAND, nothing in the
data specified that the program is part of the systemd project.
2026-08-21 09:12:19 +02:00
Yu Watanabe 58b0764a20 sysctl: introduce --save= and --revert= options (#43325) 2026-08-21 04:57:57 +09:00
Yu Watanabe 8c321be1fb journal: always obtain Manager object from varlink server
Previously, the userdata assigned varlink operation was Manager object or
SyncReq object, depends on if synchronization operation is queued or not.

When there is a method that sets a custom userdata, we should not
inherit the userdata of sd_varlink_server to sd_varlink.

Let's drop SD_VARLINK_SERVER_INHERIT_USERDATA flag from the server,
and always obtain the Manager object from the server.

Follow-up for c2806a8c1d.
2026-08-21 04:56:28 +09:00
Chris Coulson 7ecc970249 tpm2: add missing dlopen_libcrypto
tpm2_tpmt_signature_to_pem uses openssl functions directly, so it needs
to ensure that it is dlopened.
2026-08-21 03:08:31 +09:00
dongshengyuan 83e9162b93 logind: preserve scheduled shutdown on failure
Do not discard an existing scheduled shutdown until the new action
has been accepted. Keep failed D-Bus and Varlink requests from
cancelling the pending shutdown.

Follow-up for: 5ed73478e1
2026-08-21 03:04:25 +09:00
Yu Watanabe 5e2d9c6ed1 man: document systemd-sysctl --save= and --revert= 2026-08-21 00:50:02 +09:00
Yu Watanabe 80e346af74 test: add test cases for systemd-sysctl --save= and --revert= 2026-08-21 00:48:25 +09:00