Commit Graph
55698 Commits
Author SHA1 Message Date
Yu Watanabe 543a48b653 libc-wrapper: introduce a tiny libc wrapper
Then, move syscall definitions to the wrapper, and prototypes are moved
to relevant headers.

This also adds checks for add_key() and request_key(), as one day
glibc may be going to add some of them separatedly.

The check for fspick in meson.build is dropped, as it is currently
unused in our code.

This also moves
- basic/missing_bpf.h -> include/override/linux/bpf.h,
- basic/missing_keyctl.h -> include/override/linux/keyctl.h.
2025-07-11 13:05:46 +09:00
Yu Watanabe da522c9921 basic: move basic/missing_syscall_defs.h -> include/override/sys/syscall.h
This also moves syscall tables and generators to the same directory.

Note, inclusion of asm/sgidefs.h is dropped, as it is already included
by unistd.h and sys/syscall.h.
2025-07-11 13:05:46 +09:00
Yu Watanabe 2b912d2066 tree-wide: several cleanups for generating symbol lists and gperf files
- pass our system include directories to make generators use our libc
  wrappers and latest kernel headers,
- include relevant headers in generated gperf file,
- use files() rather than find_program(), as the result of
  find_program() cannot be passed to 'input' of custom_target(),
- move generate-bpf-delegate-configs.py to src/core/, as it is only used
  by libcore.
2025-07-11 13:05:42 +09:00
Yu Watanabe 1a60b97524 include: move libc header wrappers to src/include/override/, and kernel headers to src/include/uapi/
Preparation for later changes.
2025-07-11 12:44:26 +09:00
Yu Watanabe 99ae2ae328 test-cgroup: Ignore ENOENT from cg_create(); test-cgroup-util: Ignore ENXIO in one more place (#38158)
This was the only test failure building systemd-252-51.el9 in a
container, also previously reported against 252-rc1 under Gentoo in
#25015

This is a forward-port of the patch we actually started using for CIQ's
builds of the EL9-derived package, which was:

```diff
--- systemd-252/src/test/test-cgroup.c	2022-10-31 18:59:18.000000000 +0000
+++ systemd-252-test/src/test/test-cgroup.c	2025-07-10 00:47:07.541000000 +0000
@@ -62,7 +62,7 @@
         log_info("Paths for test:\n%s\n%s", test_a, test_b);
 
         r = cg_create(SYSTEMD_CGROUP_CONTROLLER, test_a);
-        if (IN_SET(r, -EPERM, -EACCES, -EROFS)) {
+        if (IN_SET(r, -EPERM, -EACCES, -EROFS, -ENOENT)) {
                 log_info_errno(r, "Skipping %s: %m", __func__);
                 return;
         }
```

I confirmed that the `ERRNO_IS_NEG_FS_WRITE_REFUSED` macro is equivalent
to checking the first 3 error codes above, so the addition of the check
for `ENOENT` is still just as relevant as it was in 252, but adding it
into the macro would be inconsistent with its name, description, and
possible other uses. Hence, in this PR I'm adding the extra check into
the `if`.
2025-07-11 10:38:04 +09:00
Yu Watanabe 878fa7d26e journalctl: do not fail on SIGTERM/SIGINT or STDOUT disconnect when running with --follow (#38116)
Closes #38114.
2025-07-11 10:36:31 +09:00
Yu Watanabe 0c0b4d544c io.systemd.Manager.Describe fix context/runtime split (#38135)
This PR rearranges fields in io.systemd.Manager.Describe according to
the guidance by Lennart:

> If a property can be set in a unit file, ever, then it belongs in context.
> Otherwise, it belongs to runtime.

Closes #38124.
2025-07-11 10:26:57 +09:00
Yu Watanabe b3337feb55 Plumbing to perform SELinux checks in varlink API (#38146)
This PR does minimal changes to introduce varlink support. Ideally, the
code should switch to using `mac_selinux_get_our_label()` and new
`mac_selinux_get_peer_label()`. But I leave it for now to minimize
breakage. `mac_selinux_get_peer_label()` remains unused.

This is a prep step to merge
https://github.com/systemd/systemd/pull/38032
2025-07-11 10:20:36 +09:00
Solar Designer 52fe0a490d test-cgroup-util: Ignore ENXIO in one more place 2025-07-11 01:49:36 +02:00
Yu Watanabe 054464ad52 main-func: drop unused DEFINE_MAIN_FUNCTION_WITH_POSITIVE_SIGNAL() 2025-07-11 08:44:43 +09:00
Yu Watanabe 390097724b journalctl: do not fail on SIGTERM/SIGINT, or when STDOUT is disconnected
The current behavior is not useful when e.g. pipefail is enabled.
Let's exit cleanly in such cases.

Closes #38114.
2025-07-11 08:41:10 +09:00
Solar Designer 470da65110 test-cgroup: Ignore ENOENT from cg_create()
which was the only test failure building systemd-252-51.el9 in a
container, also previously reported against 252-rc1 under Gentoo
in #25015
2025-07-11 00:28:14 +02:00
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
Ivan Kruglov d5f4bd3700 selinux: mac_selinux_unit_access_check_varlink macros 2025-07-10 21:16:32 +02:00
Ivan Kruglov e3fef210c8 selinux: mac_selinux_access_check_varlink_internal() 2025-07-10 21:16:32 +02:00
Ivan Kruglov fe3f2ac073 selinux: check_access() 2025-07-10 21:16:32 +02:00
Ivan Kruglov 5dc3096efb core: leave a comment about context/runtime split 2025-07-10 21:08:11 +02:00
Ivan Kruglov 79eec46dfd core: move ControlGroup move runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 89701e02ac core: move ConfirmSpawn from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 303d1b6b57 core: move ShowStatus/Log* from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 712f763036 core: move WatchdogDevice from runtime to context 2025-07-10 21:08:11 +02:00
Ivan Kruglov 545fde151a core: move RuntimeWatchdog* + RebootWatchdog + KExecWatchdog from runtime to spec 2025-07-10 21:08:11 +02:00
Ivan Kruglov afa9992429 core: fix double Environment present in both context and runtime 2025-07-10 21:08:11 +02:00
Ivan Kruglov a5d8520f86 core: move Version/Arch/Features/Taints/UnitPath from context to runtime 2025-07-10 21:08:11 +02:00
Ivan Kruglov 84c05ec632 selinux: get_our_contexts() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 3484af2800 selinux: rename mac_selinux_access_check_internal() -> mac_selinux_access_check_bus_internal() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 5a1cb174f8 selinux-utils: rename and expose log_selinux_enforcing_errno() 2025-07-10 21:06:51 +02:00
Ivan Kruglov 204e3cb6c8 selinux-util: mac_selinux_get_peer_label() 2025-07-10 21:06:51 +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
Yu Watanabe 7425f76c4e shutdown: voidify disable_binfmt() 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
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
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
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