Commit Graph

57300 Commits

Author SHA1 Message Date
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
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
Lennart Poettering
09596e7d1a repart: load libraries before forking off child 2025-11-24 11:56:47 +01:00
Lennart Poettering
52594c3184 udev: load a bunch of libs before we fork off worker processes 2025-11-24 11:56:47 +01:00
Lennart Poettering
5b2f52814b dissect-image: load library before we fork off metadata extractor child process 2025-11-24 11:56:47 +01:00
Lennart Poettering
e683dce1f1 portabled: load a bunch of libs before we fork off a dissector child processes 2025-11-24 11:56:47 +01:00
Lennart Poettering
6069de1ed3 pid1: pull in libmount unconditionally 2025-11-24 11:56:47 +01:00
Lennart Poettering
efaf5a763d execute: load a bunch of libs before we disable dlopen() 2025-11-24 11:56:35 +01:00
Lennart Poettering
800d11c36c nspawn: load three libraries we'll need later before we fork() a child 2025-11-24 11:49:44 +01:00
Lennart Poettering
2c7bdaf9f1 dlfcn-util: let's make our dlopen() code fail if we enter a container namespace
Now that we dlopen() so many deps, it might happen by accident that we
end up dlopen()ening stuff when we entered a container, which we should
really avoid, to not mix host and container libraries.

Let's add a global variable we can set when we want to block dlopen() to
ever succeed. This is then checked primarily in
dlopen_many_sym_or_warn(), where we'll generate EPERM plus a log
message.

There are a couple of other places we invoke dlopen(), without going
through dlopen_many_sym_or_warn(). This adds the same check there.
2025-11-24 09:19:33 +01:00
Yu Watanabe
19deb47ade firstboot: drop redundant and spurious errno check
Follow-up for 2319154a6b.
2025-11-23 22:36:50 +09:00
Luca Boccassi
941b91600c boot: ensure profile IDs do not get leaked and overwritten when there are tries suffixes
boot_entry_parse_tries() replaces the id, which means the id
with the profile appended is lost (leaked) and replaced by a plain filename
in case there are tries suffixes. This means the wrong order is used in
displaying the entries in the menu, as the main profile is always last
given id_without_profile has the tries suffixes and sorts higher,
while the main profile has no id_without_profile and the id sorts lower
since it does not have the tries suffix.

Follow-up for 4301ad00ef
2025-11-23 11:04:51 +09:00
Mike Yuan
375a4bd878 core/selinux-setup: actually skip setup gracefully when libselinux is not available
Follow-up for 83b6ef9b62
2025-11-22 19:07:28 +01:00
Mike Yuan
32b7a07b8c core/exec-invoke: deduplicate needs_setuid with needs_sandboxing 2025-11-22 19:07:28 +01:00
Daan De Meyer
87fbd33372 clang-tidy: Fix all remaining misc-include-cleaner violations
- Remove unused includes
- Add common false positive headers to misc-include-cleaner.IgnoreHeaders
- Add IWYU pragma keep for uncommon false positive headers
2025-11-22 10:19:41 +01:00
Daan De Meyer
d11ce97386 test-journald-config: Modernize test 2025-11-22 10:19:07 +01:00
Zbigniew Jędrzejewski-Szmek
add1828861 Various logging fixlets (#39837) 2025-11-22 10:14:10 +01:00
Yu Watanabe
e6baa5ba0b Use SD_JSON_BUILD_PAIR_* macros if possible in shared/core/home (#39845) 2025-11-22 10:04:02 +09:00
Yu Watanabe
924081f793 pam-systemd-home: various logging cleanups 2025-11-22 09:42:41 +09:00
Yu Watanabe
447eb0a00c pam-systemd-loadkey: append full stop 2025-11-22 09:42:41 +09:00
Yu Watanabe
37d8d6623f pam-systemd: various fixlets for logging
- Do not use '%m' when errno is not set.
- Do not use pam_syslog_errno() when errno is not set.
- Use pam_debug_syslog_errno() rather than log_debug_errno().
- Use 0 rather than PAM_SUCCESS in the function that returns negative
  errno, though PAM_SUCCESS == 0, hence that does not change any
  behavior.
- Append missing full stop in the log message.
2025-11-22 09:42:41 +09:00
Yu Watanabe
7214aa9a2c pam-util: make pam_debug_syslog_errno() returns pam error
Currently, the result of pam_debug_syslog_errno() is unused, hence this
does not change anything and may be slightly redundant. But let's follow
our usual coding style.
2025-11-22 09:42:41 +09:00
Yu Watanabe
82f2eb73b1 pam-util: use correct errno
- pam_log_oom() passes ENOMEM rather than -ENOMEM, hence previously
  pam_log_oom() did not return PAM_BUF_ERR.
- We may (mistakenly) pass SYNTHETIC_ERRNO(). Let's gracefully handle that.
- Introduce errno_to_pam_error() helper function.
2025-11-22 09:42:41 +09:00
Yu Watanabe
7582679d0e apparmor: update log message
Follow-up for c3b3eea2e5.
Addresses https://github.com/systemd/systemd/pull/39826#discussion_r2547327325.
2025-11-22 09:42:41 +09:00
Nick Rosbrook
7d23e27e4c test: skip test-reread-partition-table if missing privileges
Right now, this test runs inside unprivileged chroots, despite the
running_in_chroot() check. This is because running_in_chroot() fails
with -EACCES, which is ignored.

Hence, check for privileges before calling running_in_chroot(),
otherwise call is inconclusive. Note, the test will fail later on if
running without privileges anyways.
2025-11-21 19:28:05 +00:00
Luca Boccassi
12d2abe082 test: check for all errors in test-reread-partition-table
Otherwise if opening the loop dev fails, the test segfaults
dereferencing a NULL variable later

Follow-up for 757887d01d
2025-11-21 19:13:39 +01:00
Jelle van der Waa
2a3f05400a resolve: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
No functional change, just refactoring.
2025-11-21 17:34:58 +01:00
Jelle van der Waa
2ba6cdc1b9 home: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
No functional change, just refactoring.
2025-11-21 17:34:57 +01:00
Jelle van der Waa
7dda32a544 shared: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
No functional change, just refactoring.
2025-11-21 17:34:43 +01:00