Commit Graph
88683 Commits
Author SHA1 Message Date
Yu Watanabe 98d061e28b TODO: fix typo 2026-05-13 05:34:21 +09:00
Daan De Meyer 53f0ac20b2 repart: Add BtrfsReplace= (#41109)
This is a series of commits which adds a feature needed by GNOME OS'
installer. This was show during All Systems Go 2025 talk:
https://cfp.all-systems-go.io/all-systems-go-2025/talk/QRJVL3/

To sum up this PR, this changes first systemd-repart to use BLKPG
partition instead of loop devices when possible. We need then to always
rescan the partitions to try remove partitions if it failed. We allow
encrypted partitions to stay activated and with a chosen name. And we
add a new partition configuration `BtrfsReplace=`.

Note that "replace" comes from the command `btrfs replace`. But in the
case of systemd-repart, maybe "inplace" or "move" would make more sense.
I open to suggestions.

If it is better I can split this into several PRs.

The commits:

## repart: Reuse the backing fd for fdisk

Because fdisk_assign_device tries to open block devices with O_EXCL,
when it does it blocks cryptsetup from using partition block devices for
the same disk.

Since we already have a file descriptor for the device, we can just
share it and use fdisk_assign_device_by_fd instead.

## repart: Use blkpg partitions instead of loop devices when possible

We will want to allow future features to keep some devices mounted or
active. So in order to avoid leaving a mess of many loop devices, we can
just already use the partition block device already.

## repart: Rescan disk on failure if we create blkpg partitions on the
fly

Since we did not write the partition table, then the created partitions
should get removed on error.

## repart: Allow keeping luks2 volumes opened

## repart: Add BtrfsReplace=

BtrfsReplace=/mntpnt will move the btrfs filesystem from mount point to
the partition created. After moving, it will resize to take the whole
partition.
This is useful for OS installers that move a live system into a disk and
do not require a reboot.

## repart: Add VolumeName=

When a luks2 device mapper is to be kept alive after execution of
systemd-cryptsetup, the name of the volume will be taken from this
value.

## test: Add test for repart's BtrfsReplace
2026-05-12 22:24:51 +02:00
Yu Watanabe d5244e1df5 test: split unit tests (#42062) 2026-05-13 04:54:57 +09:00
Daan De Meyer 408d474dfa vmspawn: Prefer systemd-journal-remote from $PATH
$PATH might point to a systemd checkout containing
a newer version of systemd-journal-remote which we
should use, hence prefer an executable from $PATH
over the one from /usr/lib/systemd.
2026-05-12 20:52:18 +02:00
Daan De Meyer 42f2970f89 Convert journalctl to option macros (#42051) 2026-05-12 20:42:39 +02:00
Yu Watanabe c28ec168aa test: move test cases for client_id_{hash,compare}_func() to test-dhcp-client-id.c 2026-05-13 03:02:37 +09:00
Yu Watanabe 000eb0f908 test: move unit test for dhcp_identifier_set_iaid() to test-dhcp-duid.c 2026-05-13 03:02:24 +09:00
Yu Watanabe bcc7755438 dhcp-network: make dhcp_network_send_{raw,udp}_socket() take iovec_wrapper 2026-05-13 02:59:00 +09:00
Yu Watanabe 2f8348e352 dhcp: introduce sd_dhcp_message object and several related functions (part 1) (#42047) 2026-05-13 02:58:20 +09:00
Luca Boccassi 9f08885b0e test: make TEST-75-RESOLVED robust against journald metadata race
Even after switching the wait loop to a polling `journalctl --grep`, the
test still fails intermittently because the very first messages emitted by
the freshly-spawned systemd-networkd-wait-online process can carry stale
journald metadata. journald associates `_SYSTEMD_UNIT=` (and friends) with
each entry by reading `/proc/$pid/cgroup` of the originating PID; if those
messages are produced before journald notices the cgroup migration into the
new service, they get tagged with `_SYSTEMD_UNIT=init.scope`. The
`-u $unit` filter then fails to match them.

Capture a journal cursor before launching the unit, and grep using
`--after-cursor=` plus `SYSLOG_IDENTIFIER=systemd-networkd-wait-online`
instead of `-u $unit`. SYSLOG_IDENTIFIER is set by the program itself, so
it's not subject to the cgroup-discovery race. The cursor bounds the search
to entries produced by this invocation, so prior wait-online runs in
earlier testcases don't interfere.

Logs from the failing run showing the messages exist but are tagged with
the wrong unit:

  [ 2570.948554] TEST-75-RESOLVED.sh[2178]: + unit=wait-online-dns-ede81407-b93b-459d-8e5d-69292b42d2ae.service
  [ 2571.023162] TEST-75-RESOLVED.sh[2178]: + systemd-run -u wait-online-dns-ede81407-b93b-459d-8e5d-69292b42d2ae.service ...
  [ 2571.049189] TEST-75-RESOLVED.sh[2178]: + timeout 30 bash -c 'until journalctl -b -u wait-online-dns-ede81407-b93b-459d-8e5d-69292b42d2ae.service --grep ...'
  [ 2571.964986] systemd-networkd-wait-online[2190]: dns0: No DNS server is accessible.
  [ 2601.051088] TEST-75-RESOLVED.sh[2178]: ++ cleanup

And for that 2571.964986 entry:

      _SYSTEMD_CGROUP=/init.scope
      _SYSTEMD_UNIT=init.scope
      _EXE=/usr/lib/systemd/systemd-executor
      _CMDLINE=/usr/lib/systemd/systemd-executor --deserialize 68 ...
      SYSLOG_IDENTIFIER=systemd-networkd-wait-online
      MESSAGE=dns0: No DNS server is accessible.

Follow-up for d4bc62713e

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 18:30:28 +01:00
Yu Watanabe d56adae624 copy: fix typo and slightly update comment 2026-05-13 02:04:33 +09:00
Yu Watanabe 3c5bb1f352 option: fix typo 2026-05-13 01:57:12 +09:00
Yu Watanabe 47eb11e4c2 po: update Japanese translation 2026-05-13 01:51:48 +09:00
Daan De Meyer d0234450b6 json-stream: tolerate truncated SCM_RIGHTS on inbound messages
When an LSM (e.g. SELinux) denies an fd transfer or the receiver hits
RLIMIT_NOFILE, the kernel drops the fd(s) from the SCM_RIGHTS cmsg and
sets MSG_CTRUNC on the recvmsg(). recvmsg_safe() turns that into
-ECHRNG, which causes json_stream_read() to discard the data bytes
that were nevertheless received and the varlink server to silently
tear down the connection — leaving the caller waiting for a reply
that never comes.

Inline the recvmsg() call instead and, on MSG_CTRUNC, drop the partial
fds but keep the message data. The method handler will surface a clean
-ENXIO when it tries to peek the missing fd, which sd-varlink wraps as
io.systemd.System for the peer, instead of a hang. This matches the
recent sd-bus fix in 6c8de404c9 ('sd-bus: allow receiving messages with
MSG_CTRUNC set').
2026-05-12 18:54:28 +02:00
Lennart Poettering 183ce1da4e update TODO 2026-05-12 18:49:43 +02:00
Valentin David 120f906c8b test: Add test for repart's BlockDeviceReplace 2026-05-12 18:31:27 +02:00
Valentin David 4021f565e2 repart: Add VolumeName=
When a luks2 device mapper is to be kept alive after execution
of systemd-cryptsetup, the name of the volume will be taken
from this value.
2026-05-12 18:31:26 +02:00
Valentin David c07fcbb507 repart: Add BlockDeviceReplace=
BlockDeviceReplace=/mntpnt will move the btrfs filesystem from mount point to
the partition created. After moving, it will resize to take the whole
partition.

This is useful for OS installers that move a live system into a disk and
do not require a reboot.
2026-05-12 18:31:25 +02:00
Valentin David 77b15343bc repart: Allow keeping luks2 volumes opened 2026-05-12 18:31:24 +02:00
Valentin David d0d00297a4 repart: Rescan disk on failure if we create blkpg partitions on the fly
Since we did not write the partition table, then the created partitions
should get removed on error.
2026-05-12 18:31:23 +02:00
Valentin David 0ef0824201 repart: Use blkpg partitions instead of loop devices when possible
We will want to allow future features to keep some devices mounted or
active. So in order to avoid leaving a mess of many loop devices, we can
just already use the partition block device already.
2026-05-12 18:31:22 +02:00
Valentin David 3ac8bd0e97 repart: Reuse the backing fd for fdisk
Because fdisk_assign_device tries to open block devices with O_EXCL, when it
does it blocks cryptsetup from using partition block devices for the same
disk.

Since we already have a file descriptor for the device, we can just share it
and use fdisk_assign_device_by_fd instead.

This requires at least libfdisk 2.35 (part of util-linux) which was
released in 2020.
2026-05-12 18:31:21 +02:00
Bone NI ee2c2b1b89 po: Translated using Weblate (Lao)
Currently translated at 100.0% (266 of 266 strings)

po: Added translation using Weblate (Lao)

Co-authored-by: Bone NI <bounkirdni@gmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/lo/
Translation: systemd/main
2026-05-12 18:01:20 +02:00
Yu Watanabe 28423ea18c dhcp-message: introduce dhcp_message_{append,get}_option_hostname() and related functions
These are for DHCP options 12 (Hostname) and 81 (FQDN) options.
2026-05-13 00:27:49 +09:00
Yu Watanabe aa9584a037 dhcp-message: introduce dhcp_message_{append,get}_option_parameter_request_list()
These are for DHCP option 55 (parameter request list).
2026-05-13 00:27:49 +09:00
Yu Watanabe a6a6e371f7 dhcp-message: introduce dhcp_message_{append,get}_option_client_id()
These are for DHCP option 61 (client ID).
2026-05-13 00:27:49 +09:00
Yu Watanabe 1c4ee9e969 dhcp-message: introduce dhcp_message_{append,get}_option_string()
These are for DHCP options that takes a string e.g. DHCP options
17 (root path), 60 (vendor class identifier), and so on.
2026-05-13 00:27:49 +09:00
Yu Watanabe 174a61135c dhcp-message: introduce dhcp_message_{append,get}_option_addresses()
These functions support multiple addresses.

These are for e.g. DHCP options 6 (DNS servers), 42 (NTP servers) and so on.
2026-05-13 00:27:49 +09:00
Yu Watanabe 4b2ff0a00f dhcp-message: introduce dhcp_message_{append,get}_option_address()
These are equivalent to dhcp_message_{append,get}_option_be32(), but for
type safety.

These are for e.g. DHCP options 50 (requested IP address).
2026-05-13 00:27:49 +09:00
Yu Watanabe 7b97d772a2 dhcp-message: introduce dhcp_message_{append,get}_option_sec()
These are for e.g. DHCP options 51 (lease time), 58 (renewal time), and
59 (rebinding time).
2026-05-13 00:27:49 +09:00
Yu Watanabe 8c18bb6547 dhcp-message: introduce sd_dhcp_message object and several functions for the object 2026-05-13 00:27:49 +09:00
Zbigniew Jędrzejewski-Szmek 143f5911b1 core: when skipping state deserializing units, also skip job subsections (#41957)
If a unit has active jobs, when it gets serialized there are job
subsections, each with their own empty line marker. The skipping
function ignores this and skips until the marker, but then leaves
the job in place, breaking deserialization.
Consume jobs subsections too.

This shows up now that there's TEST-07-PID1.alias-corruption,
which occasionally fails when the aliased unit happens to
still have a job when the reexec happens.

```
[  967.551630] TEST-07-PID1.sh[179]: + echo 'Testing with: systemctl daemon-reexec'
[  967.551630] TEST-07-PID1.sh[179]: Testing with: systemctl daemon-reexec
[  968.405274] TEST-07-PID1.sh[179]: + echo '--- Attempt 1/3 ---'
[  968.405274] TEST-07-PID1.sh[179]: --- Attempt 1/3 ---
[  968.698641] TEST-07-PID1.sh[179]: + echo 'Running daemon-reexec...'
[  968.698641] TEST-07-PID1.sh[179]: Running daemon-reexec...
[  969.130261] TEST-07-PID1.sh[179]: + echo 'legit.service PID remains 1282. Attempt 1 passed.'
[  969.130261] TEST-07-PID1.sh[179]: legit.service PID remains 1282. Attempt 1 passed.
[  970.870456] TEST-07-PID1.sh[179]: + echo '--- Attempt 2/3 ---'
[  970.870456] TEST-07-PID1.sh[179]: --- Attempt 2/3 ---
[  971.267205] TEST-07-PID1.sh[179]: + echo 'Running daemon-reexec...'
[  971.267205] TEST-07-PID1.sh[179]: Running daemon-reexec...
[  971.715743] TEST-07-PID1.sh[179]: + echo 'legit.service PID changed from 1282 to 1643!'
[  971.715743] TEST-07-PID1.sh[179]: legit.service PID changed from 1282 to 1643!
```


https://github.com/systemd/systemd/actions/runs/25376867873/job/74414201255
2026-05-12 17:12:59 +02:00
Yu Watanabe 8bc6aa614d network: use TLV and iovec to manage several DHCP options (#42045) 2026-05-13 00:02:10 +09:00
Zbigniew Jędrzejewski-Szmek f2a4288412 storagectl: add assert for args
coccinelle-storage check started failing…
2026-05-12 16:23:15 +02:00
Lennart Poettering 219d894db9 Implement Path/Scope/Swap/Timer Context/Runtime for io.systemd.Unit.List (#41980)
The PR implements the following objects + tests for
io.systemd.Unit.List:
* PathContext
* PathRuntime
* ScopeContext
* ScopeRuntime
* SwapContext
* SwapRuntime
* TimerContext
* TimerRuntime

It's a continuation of the following PRs:
* https://github.com/systemd/systemd/pull/37432
* https://github.com/systemd/systemd/pull/37646
* https://github.com/systemd/systemd/pull/38032
* https://github.com/systemd/systemd/pull/38212
* https://github.com/systemd/systemd/pull/39391
2026-05-12 16:12:36 +02:00
Daan De Meyer e530ef6761 btrfs-util: clear RDONLY flag on subvolume before destroy ioctl
Without CAP_SYS_ADMIN, btrfs_ioctl_snap_destroy() runs an
inode_permission(MAY_WRITE) check against the target subvolume root, which
btrfs_permission() rejects with EROFS for a read-only subvolume. As a
result, unprivileged removal of a read-only subvolume fails — both via
btrfs_subvol_remove_at() directly and via the recursive cleanup path used
by rm_rf_subvolume_and_freep(), which propagates the EROFS up.

Detect EROFS after the destroy ioctl, clear the RDONLY flag (only inode
ownership is required for BTRFS_IOC_SUBVOL_SETFLAGS), and retry once.

While at it, fix the surrounding comments: BTRFS_IOC_SNAP_DESTROY drops the
entire subvolume tree, so regular files inside are irrelevant; ENOTEMPTY
from the ioctl indicates nested subvolumes (BTRFS_ROOT_REF_KEY entries) via
may_destroy_subvol(), not non-empty contents.
2026-05-12 16:03:08 +02:00
Zbigniew Jędrzejewski-Szmek 1955c18a18 journalctl: move handling of --smart-relinquish-var to action logic
The help string for --smart-relinquish-var and --relinquish-var
were in reversed order because of the _fallthrough_.

We would resolve the conditions for "smart relinquish" immediately
in parse_argv() and call 'return 0' if the conditions were wrong,
terminating option parsing and the program. It seems nicer to delay
action until later. This makes the logic flow more standard. This
also allows the option parsing cases to be exchanged, fixing the
issue with --help.
2026-05-12 15:29:51 +02:00
Zbigniew Jędrzejewski-Szmek 1dbd734048 journalctl: drop some parentheses 2026-05-12 15:29:51 +02:00
Zbigniew Jędrzejewski-Szmek c3f4c1b8d6 journalctl: convert to OPTION macros
Two namespaces are used: "journalctl" and "journalctl-varlink". Help for
--user/--system in the latter is added, even though it is not used yet.
I think it'll be good to have this for introspection.

The four FSS-related options (--interval, --verify-key, --force,
--setup-keys) unfortunately each gain an inline #if HAVE_GCRYPT / #else;
the EOPNOTSUPP fallback is duplicated four times.

The metavar for --identifier/--exclude-identifier is changed to "ID"
to make the layout nicer. (And because that seems to make more sense.)

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 15:29:51 +02:00
drhydroxide 1f4052a2f2 60-sensor.hwdb iio/accel fix for Advan Evo-X 13 (#42037)
Added fix for Advan Evo-X 13 2-in-1 laptop

Relevant output of `udevadm info --export-db`
```
P: /devices/pci0000:00/0000:00:15.2/i2c_designware.3/i2c-2/i2c-NSA2513:00/iio:device0
M: iio:device0
R: 0
J: +iio:iio:device0
U: iio
T: iio_device
E: DEVPATH=/devices/pci0000:00/0000:00:15.2/i2c_designware.3/i2c-2/i2c-NSA2513:00/iio:device0
E: DEVTYPE=iio_device
E: SUBSYSTEM=iio
E: USEC_INITIALIZED=5462149
E: ACCEL_MOUNT_MATRIX=-1,0,0;0,-1,0;0,0,1
E: IIO_SENSOR_PROXY_TYPE=iio-poll-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:
```
2026-05-12 14:27:02 +01:00
Zbigniew Jędrzejewski-Szmek e7d07c2035 shared/options: add OPTION_COMMON_{SYSTEM,USER}
We have different help strings for --user/--system in different places, so this
only covers a subset of --system/--user instances. But this particular help
seems to be the most widely used.

(In a few cases, the help string is fixed: it should be "system mode", not
"per-system mode".)
2026-05-12 14:49:01 +02:00
Daan De Meyer 8b81e3b751 chase: Use openat2() if available
Let's make use of openat2() if we can in chaseat().
2026-05-12 14:43:39 +02:00
Daan De Meyer 452214c09b chase: Use ELOOP for CHASE_PROHIBIT_SYMLINKS error
Matches the behavior of openat2() with RESOLVE_NO_SYMLINKS
which makes introducing support for openat2() easier.
2026-05-12 14:43:39 +02:00
hschloss 1ea3359793 pe-binary: fix "systemd-sbsign calculates wrong PE checksum" 2026-05-12 14:15:05 +02:00
Zbigniew Jędrzejewski-Szmek 9bd3f4297d journalctl: reorder parse_argv() cases to match --help
Pure reordering. ARG_SMART_RELINQUISH_VAR is kept immediately before
ARG_RELINQUISH_VAR because of the existing _fallthrough_; that's the
only deviation from strict --help order.

Co-developed-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 14:05:35 +02:00
Yu Watanabe 0b8b2af657 Introduce helper functions to parse and build length-prefixed data and TLV data (#41802)
These are currently not used yet, but will be used later in
parsing/building network packets like DHCP message.
2026-05-12 20:08:40 +09:00
Yu Watanabe 30b14a0886 dhcp: use struct iovec_wrapper to manage user class 2026-05-12 20:06:28 +09:00
Yu Watanabe fa881fda15 sd-dhcp-option: drop unused sd_dhcp_option 2026-05-12 20:06:28 +09:00
Yu Watanabe 431ec1b145 dhcp: use TLV object to manage extra and vendor options
Note, previously we replaced the previous option with the same option code with
new one. But, DHCP message can have multiple options with same option code.
Hence, this make the conf parser not replace, but append new one.
2026-05-12 20:06:28 +09:00
Yu Watanabe 47747cd212 sd-dhcp-protocol: rename DHCP option 43, 124, and 125
There are four DHCP options with confusing names:
Option 43: Vendor-Specific Information
Option 60: Vendor Class Identifier
Option 124: Vendor-Identifying Vendor Class
Option 125: Vendor-Identifying Vendor-Specific Information

Let's use their full names for their corresponding enums.
2026-05-12 20:06:28 +09:00