Commit Graph
81286 Commits
Author SHA1 Message Date
Daan De Meyer 1fbaabf9ec meson: Don't create static library target unless option is enabled
While we don't build these by default, all the source files still
get added to the compile_commands.json file by meson, which can confuse
tools as they might end up analyzing the source files twice or analyzing
the wrong one.

To avoid this issue, only define the static library target if the
corresponding option is enabled.
2025-05-12 13:35:50 +02:00
Daan De Meyer 30d20907bd meson: Remove unneeded include directories
meson by default adds the current source and build directory as include
directories. Because we structure our meson code by gathering a giant dict
of everything we want to do and then doing all the actual target generation
in the top level meson.build, this behavior does not make sense at all because
we end up adding the top level repository directory as an include directory
which is never what we want.

At the same time, let's also make sure the top level directory of the build
directory is not an include directory, by moving the version.h generation
into the src/version subdirectory and then adding the src/version subdirectory
of the build directory as an include directory instead of the top level
repository directory.

Making this change means that language servers such as clangd can't get
confused when they automatically insert an #include line and insert
"#include "src/basic/fs-util.h" instead of "#include "fs-util.h".
2025-05-12 13:35:50 +02:00
Daan De Meyer 6350d2dbd9 meson: Extract objects instead of creating intermediate static libraries
Currently, when we want to add unit tests for code that is compiled into
an executable, we either compile the code at least twice (once for the
executable, and once for each test that uses it) or we create a static
library which is then used by both the executable and all the tests.

Both of these options are not ideal, compiling source files more than
once slows down the build for no reason and creating the intermediate
static libraries takes a lot of boilerplate.

Instead, let's use the extract_objects() method that meson exposes on
build targets. This allows us to extract the objects corresponding to
specific source files and use them in other executables. Because we
define all executables upfront into a dictionary, we integrate this into
the dictionary approach by adding two new fields:

- 'extract' takes a list of files for which objects should be extracted.
  The extracted objects are stored in a dict keyed by the executable name
  from which they were extracted.
- 'objects' takes the name of an executable from which the extracted
  objects should be added to the current executable.

One side effect of this approach is that we can't build test executables
anymore without building the main executable, so we stop building test
executables unless we're also building the main executable. This allows
us to switch to using subdir_done() in all of these subdirectories to skip
parsing them if the corresponding component is disabled.

These changes get me down from 2439 => 2403 ninja targets on a full rebuild
from scratch.
2025-05-12 13:35:50 +02:00
Daan De Meyer d8def5dc87 meson: Stop doing nested build when fuzzers are enabled
Currently, when fuzzers are enabled, we run meson from within meson
to build the fuzzer executables with sanitizers. The idea is that
we can build the fuzzers with different kinds of sanitizers
independently from the main build.

The issue with this setup is that we don't actually make use of it.
We only build the fuzzers with one set of sanitizers (address,undefined)
so we're adding a bunch of extra complexity without any benefit as we
can just setup the top level meson build with these sanitizers and get
the same result.

The other issue with this setup is that we don't pass on all the options
passed to the top level meson build to the nested meson build. The only things
we pass on are extra compiler arguments and the value of the auto_features
option, but none of the individual feature options if overridden are passed on,
which can lead to very hard to debug issues as an option enabled in the top
level build is not enabled in the nested build.

Since we're not getting anything useful out of this setup, let's simplify
and get rid of the nested meson build. Instead, sanitizers should be enabled
for the top level meson.build. This currently didn't work as we were overriding
the sanitizers passed to the meson build with the fuzzer sanitizer, so we
fix that as well by making sure we combine the fuzzer sanitizer with the ones
passed in by the user.

We also drop support for looking up libFuzzer as a separate library as
it has been shipped builtin in clang since clang 6.0, so we can assume
that -fsanitize=fuzzer is available.

