Commit Graph
82731 Commits
Author SHA1 Message Date
Ubuntu df5b3426f6 journald: support reloading configuration at runtime 2025-07-10 21:38:36 +02:00
Lennart Poettering c35ceb84e3 Introduce ERRNO_IS_FS_WRITE_REFUSED(), and use it in binfmt_mounted() (#38117)
- This introduces ERRNO_IS_FS_WRITE_REFUSED(), and apply it where
usable.
- This makes unexpected errors in access_fd() called by binfmt_mounted()
propagated to the caller.
- Renames binfmt_mounted() to binfmt_mounted_and_writable(), as it also
checks the fs is writable.
- Voidifies one disable_binfmt() call in shutdown.c.
2025-07-10 21:38:13 +02:00
DaanDeMeyer cc43510a13 userdb: Add userdb.transient credentials
To implement --bind-user in systemd-vmspawn, we need a transient
version of these credentials. These are useful when the home directory
of the user is mounted into the container/vm and every trace of the user
will be (mostly) gone again when the container/vm is shut down.
2025-07-10 21:36:09 +02:00
DaanDeMeyer 88444243b8 ruff: Default to python 3.7 version
For some use cases we still want python 3.7 compat so let's default
to that and only target python 3.9 in a few specific cases.
2025-07-10 18:09:17 +02:00
Li Tian b6d4997683 Add --entry-type=type1|type2 option to kernel-install.
Both kernel-core and kernel-uki-virt call kernel-install upon removal. Need an additional argument to avoid complete removal for both traditional kernel and UKI.

Signed-off-by: Li Tian <litian@redhat.com>
2025-07-10 18:07:23 +02:00
DaanDeMeyer 33a5cc768c socket-activate: Always send NOTIFY=ready
Even if we're not using --accept=, it's very useful to be able to
synchronize on systemd-socket-activate having binded to its listen
socket, so let's always send READY=1. This means the payload can't
send READY=1 anymore but it's doubtful whether that's useful in this
case in the first place.
2025-07-10 16:19:46 +02:00
Daan De Meyer 6a9cb1936f Two trivial nspawn fixes (#38152) 2025-07-10 16:19:18 +02:00
DaanDeMeyer 1f24a954e4 vmspawn: Use virtio-blk-pci for image instead of virtio-scsi-pci
We don't need a full blown SCSI controller just to present the main
root drive device to the VM. Let's simplify the storage stack by using
virtio-blk-pci instead.

Additionally, virtio-blk-pci is a builtin module in Arch and Fedora
which means we can do qemu direct kernel boot without needing an initrd.
2025-07-10 16:18:33 +02:00
DaanDeMeyer 6ed684db41 escape: Make quote_command_line() argument const 2025-07-10 16:18:10 +02:00
DaanDeMeyer 8ba6c2b7f5 vmspawn: Disable hpet for vmspawn x86 virtual machines
hpet is an emulated clocksource that is generally discouraged in favor
of kvm-clock or tsc for virtual machines. While vmspawn's virtual machines
already use kvm-clock, leaving hpet enabled causes qemu on the host to
consume a non-trivial amount of cpu, so let's disable the hpet feature since
we're not making use of it anyway.
2025-07-10 16:14:52 +02:00
Yu Watanabe 0b565facc4 Revert "resolve: query the parent zone for DS records"
This reverts commit 49ff90c70d.
2025-07-10 15:18:07 +02:00
DaanDeMeyer 4f54d81ace nspawn: Use in_child_chown() in one more place 2025-07-10 13:55:45 +02:00
DaanDeMeyer 6f60ce002b nspawn: Improve log message 2025-07-10 13:55:43 +02:00
Eisuke Kawashima dc6e9c548b zsh-completion: generate completion for systemd-run from systemd-analyze
continuation of #37641
2025-07-10 11:39:06 +02:00
Jörg Behrmann 693f11d5ba news: fix typo 2025-07-10 10:23:28 +02:00
Christian Hesse 8dfe176adc man: clean up list of literals 2025-07-10 15:23:56 +09:00
Yu Watanabe 0777d821ad ci: also set TEST_RUNNER environment variable in coverage test
Otherwise, integration-test-wrapper.py will fail.
```
Traceback (most recent call last):
  File "/home/runner/work/systemd/systemd/test/integration-tests/integration-test-wrapper.py", line 693, in <module>
    main()
    ~~~~^^
  File "/home/runner/work/systemd/systemd/test/integration-tests/integration-test-wrapper.py", line 677, in main
    runner = os.environ['TEST_RUNNER']
             ~~~~~~~~~~^^^^^^^^^^^^^^^
  File "<frozen os>", line 717, in __getitem__
KeyError: 'TEST_RUNNER'
```

Follow-up for c0a5801f7b.
2025-07-10 07:39:15 +02:00
Yu Watanabe 7425f76c4e shutdown: voidify disable_binfmt() 2025-07-10 14:02:00 +09:00
Yu Watanabe f436c64e61 man: fix typo
Follow-up for 7baf403430.
2025-07-10 14:02:00 +09:00
Yu Watanabe 9a33cbac7d binfmt-util: rename binfmt_mounted() -> binfmt_mounted_and_writable()
As it does not only check if binfmt_misc is mounted, but also check if
it is writable.
2025-07-10 14:02:00 +09:00
Yu Watanabe bd068e2903 binfmt-util: propagate failure in access_fd()
It is not necessary to hide errors in access_fd(), and only acceptable
errors here are -EROFS, -EACCES, and -EPERM.
2025-07-10 14:02:00 +09:00
Yu Watanabe e28d408c6b errno-util: introduce ERRNO_IS_NEG_FS_WRITE_REFUSED() 2025-07-10 14:02:00 +09:00
Zbigniew Jędrzejewski-Szmek 85830b0d62 ukify: fix version detection for aarch64 zboot kernels with gzip or lzma compression
Fixes https://github.com/systemd/systemd/issues/34780. The number in the header
is the size of the *compressed* data, so for gzip we'd read the initial part of
the decompressed data (equal to the size of the compressed data) and not find
the version string. Later on, Fedora switched to zstd compression, and there we
correctly use the number as the size of the compressed data, so we stopped
hitting the issue, but we should still fix it for older kernels.

I verified that the fix works for gzip-compressed kernels. I also made the same
change for the code for lzma compression. I'm pretty sure it is the right thing,
even though I don't have such a kernel at hand to test.

>>> ukify.Uname.scrape('/lib/modules/6.12.0-0.rc2.24.fc42.aarch64/vmlinuz')
Real-Mode Kernel Header magic not found
+ readelf --notes /lib/modules/6.12.0-0.rc2.24.fc42.aarch64/vmlinuz
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
Found uname version: 6.12.0-0.rc2.24.fc42.aarch64
2025-07-10 13:37:07 +09:00
Zbigniew Jędrzejewski-Szmek d871e07285 TEST-04-JOURNAL: drop unexpected whitespace 2025-07-10 13:37:07 +09:00
Lennart Poettering 03b4a607f6 core: followups for the recent subgroup killing commits
This is a follow-up for 0f23564ad4 and
6b02854f50, as suggested here:

https://github.com/systemd/systemd/pull/37855#pullrequestreview-2997596953
2025-07-10 13:32:51 +09:00
Antonio Alvarez Feijoo dee77ac201 generate-bpf-delegate-configs: fix compatibility with Python 3.7
- Operator ":=" requires Python 3.8 or newer.
- list[str] requires Python 3.9 or newer.

Follow-up for ea9826eb94
2025-07-10 13:30:44 +09:00
Yu Watanabe 1cf5b39d64 core: add 'DefaultRestrictSUIDSGID' config option (#38126)
closes #37602, see there for extra motivation and considered
alternatives.

On typical systems, only few services need to create SUID/SGID files.
This often is limited to the user explicitly setting suid/sgid, the
`systemd-tmpfiles*` services, and the package manager. Allowing a
default to globally restrict creation of suid/sgid files makes it easier
to apply this restriction precisely.

## testing done
- built on aarch64-linux and x86_64-linux
- ran a VM test on x86_64-linux, checking for:
    - VM system boots successfully
    - defaults apply (both `yes`, `no`, and undefined)
    - systemd tmpfiles can set suid/sgid on journal log path
- Other services explicitly defining `RestrictSUIDSGID=no` can create
suid files
2025-07-10 13:30:07 +09:00
Yu Watanabe 6e619d6c8d man/systemd.exec: update documentation for PrivateBPF= (#38142)
Follow-up for #36134

Add a short description about what PrivateBPF=yes does and how it can be
useful.
2025-07-10 13:13:54 +09:00
Matteo Croce 7baf403430 man/systemd.exec: update documentation for PrivateBPF=
Add a short description about what PrivateBPF=yes does
and how it can be useful.
2025-07-10 01:57:14 +02:00
Matteo Croce 6b099b8369 man/systemd.exec: use constant instead of literal
Use <constant> instead of <literal> otherwise every configuration item
is wrapped in double quotes.
2025-07-10 01:26:46 +02:00
Lennart Poettering 733454ae8f update TODO 2025-07-09 22:32:31 +02:00
Grimmauld 0316fb8219 core: document 'DefaultRestrictSUIDSGID' 2025-07-09 21:45:46 +02:00
Grimmauld aa668230c9 core/varlink-manager: Support 'DefaultRestrictSUIDSGID' option 2025-07-09 21:45:41 +02:00
Grimmauld 97998d1cbe core/dbus-manager: Support 'DefaultRestrictSUIDSGID' option 2025-07-09 21:45:38 +02:00
Lennart Poettering 726183627b cgroup: handle ENODEV on cg_read_pid() gracefully
The recently added test case TEST-07-PID1.subgroup-kill.sh surfaced a
race: if we enumerate PIDs in a cgroup, and the cgroup is unlinked at
the very same time reading will result in ENODEV. We need to handle that
gracefully. Hence let's do so.

Noticed while looking at:

https://github.com/systemd/systemd/actions/runs/16143084441/job/45554929264?pr=38120
2025-07-09 20:45:59 +02:00
Yu Watanabe da412f3be2 recurse-dir: coding style cleanups; mount-util: teach open_tree_attr_fallback() our usual AT_EMPTY_PATH trick (#38130) 2025-07-10 03:32:33 +09:00
Grimmauld 30bbdf0771 core: add 'DefaultRestrictSUIDSGID' config option
closes #37602

On typical systems, only few services need to create SUID/SGID files.
This often is limited to the user explicitly setting suid/sgid, the
`systemd-tmpfiles*` services, and the package manager. Allowing a default
to globally restrict creation of suid/sgid files makes it easier to apply
this restriction precisely.
2025-07-09 11:08:34 +02:00
Grimmauld fd3b207011 units/systemd-tmpfiles-setup.service: explicitly set RestrictSUIDSGID=no
The tmpfiles service is used to set file permissions, e.g. for setting
suid bit on the journal log directory [1].

[1] https://github.com/systemd/systemd/blob/48e0f7bc2f94e74d15eed5c9e70b1c0269a495ec/tmpfiles.d/systemd.conf.in#L24-L25
2025-07-09 11:08:31 +02:00
Fabian Vogt e21cd6db9c units/initrd-cleanup.service: Conflict with emergency.target
This is very similar to 327cd2d3db:

If emergency.target is started while initrd-cleanup.service/start is queued,
the initrd-cleanup job did not get canceled. In parallel to the emergency
units, it eventually runs the service, which in turn isolates and starts
initrd-switch-root.target. This stops the emergency units and effectively
starts the initrd boot process again, which likely fails again like the
initial attempt. The system is thus stuck in a loop, never really reaching
emergency.target.

This can be triggered if a service in between initrd-parse-etc.service
and initrd.target fails.

With this conflict added, starting emergency.target automatically cancels
initrd-cleanup.service/start, avoiding the loop.
2025-07-09 10:28:29 +02:00
Mike Yuan 56c6d90f8c mount-util: teach open_tree_attr_fallback() our usual AT_EMPTY_PATH trick
While at it, rename it to _with_fallback following
the naming scheme we use elsewhere.
2025-07-09 10:14:00 +02:00
Mike Yuan 2b4999acb4 mount-util: regroup functions 2025-07-09 10:14:00 +02:00
Mike Yuan ba010e14f2 recurse-dir: switch to FOREACH_ARRAY 2025-07-09 10:13:59 +02:00
Mike Yuan 8d4b2689ca recurse-dir: use -EBADF as placeholder for invalid fd
As per our coding style.
2025-07-09 10:13:59 +02:00
Yu Watanabe f17c49c569 Add support for BPF tokens (#36134)
Add a new option `PrivateBPF=` to mount a private instance of bpffs.
Add also four configuration options
`BPFDelegate{Commands,Maps,Programs,Attachments}=` which set the
corresponding bpffs mount options in order to create BPF tokens:
https://lwn.net/Articles/947173/

Closes#35108.
2025-07-09 15:12:22 +09:00
Matteo Croce ea9826eb94 core: add options to delegate BPFFS token creation
Add four new options BPFDelegate{Commands,Maps,Programs,Attachments}=
in order to delegate to a BPFFS instance the permission to create tokens.

The value is a list of options taken from:
https://github.com/torvalds/linux/blob/v6.14/include/uapi/linux/bpf.h#L922-L1121
The special value "any" means to allow every possible values.

More informations about BPF tokens here:
https://lwn.net/Articles/947173/
2025-07-08 22:35:29 +02:00
Matteo Croce 3a47437fc9 core: Introduce PrivateBPF= to mount a private BPFFS
Add a new option PrivateBPF= to mount a new instance of bpffs within a
namespace.
PrivateBPF= can be set to "no" to use the host bpffs in readonly mode
and "yes" to do a new mount.
The mount is done with the new fsopen()/fsmount() API because in future
we'll hook some commands between the two calls.
2025-07-08 22:33:28 +02:00
Matteo Croce 2c7dabff50 core: split out setup_private_users_child()
Drop support for kernels older than 3.19, as this is where
/proc/<pid>/setgroups was added.

https://github.com/torvalds/linux/commit/9cc46516ddf497ea16e8d7cb986ae03a0f6b92f8
2025-07-08 18:23:46 +02:00
Matteo Croce 9554ac3052 tests: run test with CAP_BPF
Add CAP_BPF to tests run with nspawn, so we don't have to use a VM
to test BPF calls.
2025-07-08 18:23:46 +02:00
Matteo Croce a80c06cf02 nspawn: create mountpoint for bpffs
When we mount a tmpfs as /sys, create a mountpoint for bpf, as we
already do for cgroup
2025-07-08 18:23:46 +02:00
Yu Watanabe 48e0f7bc2f core: fix owner check of PIDFile=, and update document (#38115)
Closes #38108.
2025-07-08 23:58:19 +09:00