Commit Graph

85135 Commits

Author SHA1 Message Date
Mike Yuan
38b59a83d2 libmount-util: build .c only if libmount feature is enabled
Follow-up for 7336f2c748

This alignes with some other optional modules in shraed/,
and it allows dlopen_libmount() to be optimized out entirely.
Let's avoid emitting pointless symbols.
2025-11-26 02:40:28 +01:00
Mike Yuan
46b4b33c25 Revert "pid1: pull in libmount unconditionally"
This reverts commit 6069de1ed3.
2025-11-26 02:40:28 +01:00
Mike Yuan
1bee93e6e2 core/mount: comprehensively disable mount unit support if no libmount
Follow-up for b3243f4bee
and 5df44d0f6a

Since we now consider this a supported senario, let's hook up
libmount loading with the high-level unit_type_supported() machinery
and gracefully skip the whole unit accordingly.
2025-11-26 02:40:27 +01:00
Mike Yuan
f76f91b7c9 dlfcn-util: fix potential dl handle leak
Follow-up for 2c7bdaf9f1
2025-11-26 01:41:51 +01:00
Daan De Meyer
2ba910ab06 run: Don't make executable absolute when --root-directory= is used
Also, unless --same-root-dir was specified, don't make the executable
absolute if we're running in a chroot. Situations like this are still iffy,
but we might as well handle them a little more gracefully.
2025-11-26 00:37:17 +01:00
Frantisek Sumsal
ade882f16f sd-journal: fix a copy-paste error
Dereference the Directory pointer in the debug message instead of the
(probably already freed) JournalFile one.
2025-11-26 00:36:03 +01:00
Zbigniew Jędrzejewski-Szmek
1d26bac43f tree-wide: Fix constness issues with newer glibc (#39896)
Latest glibc uses _Generic to have strstr() and other functions return
const char* or char* based on whether the input is a const char* or a
char*. This causes build failures as we previously always expected a
char*.

Let's fix the compilation failures and add our own macros similar to
glibc's to have string functions that return a mutable or const pointer
depending on the input.
2025-11-26 00:32:54 +01:00
Daan De Meyer
0bac1ed242 tree-wide: Fix constness issues with newer glibc
Latest glibc uses _Generic to have strstr() and other functions return
const char* or char* based on whether the input is a const char* or a
char*. This causes build failures as we previously always expected a char*.

Let's fix the compilation failures and add our own macros similar to glibc's
to have string functions that return a mutable or const pointer depending on
the input.
2025-11-25 20:49:39 +01:00
Daan De Meyer
33b0642e6a tree-wide: sizeof() fixes
- TIME_T_MAX is always time_t so the check in time-util.c was redundant
- quota-util.c was zero-ing a pointer
- smbios11.c was calling sizeof(pointer)
2025-11-25 17:34:48 +01:00
Daan De Meyer
c36942916b run0: Give --empower its own color, title and emoji
When in --empower mode, all created files will be owned by the current
user, which could be problematic when creating files outside of the
current user's home directory, as other processes running as the same
user would be able to edit those files.

While this is a bit of an edge case since users already have to go through
the effort of writing --empower to indicate they want a privileged session
as the current user, it's not unphatomable to think they could start an
empowered session which they later return to and continue using. Currently,
it's not easy to differentiate a regular run0 session and an empowered session
at a glance, so users might think they're using a regular run0 session when
they're actually using an empowered session.

To address this problem, let's give empowered session their own identify, by
making the background orange, using the pumpkin emoji as the shell prompt
prefix and giving them an orange circle as the PTY title.
2025-11-25 17:15:30 +01:00
Daan De Meyer
2f62e4f5d8 boot: Fix warning
memchr() is a macro on newer glibc so make sure to undefine it before
redefining it.
2025-11-25 16:50:50 +01:00
Yu Watanabe
784f5a52f8 openssl-util: indentation fix
Follow-up for 1144f07dc6.
2025-11-25 15:32:37 +01:00
Yu Watanabe
1defd69d69 TEST-02-UNITTESTS: drop outdated comment
Follow-up for 741d59b326.
2025-11-25 22:52:10 +09:00
Yu Watanabe
f01daa30f1 docs/MOUNT_REQUIREMENTS: fix typo
Follow-ups for 3e94ae6f1e.
2025-11-25 22:52:10 +09:00
Yu Watanabe
05afbcc377 process-util: fix typo
Follow-up for a08f2ea02d.
2025-11-25 22:52:10 +09:00
Daan De Meyer
d867010caa mkosi: Add hyperscale profile (#39329)
In the CentOS Hyperscale SIG, we maintain a backport of systemd with
its own rpm spec forked from rawhide.

Let's make it easy to build upstream rpms using the Hyperscale spec
by adding a mkosi hyperscale profile.
2025-11-25 13:50:45 +01:00
Daan De Meyer
32b10d0d28 TEST-88-UPGRADE: Stop resolved hook socket before downgrading
Otherwise it'll remain active and cause networkd to get started again
during the downgrade.
2025-11-25 11:49:31 +01:00
Zbigniew Jędrzejewski-Szmek
7fd5f7aade Adjust code to query terminal size and other attributes (#39832) 2025-11-25 11:43:26 +01:00
Daan De Meyer
91af194001 mkosi: Add fixed qemu ppa for Noble temporarily
Until https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/2127974
is fixed and rolled out, let's use enr0n's ppa with the fixed qemu
to make CI pass.
2025-11-25 11:02:34 +01:00
Daan De Meyer
c41c4b2bf3 mkosi: Add hyperscale profile
In the CentOS Hyperscale SIG, we maintain a backport of systemd with
its own rpm spec forked from rawhide.

Let's make it easy to build upstream rpms using the Hyperscale spec
by adding a mkosi hyperscale profile.
2025-11-25 11:02:34 +01:00
Daan De Meyer
fb514c2f8f mkosi: Rework how the pkgenv environment variables are set
Instead of including distribution specific files in the subimages,
let's have one common mkosi.pkgenv/ directory that handles all the
matching which is then included in the subimages.

This gives us more control on exactly how we do the matching.
2025-11-25 11:02:34 +01:00
Daan De Meyer
2fe49e8a4c mkosi: update mkosi commit reference to 10544812b35a668d4aac9834c78ee8166e99bc78
* 10544812b3 Don't fix up vmlinuz locations if not required
* 9baf551923 Reduce amount of packages in default image
* 9e1a2f18b8 Add support for assert sections
* c7c6e2c0b1 ubuntu: Switch to devel as the default release
* 0822deb69c Improve logging when we can not extract kernel version from filename
* 1fd7ef3db7 Do not build default initrd if Initrds= is specified
* 611c8b46c8 Don't unconditionally sync when PackageCacheDirectory=/var
* ab37f24d38 README: add link to OBS docs for mkosi builds
* 02bf256ebb completion: add reuse ignore comments
* 10ccb0b04f Make sure not all subimages depend on default-initrd subimage
* 442e1ce0f1 mkosi-tools: systemd-boot-tools is now available for all arches
* 307fc1dba3 action: make it work when used as a submodule
* c37a55f91b config: serialize dataclass instances in our JSONEncoder
* f26cb34155 log: set terminal window title in complete_step while mkosi runs
* 280c78e681 Make sure inherited settings are applied for the default initrd
* ae4f2fd718 Fix typo
* 5644f3e83e build(deps): bump github/codeql-action from 3.29.7 to 3.30.5
* 7d7b26b8c9 build(deps): bump actions/checkout from 4.2.2 to 5.0.0
* e805253447 postmarketos: implement is_kernel_package
* dd51d2e019 postmarketos: provide missing i386-vars.fd
* e23e6de66b Do not relabel files when building extension image
* ab05ead5eb Bump various systemd version checks to 258
* 382cc8b450 preset: drop systemd-networkd-wait-online.service
* 477b6b2ed5 mkosi-initrd: install systemd-container in network profile
* 1d167c0b53 mkosi-initrd: add 89-ethernet.network for network profile
* b1e81dec3a mkosi-initrd: Install libseccomp explicitly
* 3c431a141c opensuse: repository non-oss-debug is invalid
* 62ab363149 ci: add an s390x build job for additional coverage
* 62765f2d07 mailmap: deduplicate Daan
* 47f963f40b Revert "ci: Disable PPC jobs temporarily"
* 6a48f83dda dnf: Always specify --best again
* 3702368616 sandbox: Make all relative paths absolute during argparsing
* a587af0bf7 dnf: Fix /var package cache directory check in package_subdirs()
* 56cdbc25b5 Always use repository metadata from /var package cache directory
* 669d4418a3 Add note on Encrypt=yes to Passphrase= docs
* caa129edae Drop BuildSourcesEphemeral=yes from default image config
* 7edca63478 Add devicetree-auto support for UKI
* 6cb1649074 Don't add ncdu for ppc64-le on Fedora
* e019d2d2a6 ci: Disable PPC jobs temporarily
2025-11-25 11:02:34 +01:00
Yu Watanabe
27971114d5 factory: do not install nsswitch.conf when nss is disabled
When systemd is built with musl, nss modules are not supported,
hence the file is not necessary. Let's not install the file.
2025-11-25 10:48:31 +01:00
Zbigniew Jędrzejewski-Szmek
e698ee5705 basic/terminal-util: ignore failures in cleanup
Some of the functions were ignoring failure in cleanup, others weren't. If we
got a reply, it's better to use it, so ignore failures in cleanup everywhere.
2025-11-24 21:48:28 +01:00
Zbigniew Jędrzejewski-Szmek
46f6742911 basic/terminal-util: operate on one fd in get_default_background_color()
This moves the open call earlier, so that we do any state-changing operations
if we actually managed to open the nonblocking fd. The code is easier to follow
this way and might be more robust.

Suprisingly, this fixes https://github.com/systemd/systemd/issues/39055: it
seems that run0 chowns /dev/stdin (in my case /dev/pts/0) to root:root, and the
second run0 can read and write stdin/stdout throught the already-open fds,
but fd_reopen fails.

Fixes https://github.com/systemd/systemd/issues/39055.
2025-11-24 21:47:57 +01:00
Lennart Poettering
3a5d9ee980 discover-image: use _SD_PATH_INVALID where appropriate
The enum definition only exists for cases like this, use it, instead of
its literal value.

This doesn't effectively change anything, but cleans up the code a bit.
2025-11-24 17:42:04 +00:00
Lennart Poettering
b26e6207cb dissect-image: make verity params for mountfsd_mount_image() optional 2025-11-24 17:41:06 +00:00
Chris Down
e45f2aede9 Revert "nspawn: Fix broken host links for container journals" (#39879)
Reverts systemd/systemd#39727
2025-11-25 01:13:43 +08:00
Daan De Meyer
8c22cb264d core: Make libmount optional (#39878) 2025-11-24 17:19:26 +01:00
Antonio Alvarez Feijoo
7599d26436 run: fix two minor memory leaks
```
==19541== 8 bytes in 1 blocks are still reachable in loss record 1 of 3
==19541==    at 0x4841744: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19541==    by 0x50125C9: strdup (strdup.c:42)
==19541==    by 0x4C55925: getusername_malloc (user-util.c:154)
==19541==    by 0x1121D6: parse_argv_sudo_mode (run.c:1098)
==19541==    by 0x123B13: run (run.c:3032)
==19541==    by 0x124198: main (run.c:3100)
==19541==
==19541== 11 bytes in 1 blocks are still reachable in loss record 2 of 3
==19541==    at 0x4841744: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==19541==    by 0x50125C9: strdup (strdup.c:42)
==19541==    by 0x112A9C: parse_argv_sudo_mode (run.c:1182)
==19541==    by 0x123B13: run (run.c:3032)
==19541==    by 0x124198: main (run.c:3100)
```
2025-11-24 16:03:34 +00:00
Lennart Poettering
77a1e2dec6 Revert "nspawn: Fix broken host links for container journals" 2025-11-24 16:34:00 +01:00
Daan De Meyer
5df44d0f6a core: Make libmount optional
Instead of skipping libcore entirely when libmount is not available,
let's only compile out the pieces that need libmount. This makes the
meson logic much less complex and allows systemd-analyze to be built
when libmount is not available.
2025-11-24 16:23:10 +01:00
Daan De Meyer
9c2cd09420 test: Skip protect_kernel_logs test if libmount is missing
libmount is required for setup_namespace() so skip the test if it
is not available.
2025-11-24 16:10:31 +01:00
Lennart Poettering
39c343daa6 nspawn: fix CI 2025-11-24 15:53:47 +01:00
Yu Watanabe
da22ccf48f openssl-util: introduce openssl_extract_public_key() helper function
This splits out common logic in keyutil and systemd-measure.

Note, previously d2i_PUBKEY_fp() was used, but now it is replaced with
d2i_PUBKEY(), as musl seems to not support reading from memstream.
2025-11-24 22:49:55 +09:00
Daan De Meyer
4f6ef13f43 run0: Stay in cwd if --empower is specified without a user
If we run "run0 --empower", the expectation is to stay in the
current working directory, not switch to ~.
2025-11-24 14:39:34 +01:00
Lennart Poettering
c746488537 block dlopen() once we transition into some foreign namespace (#39824)
Let's make sure we never accidentally end up loading code from a foreign
namespace.
2025-11-24 14:14:16 +01:00
Daan De Meyer
d60206c49a meson: Still build libshared even if libmount is disabled (#39871)
Currently, if the libmount feature is disabled, we don't build libshared
and as a result skip building every other executable as well. Among
other things, this makes our nodeps CI builds kind of pointless since
hardly any code will be compiled.

Let's improve on the situation by making libmount properly optional in
libshared. Then, we only skip building the executables that actually
need libmount.
2025-11-24 14:05:29 +01:00
Yu Watanabe
0cc96fc213 test: use log_tests_skipped_errno() at one more place
Follow-up for 12d2abe082.
2025-11-24 21:16:39 +09:00
Daan De Meyer
7336f2c748 meson: Still build libshared even if libmount is disabled
Currently, if the libmount feature is disabled, we don't build
libshared and as a result skip building every other executable as
well. Among other things, this makes our nodeps CI builds kind of
pointless since hardly any code will be compiled.

Let's improve on the situation by making libmount properly optional
in libshared. Then, we only skip building the executables that
actually need libmount.
2025-11-24 13:09:41 +01:00
Daan De Meyer
e910f9bc63 test-reread-partition-table: Don't keep open fds around
Avoids EBUSY from BLKRRPART when built without libblkid support.
2025-11-24 13:09:41 +01:00
Daan De Meyer
dee7dfea1d test-reread-partition-table: Only check for CAP_SYS_ADMIN
We might have CAP_SYS_ADMIN even without being root.
2025-11-24 13:09:41 +01:00
Daan De Meyer
43687c22ab tests: Assume we're running in a chroot if check fails
running_in_chroot() will fail when a test is executed as a non-root
user without CAP_DAC_READ_SEARCH as it won't be able to access
/proc/1/root.

Let's make things more robust by skipping tests if we can't detect
if we're in a chroot or not, since if we can't even detect if we're
in a chroot or not, chances are we're missing the required privileges
to execute the test anyway.
2025-11-24 13:09:41 +01:00
Yu Watanabe
f866ff3df8 tree-wide: replace tab with space, adjust missing or duplicated space 2025-11-24 12:45:06 +01:00
Yu Watanabe
332bce5bd7 oomd: move check if processes can be killed into oomd_cgroup_kill()
This also adds a debuuging log if the check failed.
Addresses https://github.com/systemd/systemd/pull/39773#discussion_r2549439336.

Follow-up for 38e9d40c80.
2025-11-24 12:40:13 +01:00
Luca Boccassi
5da6a8ee6e man,doc: add uapi spec numbers to all links to uapi specs (#39867) 2025-11-24 11:15:09 +00:00
Lennart Poettering
ed3fcaae11 crash-handler: also disable dlopen(), just in case 2025-11-24 11:56:47 +01:00
Lennart Poettering
a08f2ea02d process-util: also disable dlopen() in safe_fork() 2025-11-24 11:56:47 +01:00
Lennart Poettering
9252e26f4c core: load libcryptsetup before forking off child that might need it 2025-11-24 11:56:47 +01:00
Lennart Poettering
c64a486058 sysext: load libraries before forking off worker child 2025-11-24 11:56:47 +01:00