To make sure we still run the fuzzing tests, we enable the fuzz-tests option
by default now to make sure they still always run (without instrumentation unless
one of llvm-fuzz or oss-fuzz is enabled).
2025-05-12 13:34:28 +02:00
Valentin Hăloiu 1dbeb98fea Add netdev files associated with link to networkd JSON output (#37402)
`networkctl status LINK` gained support for showing the netdev
configuration files associated with a link in
c9837c17d5, but these netdev files were
never added to the JSON output too.

This pull-request fixes that by adding two new fields (`NetDevFile` and
`NetDevFileDropins`) to the `networkctl` (and `D-Bus`) JSON output.
2025-05-11 09:33:28 +09:00
Luca Boccassi f0b7ca9768 test: fix root check for test-bpf-foreign-programs
This test requires root, but the check was mistakenly dropped, causing it
to fail with an assert when running without root:

src/test/test-bpf-foreign-programs.c:308: Assertion failed: expected "test_bpf_cgroup_programs(m, "single_prog.service", single_prog, ELEMENTSOF(single_prog))" to succeed, but got error: Operation not permitted

Restore the uid check

Follow-up for 22e2f06428
2025-05-10 14:04:45 +02:00
Yu Watanabe d7b217f2a9 mount-tool: honor arg_canonicalize for ACTION_UMOUNT path_is_absolute() check too (#37398)
Split out from #36337
2025-05-10 03:22:20 +09:00
Yu Watanabe ef12eadfc8 core/bpf: drop old kernels support (#37151) 2025-05-10 03:13:42 +09:00
Yu Watanabe b112a676d5 udev: several cleanups for managing events (#37384)
Mostly no functional changes, just refactoring.
2025-05-10 02:30:25 +09:00
Mike Yuan b3cfee2f5d mount-tool: honor arg_canonicalize for ACTION_UMOUNT path_is_absolute() check too
Follow-up for 4e24796b5a
2025-05-09 18:39:51 +02:00
Mike Yuan 3cea9c403c core/mount: remove unused temporary variable 2025-05-09 18:39:37 +02:00
Luca Boccassi b6c3fc750a boot: skip shim-specific logic when running with new shim
Since shim 16 the plain BS->LoadImage() will just work (TM), we do not need
anymore to set up manual overrides and manually call in the shim-specific
lock protocol or to set shim-specific EFIVAR to make addons work or to load
shim-signed kernels.

Check if the new protocol added in v16 is present, and if so, skip
all that. Once versions < 16 are no longer supported/revoked, all
the code can be dropped entirely.
2025-05-09 17:07:14 +01:00
Yu Watanabe dcd2ad2314 udev: move error handling in event_requeue() to caller
Also, remove udev database on failure.
2025-05-10 00:26:32 +09:00
Yu Watanabe f694a527ac udev: split out device_broadcast_on_error() 2025-05-10 00:26:32 +09:00
Yu Watanabe e969ec1d51 sd-device: rename arguments
To make it consistent with its declaration and other function
prototypes.
2025-05-10 00:26:32 +09:00
Yu Watanabe dc231d66ac udev: move timeout event sources from struct Event to struct Worker
The timeout event sources are enabled only when the event is being
processed by a worker, hence they are not necessary to be owned by the
event.

No effective functional change, just refactoring.
2025-05-10 00:26:32 +09:00
Yu Watanabe e1ae931064 udev: list up all dependencies of an event when the first time it is examined
No functional change, just refactoring.
2025-05-10 00:26:32 +09:00
Yu Watanabe 0cde671c29 udev: check earlier if there is a free room for processing an event 2025-05-10 00:26:32 +09:00
Yu Watanabe 4478546649 udev: cache last queued event entry
When we have N queued events, LIST_APPEND() takes O(N).
Let's cache the last event to optimize queueing.
2025-05-10 00:26:32 +09:00
Yu Watanabe e962ebbe72 udev: introduce event_freep() and use it as cleanup attribute
No functional change, just refactoring and preparation for later change.
2025-05-10 00:26:32 +09:00
Daan De Meyer 180ea8b3ab More header cleanups (#37381) 2025-05-09 17:22:33 +02:00
Yu Watanabe 7ded1bcf04 test: allow to allocate test scope even running with unprivileged user 2025-05-10 00:17:52 +09:00
Yu Watanabe ad446c8ceb core/bpf-devices: use bpf_program_supported()
Note, BPF_PROG_TYPE_CGROUP_DEVICE is supported since kernel v4.15.
As our baseline on the kernel is v5.4, we can assume the bpf type is
always supported.
2025-05-10 00:17:52 +09:00
Yu Watanabe ec3c5cfac7 core/bpf-firewall: replace bpf_firewall_supported() with bpf_program_supported()
Note, BPF_PROG_TYPE_CGROUP_SKB is supported since kernel v4.10, and
BPF_F_ALLOW_MULTI and program name is supported since kernel v4.15.
As our baseline on the kernel is v5.4, we can assume that the type,
flag, and naming is supported when bpf_program_supported() succeeds.
2025-05-10 00:17:52 +09:00
Yu Watanabe 22e2f06428 core/cgroup: foreign bpf programs needs to pass bpf_program_supported()
As CONFIG_CGROUP_BPF may be disabled on the kernel or we are running on
sanitizers. See comments in bpf_program_supported().

Follow-up for 3fcb98cbff.
2025-05-10 00:17:52 +09:00
Yu Watanabe 71be1f3875 bpf-program: introduce bpf_program_supported() helper function
It checks if the kernel is built with CONFIG_CGROUP_BPF.
It is currently unused, but will be used later.
2025-05-10 00:17:52 +09:00
Yu Watanabe df80d728be bpf-compat: drop unused compat_libbpf_probe_bpf_prog_type() 2025-05-10 00:17:52 +09:00
Yu Watanabe fb9991962d core/bpf: drop unnecessary check for probing program type
BPF_PROG_TYPE_CGROUP_SKB is supported since kernel v4.10
(0e33661de493db325435d565a4a722120ae4cbf3) and
BPF_PROG_TYPE_CGROUP_SOCK_ADDR is supported since kernel v4.17
(4fbac77d2d092b475dda9eea66da674369665427).

Our baseline on the kernel is v5.4. The check is not necessary.
2025-05-10 00:17:52 +09:00
Yu Watanabe 4d2b9abbe1 core: replace cgroup_bpf_supported() with dlopen_bpf_full()
After 3988e2489a, the function is a simple
wrapper of bpf_dlopen() with logging. Let's introduce dlopen_bpf_full()
that takes log level, and replace cgroup_bpf_supported() with it.
2025-05-10 00:17:52 +09:00
Yu Watanabe e06e34a3b6 udev: replace get_user/group_creds() with userdb/groupdb_by_name() (#37304)
This also makes networkd not refuse User=/Group=root.
2025-05-09 20:54:16 +09:00
Kurt Borja 15450ba214 hwdb: keyboard: Add Alienware special keys
Add Alienware *Performance mode* toggle key and *Macro* keys.

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
2025-05-09 20:42:00 +09:00
Marcos Alano fb8149234a Add emulated release to G-Mode key 2025-05-09 20:41:45 +09:00
Daan De Meyer 5f142e01d0 strv: Move STRV_FOREACH() to strv-fundamental.h 2025-05-09 11:33:33 +02:00
Daan De Meyer 56c710ce37 alloc-util: Remove unneeded stdlib.h include 2025-05-09 11:33:33 +02:00
Daan De Meyer 2782dae50f compress: Drop lz4 includes from compress.h
The lz4 functions are only used in test-compress.c, so let's just
put the declarations and includes in there instead of having everyone
including compress.h pull in the lz4 headers.
2025-05-09 11:33:33 +02:00
Daan De Meyer 7227d5bfff terminal-util: Move various functions to ansi-color.c 2025-05-09 11:33:33 +02:00
Daan De Meyer c992250c24 basic: Move parts of audit-util.{c,h} to libaudit-util.{c,h} in shared/ 2025-05-09 11:33:33 +02:00
Daan De Meyer 3b7d332047 macro: Reduce transitive includes 2025-05-09 11:33:31 +02:00
Daan De Meyer 3b58245624 basic: Override glibc's sys/param.h header with an empty file
Instead of unconditionally including sys/param.h in
macro-fundamental.h which itself includes a bunch of other unnecessary
headers, let's override it with an empty file to avoid it from overriding
our MAX() macro. We can't make including it an error as it's included (
for seemingly no good reason) by <resolv.h>.
2025-05-09 11:23:14 +02:00
Yu Watanabe 37c8a03ebf udevadm-info: parse all arguments before doing anything (#37292) 2025-05-09 14:09:45 +09:00
David Tardon 6cdc63d120 udevadm-info: use string table to parse query type 2025-05-09 12:14:21 +09:00
David Tardon 4ef3019ceb udevadm-info: drop args of stat_device()
They are all static vars now, so can be used directly.
2025-05-09 12:14:21 +09:00
David Tardon 8ea3c1fb9e udevadm-info: shorten the code a bit 2025-05-09 12:14:21 +09:00
David Tardon 31767b92a0 udevadm-info: reject devices passed via opts too
Follow-up-for a6b4b2fa01
2025-05-09 12:14:21 +09:00
David Tardon d89b3004da udevadm-info: split arg. parsing into a separate function 2025-05-09 12:14:16 +09:00
David Tardon 86ff972ac3 udevadm-info: drop superfluous pager_open() call
It's already called in advance in info_main().
2025-05-09 12:10:51 +09:00
David Tardon 5b4d73208e udevadm-info: make arg_pager_flags static 2025-05-09 12:10:51 +09:00
David Tardon cb3f6c9e0d udevadm-info: move static dtor closer to args 2025-05-09 12:10:51 +09:00
Yu Watanabe 0c93e66386 udev: use userdb_by_name()/groupdb_by_name()
Prompted by https://github.com/systemd/systemd/pull/37294#discussion_r2068141968.
2025-05-09 12:10:28 +09:00
Yu Watanabe e4d07d1a2d userdb: introduce USERDB_SYNTHESIZE_NUMERIC flag
When the flag is set, even if the specified UID/GID does not exist,
create a synthetic user record for the UID/GID.
Currently, only system UID/GID are supported.
2025-05-09 12:10:28 +09:00