Commit Graph
57894 Commits
Author SHA1 Message Date
Yu Watanabe f37931bd78 tree-wide: replace cg_{fd,path}_get_cgroupid() with {fd,path}_to_handle_u64() 2026-02-04 02:45:17 +09:00
Yu Watanabe 2eab8fa1e4 pidfd-util: use fd_to_handle_u64() 2026-02-04 02:45:17 +09:00
Yu Watanabe e7ce1e22b9 mountpoint-util: introduce name_to_handle_at_u64() and friends
They will be used later.
2026-02-04 02:45:06 +09:00
Yu Watanabe 09811ccaa1 mountpoint-util: make name_to_handle_at_loop() gracefully handle NULL path 2026-02-04 00:07:02 +09:00
Yu Watanabe 055ceec666 journal: avoid strjoina()/newa() (#40489)
Fixes #40456.
2026-02-03 23:42:23 +09:00
Yu Watanabe f2a54dac72 vmspawn/firstboot/homectl: fixes for plymouth (#40558) 2026-02-03 23:38:38 +09: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 dd839b1463 parse-util: rename trivial argument for parse_pid()
The function parse_pid() trivially returns pid, hence it is not
necessary to name the argument for storing result as 'ret_pid'.
2026-02-03 21:43:17 +09:00
Yu Watanabe 7e81423fb8 journal: check the length of timestamp field in syslog message
No functional change. Just refactoring and adding assertion.
2026-02-03 21:43:17 +09:00
Yu Watanabe 8d607f93b7 journal: make security label always NUL-terminated
Then, we can drop label_len or label_size arguments at various places.

While doing this, SCM_SECURITY is now ignored when SELinux is disabled
or when it contains embedded NUL.
2026-02-03 21:43:17 +09:00
Yu Watanabe dc709eff0b udev: create /run/udev/queue file earlier
When udevd received a uevent or inotify event, we will queue or trigger
synthesized events. To minimize the race between processing these events
by udevd and user invocation of 'udevadm settle', let's create /run/udev/queue
file earlier.
On some errors, no event may be queued, but in that case, the file will
be removed by the post event source if nothing queued. See on_post().

Hopefully mitigate the issue #40499.
2026-02-03 21:25:01 +09:00
Yu Watanabe b7363d3330 udev: remember UUIDs of triggered events
Otherwise, /run/udev/queue file may be removed before udevd receives
the triggered uevents. This avoids the following race:

1. uevent A is being processed,
2. received an inotify event and trigger a synthesized uevent,
3. uevent A has been processed,
4. the uevent queue becomes empty, and /run/udev/queue is removed,
5. received and queued the synthesized uevent, and /run/udev/queue is recreated.

With this patch, /run/udev/queue is not removed in step 4. Hence,
'udevadm settle' will wait for the synthesized event being processed.

This is similar to waiting for child processes that reread partitions
(thus trigger synthetic events) being terminated, but for synthetic
events triggered by the manager.
2026-02-03 21:25:01 +09:00
Yu Watanabe 95b40e4cf3 udev/watch: drop redundant argument
The arguments dev and target are always same.
2026-02-03 21:25:01 +09:00
Luca Boccassi 75cb25c0b9 firstboot/homectl: hide plymouth splashscreen when asking questions
When plymouth is enabled, the screen gets all garbled when firstboot
runs and asks questions. Disable the splash screen, but only when
actually asking questions.
2026-02-03 13:21:03 +01:00
Luca Boccassi 7f7622285d homectl: trim some trailing whitespace 2026-02-03 12:47:12 +01:00
Luca Boccassi 610d8c3dfc vmspawn: do not pass console=hvc0 in GUI mode
This breaks when using qemu's GUI mode. Follow mkosi's example.

Follow-up for 773ca1def8
2026-02-03 10:50:34 +01:00
Yu Watanabe 9b011d3f5e ssh-generator: drop unused variable 2026-02-03 16:50:00 +09:00
Yu Watanabe 9666541a56 ssh-generator: drop redundant check
The loop STRV_FOREACH() below does nothing if the strv is empty.
2026-02-03 16:50:00 +09:00
Yu Watanabe 70510c2c90 ssh-generator: fix memleak 2026-02-03 16:50:00 +09:00
Yu Watanabe 65b50ae2c8 sd-bus: do not log in higher than LOG_DEBUG from library
Follow-up for 6c8de404c9.

This also adds full stop to the log message, and make "vs" followed by
dot for consistency to other messages.
2026-02-03 16:49:46 +09:00
Antonio Alvarez Feijoo 2f76b10b94 import-generator: fix sysext/confext ordering in initrd
In the initrd, order the generated `systemd-import@.service` units before the
initrd-specific sysext/confext units.
2026-02-03 08:18:41 +09:00
Mike Yuan c27d1b3eec ssh-generator: follow symlink when searching for sshd@.service
unit_file_exists() currently does not follow symlinks, as it is
mainly used to test whether the unit (of any install state)
has been seen under search dirs. However, in ssh-generator
we should search for and honor whatever the distro ships,
which might be an alias or linked externally.
2026-02-03 08:17:34 +09:00
Luca Boccassi ce41216e49 ask-password: install polkit policy
The policy was added, but never hooked into meson to be installed,
so it's unused. Install it.

Follow-up for 066f6bfb62
2026-02-03 08:16:25 +09:00
Yu Watanabe ab8603d26b Fixes for ask-password (#40549) 2026-02-03 07:48:13 +09:00
Zbigniew Jędrzejewski-Szmek 65f72f5dbb ask-password: remove files in /run when query is aborted
Because of the missing 'goto', if the query was aborted, we
would leave behind the ask.* ini file.
2026-02-02 15:16:23 +01:00
Zbigniew Jędrzejewski-Szmek f01c99c67e ask-password: reject control chars and quotes in query description
As reported in https://yeswehack.com/vulnerability-center/reports/705270,
YesWeHack issue #YWH-PGM9780-66, if a newline is injected into the message
field, it is passed through unmolested and lands in the .ini file. This
obviously would cause the parser to be confused.

Let's forbid any control characters or quotes in those fields. If we want
something more complicated in the future, we can add a custom validation
function and allow some escaping mechanism.
2026-02-02 15:16:23 +01:00
Antonio Alvarez Feijoo 5327755f8b discover-image: fix typo in log message 2026-02-02 22:24:28 +09:00
Yu Watanabe 389254d9df boot: fix typo in variable name
Fixed by GitHub Copilot.
2026-02-01 08:26:07 +01:00
Yu Watanabe c3540c80a5 bus-unit-util: convert StandardInputText to StandardInputData
Fixes #40527.
2026-01-31 06:41:57 +09:00
Yu Watanabe da912e7f2f bus-unit-util: make ExecSearchPath= accepts colon separated list
Unlike other settings that takes multiple values, the setting takes
colon separated list of paths, but when specified as a DBus property,
it previously accepted space separated list of paths.
Let's also make the DBus property accepts colon separated lists.

Fixes #40513.
2026-01-31 01:24:07 +09:00
Yu Watanabe 4481c9ff65 machine: skip reading properties through DBus when not connected
When machined is started earlier than DBus service, the execution is
blocked by reading properties through DBus for a while. Let's return
earlier if the DBus connection is not ready.

Fixes issue reported in #40414.
2026-01-31 01:23:26 +09:00
Yu Watanabe 579640f50c network: slightly improve log message 2026-01-31 01:22:38 +09:00
Govind Venugopal e198f1a847 network: fix NFTSet population when [DHCPPrefixDelegation] Assign=no (#40049)
When [DHCPPrefixDelegation] Assign=no, networkd creates routes instead of
addresses. These routes need to populate nftables sets for firewall
rules to work correctly.

This commit adds dhcp_pd_route_modify_nft_set() to handle NFT set
updates for DHCP-PD routes, similar to how address_modify_nft_set()
handles them for addresses.

Fixes: #38383
2026-01-30 23:38:13 +09:00
Yu Watanabe 3762ada7e3 repart: Restore early fstab/crypttab generation (#40473)
fstab/crypttab generation were moved to the late stage to support
'fixate-volume-key' option. This, however, broke the use-case when
fstab/crypttab are put to the generated partition/image.

Fixes #40444
2026-01-30 23:32:07 +09:00
Yu Watanabe 43b6eb09be discover-image: Follow symlinks in a given root (#39843)
This is needed to set up extension images from the initrd with
`systemd-sysext --root=/sysroot/ merge`.

- vpick: Don't use openat directly but resolve symlinks in given root
    
With systemd-sysext --root= all symlinks should be followed relative to
    the given root and direct openat usage doesn't work.
    Remove the openat call and let pin_choice do the work with the chase
    helper function to resolve the symlink in the given root.
- discover-image: Follow symlinks in a given root
    
    So far systemd-sysext with --root= specified didn't follow extension
symlinks (such as the "current" symlinks managed by systemd-sysupdate).
The main use case is running systemd-sysext --root=/sysroot for setting
    up the overlay mounts already from the initrd.
    
Resolve symlinks correctly but don't defend against later symlink races
    that would access a path outside of the given root. Malicous live
modifications are not a realistic threat model and anyway for that one
would need to rework how the image entry is passed over up to the point
when the loop device is set up. This change here does not introduce this
weakness nor does it expose it more than before. Thus, make it explicit
    that setting up the extensions for a given --root= implies a certain
trust into this given root tree that it does not try do race conditions
with symlinks to trick systemd-sysext to mount a file outside --root=.
Without a strict --image-policy= set we would anyway mount filesystems
right away which is another attack vector but, again, the main use case
    is to do this for the final system which is trusted at this stage.
- sysext: Use correct image name for extension release checks
    
For the extension release check the image name is needed and was derived
    from the backing file of the loop device. However, this can have a
different name when symlinks were resolved. The surprising behavior was
that it worked when the target name started with the extension name and
_ because that's what's supported to chop off version suffixes. However,
we should not have such strict requirements for the target name and also
allow - as version separator and entirely different names/prefixes, the
    same way as we also do for directories instead of raw images.
    
    Do not use the image name derived from the backing file of the loop
    device but directly the extension name we have at hand.
- test: Add tests for handling symlinks with systemd-sysext
    
    When we now allow following symlinks inside a --root= we should also
test that it works in various cases from simple relative and absolute
    symlinks to .v being a symlink itself or its contents, both for
directory and for .raw image extensions. While at it, also add a simple
    test for .v without symlinks which wasn't there for direct usage of
    systemd-sysext.
2026-01-30 22:36:20 +09:00
Ivan Shapovalov 32417c1723 network: fix max MTU check for IPv6 MTU adjustments
When link MTU is being adjusted in an IPv6 context (e.g., according to
the MTU received in an RA), the new MTU is clamped against link's
current MTU than link's max MTU. This means that the link MTU can never
be increased via an RA:

    systemd-networkd[10068]: eth1: Reducing requested IPv6 MTU 8900 to the interface's maximum MTU 1500.
    systemd-networkd[10068]: Setting '/proc/sys/net/ipv6/conf/eth1/mtu' to '1500'
    systemd-networkd[10068]: No change in value '1500', suppressing write

Fix this check to make logical sense, and also to match a similar check
in src/network/networkd-setlink.c:link_adjust_mtu().
2026-01-30 22:34:20 +09:00
Vitaly Kuznetsov 307785960b repart: Restore early generation of fstab/crypttab
Commit 15b1c33 ("repart: Generate fstab and crypttab late") moved
fstab/crypttab generation to the late stage but this introduced a regression:
it may be necessary to include fstab and crypttab into the generated partition
(e.g. with CopyFiles=). This is incompatible with 'fixate-volume-key' option as
it is impossible to capture LUKS volume key before it gets created but all the
rest should work fine.

Generate crypttab twice: early and late to capture possible changes. There's no
need to do the same for fstab for now, so keep the status quo.
2026-01-30 13:21:57 +01:00
Mike Yuan 95a7b7d474 core: several follow-ups for varlink EnqueueMarkedJobs() method (#40365) 2026-01-30 08:38:13 +01:00
Yu Watanabe 1d60b723a3 Fix bug in DM iteration and standardise how to iterate through DM layers (#40426)
get_block_device_harder_fd() currently only traverses one level of
device mapper stacking when looking for the underlying block device.
This causes issues with nested DM setups like dm-crypt on top of
dm-integrity, where we don't traverse enough to get the actual physical
device.

Fix this by iterating through all DM layers until we reach a device with
no underlying device. And while we're at it also make cgroups use the
same logic.

Fixes: #40419
2026-01-30 15:36:03 +09:00
Lennart Poettering 1ccf4fe026 discover-image: carefully process sidecars
We have been a bit sloppy with caring for the various sidecards. Address
that.
2026-01-30 14:13:49 +09:00
Zbigniew Jędrzejewski-Szmek 248bc94fbf Rework error propagation in systemctl preset (#40504) 2026-01-29 16:41:31 +01:00
Zbigniew Jędrzejewski-Szmek 64eb78135c shared/install: rework error propagation again
The immediate impulse for this change is the fedora scriptlet which called:
  /usr/lib/systemd/systemd-update-helper install-system-units cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which called
  systemctl preset cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which threw an error that system-systemdx2dcryptsetup.slice does not exist
and did nothing at all. (The backslash is consumed by the shell.)
The obvious fix here is to figure out more levels of escaping… But we should
do something more robust in such cases.

If we fail in processing of a single unit, let preset all continue processing
units, report the failure through 'changes'. At the end, return failure. In
general, for operations which operate on a list of units specified by the user,
fail the whole operation if any of the individual operations failed. The only
operation where we don't do this is 'preset-all'.

$ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/ preset asdf1.servie asdf2.path; echo $?
Cannot find unit asdf1.servie.service.
Cannot find unit asdf2.path.
Failed to preset unit: Unit asdf1.servie.service does not exist
Failed to preset unit: Unit asdf2.path does not exist
1

While at it, fix double logging in the manager: dump_unit_changes() already
logs about errors, so the manager should only log on success.
2026-01-29 08:49:44 +01:00
Zbigniew Jędrzejewski-Szmek c67d64add6 shared/install: fix bogus error handling
This partially reverts a4f0e0da35. The
intent was good, we gather the errors, but we have no mechanism to
propagate the result, so the gathered result was ignored. In 'changes'
we can only report errors for specific units. If reading of the
directory fails, we might just as well report the error immediately.
This isn't great, but it's better then ignoring the errors. In practice,
failing halfway in this manner is unlikely, since it'd mean that the fs
is corrupted or something like that. We might as well return immediately
on such catastrophic errors.
2026-01-29 07:45:55 +01:00
Kai Lüke 16b3472b3f vmspawn: Add image format option to support qcow2
A QEMU qcow2 VM image can be internally sparse and compressed.
Support such images in vmspawn for both the main disk and any extra
disks.
2026-01-29 09:02:13 +09:00
Antonio Alvarez Feijoo b0b2a71d81 tar-util: do not error out if archive_read_next_header() returns ARCHIVE_WARN
archive_read_header(3) states that `archive_read_next_header()` returns
`ARCHIVE_WARN` if it succeeds but a non-critical error is found, so issue a
warning instead of stopping the untar process in this case.
2026-01-29 02:41:11 +09:00
Jeff Layton eb2e91b981 pidfd/cgroup-util: use fully-sized filehandle buffers
The current code assumes that FILEID_KERNFS filehandles will never grow
in size. This is not a safe assumption and userland shouldn't be trying
to guess the size of the filehandle it'll get.

We have a macro for that: MAX_HANDLE_SZ.
2026-01-29 00:57:03 +09:00
Kai Lueke 2ab3a2b44c sysext: Use correct image name for extension release checks
For the extension release check the image name is needed and was derived
from the backing file of the loop device. However, this can have a
different name when symlinks were resolved. The surprising behavior was
that it worked when the target name started with the extension name and
_ because that's what's supported to chop off version suffixes. However,
we should not have such strict requirements for the target name and also
allow - as version separator and entirely different names/prefixes, the
same way as we also do for directories instead of raw images.

Do not use the image name derived from the backing file of the loop
device but directly the extension name we have at hand.
2026-01-28 12:24:57 +01:00
Kai Lueke 5c6bb28999 discover-image: Follow symlinks in a given root
So far systemd-sysext with --root= specified didn't follow extension
symlinks (such as the "current" symlinks managed by systemd-sysupdate).
The main use case is running systemd-sysext --root=/sysroot for setting
up the overlay mounts already from the initrd.

Resolve symlinks correctly but don't defend against later symlink races
that would access a path outside of the given root. Malicous live
modifications are not a realistic threat model and anyway for that one
would need to rework how the image entry is passed over up to the point
when the loop device is set up. This change here does not introduce this
weakness nor does it expose it more than before. Thus, make it explicit
that setting up the extensions for a given --root= implies a certain
trust into this given root tree that it does not try do race conditions
with symlinks to trick systemd-sysext to mount a file outside --root=.
Without a strict --image-policy= set we would anyway mount filesystems
right away which is another attack vector but, again, the main use case
is to do this for the final system which is trusted at this stage.
2026-01-28 12:24:57 +01:00
Yu Watanabe 701cf5b698 ansi-color: follow-ups for $SYSTEMD_COLOR=auto-* (#40442)
Follow-ups for #40303
2026-01-28 16:00:38 +09:00
Yu Watanabe 5a30581d67 format-table: fix typo
Follow-up for f42dc5ea18.
2026-01-28 14:10:42 +09:00