Commit Graph

6915 Commits

Author SHA1 Message Date
Mike Yuan
946eea7a7f mountpoint-util: remove unused TMPFS_LIMITS_SYS_FS_CGROUP
Follow-up for 6801a9d88a
2025-05-15 09:00:51 +09:00
Mike Yuan
68a2435cc2 cgroup-util: drop cg_kill() cgroup.threads kludge
Our baseline is v5.4 now.
2025-05-15 07:26:03 +09:00
Daan De Meyer
3b21af5234 hashmap: Split out iterator.h
As preparation for #37344, let's split out iterator.h so we can
avoid including the entirety of hashmap.h where it's not needed.
2025-05-15 00:01:32 +02:00
Daan De Meyer
0dc510ab03 tpm2-util: Make sure structs/enums are named and add to forward.h
We have to name structs/enums to be able to forward declare them, so
let's do that and add the missing ones to forward.h.
2025-05-14 22:34:02 +02:00
Yu Watanabe
1ef6cee327 Bugprone argument comment - round 4 (#37380)
Follow up from https://github.com/systemd/systemd/pull/37356
2025-05-15 03:36:16 +09:00
Daan De Meyer
17b0d165f6 capability-util: Ignore unknown capabilities instead of aborting
capability_quintet_mangle() can be called with capability sets
containing unknown capabilities. Let's not crash when this is the
case but instead ignore the unknown capabilities.

Fixes d5e12dc75e
2025-05-15 03:33:32 +09:00
Daan De Meyer
d802d40e86 forward: Add forward declaration for LockFile (#37445) 2025-05-14 19:55:18 +02:00
Daan De Meyer
ba6d1f9aca forward: Add forward declaration for LockFile 2025-05-14 19:20:00 +02:00
Daan De Meyer
5f7b80b4e5 hashmap: Make sure Iterator struct is named
Otherwise we can't forward declare it.

Split out of #37344
2025-05-14 17:21:37 +02:00
Daan De Meyer
02b6ac3a50 static-destruct: Move static_destruct() logic to implementation file
This will allow us to remove the memory-util.h include from
static-destruct.h as part of #37344.
2025-05-14 16:56:41 +02:00
Daan De Meyer
686bbf1e7f Introduce forward.h header with forward declarations
In preparation for adopting forward declarations to reduce unnecessary
transitive includes across the tree, let's introduce a forward.h header
with forward declarations for all libc, libsystemd, basic and shared types.

Additionally, this header exports all basic integer types and errno constants,
as well as all macros including assertions macros. These header files contain
types often used in headers and are always included in every source file one
way or another anyway.

To avoid having to include memory-util.h and alloc-util.h in forward.h, we
split off the parts we need from both into cleanup-util.h and only include
cleanup-util.h in forward.h.

To keep this commit self-contained, we include cleanup-fundamental.h and
cleanup-util.h from the headers that originally contained the same macros.
We'll remove these again in a later commit that optimizes the includes in
src/basic and src/fundamental.

Split out of #37364
2025-05-14 15:44:17 +02:00
Jelle van der Waa
39f4686045 basic: fix consistency of flags argument for chase and chaseat
Both functions have one flags argument, so we don't need to
rename them to `chase_flags`.
2025-05-14 12:10:54 +02:00
Jelle van der Waa
09755ba511 treewide: fix argument comment for getxattr_at_bool 2025-05-14 11:15:45 +02:00
Jelle van der Waa
4827c9fde8 basic: fix argument naming for vt_release 2025-05-14 11:15:45 +02:00
Lennart Poettering
559795fa46 compress: deal with zstd decoder issues gracefully
If zstd frames are corrupted the initial size returned for the current
frame might be wrong. Don#t assert() on that, but handle it gracefully,
as EBADMSG
2025-05-13 15:39:57 +02:00
Lennart Poettering
a2ab433a60 socket-util: make return parameter to socket_autobind() optional 2025-05-13 14:42:33 +02:00
Ivan Kruglov
e739395f13 socket-util: socket_address_equal_unix() 2025-05-13 01:55:15 -07:00
Ivan Kruglov
92e8e2b034 log: log_get_target_max_level() 2025-05-13 01:53:22 -07:00
Antonio Alvarez Feijoo
0425fc5eb7 log: fix declaration of log_dispatch_internal() 2025-05-12 23:42:19 +09:00
Mike Yuan
81d5eda6c5 core: accept "|" ExecStart= prefix to spawn target user's shell; teach run0 about the new logic (#37071)
I've always been reluctant to invoke the current user's shell in another
user's context, hence was fully grounded in `sudo -i`. With this bit in
place `run0` will finally be feature-complete on my side ;-)
2025-05-12 16:10:03 +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
180ea8b3ab More header cleanups (#37381) 2025-05-09 17:22:33 +02: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
64fc712fe7 user-util,user-record-nss: initialize buffer before calling getpwnam_r() and friends
The buffer will be used by a library outside of our code base,
and may not be initialized even on success. Let's initialize
them for safety.

Hopefully fixes the following fuzzer warning:
```
==2039==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7f9ad8be3ae6 in _nss_files_getsgnam_r (/lib/x86_64-linux-gnu/libnss_files.so.2+0x8ae6) (BuildId: 013bf05b4846ebbdbebdb05585acc9726c2fabce)
    #1 0x7f9ad93e5902 in getsgnam_r (/lib/x86_64-linux-gnu/libc.so.6+0x126902) (BuildId: 0323ab4806bee6f846d9ad4bccfc29afdca49a58)
    #2 0x7f9ad9b98153 in nss_sgrp_for_group /work/build/../../src/systemd/src/shared/user-record-nss.c:357:21
    #3 0x7f9ad9b98926 in nss_group_record_by_gid /work/build/../../src/systemd/src/shared/user-record-nss.c:431:21
    #4 0x7f9ad9bcebd7 in groupdb_by_gid_fallbacks /work/build/../../src/systemd/src/shared/userdb.c:1372:29

  Uninitialized value was created by a heap allocation
    #0 0x556fd5294302 in malloc /src/llvm-project/compiler-rt/lib/msan/msan_interceptors.cpp:1021:3
    #1 0x7f9ad9b9811d in nss_sgrp_for_group /work/build/../../src/systemd/src/shared/user-record-nss.c:353:23
    #2 0x7f9ad9b98926 in nss_group_record_by_gid /work/build/../../src/systemd/src/shared/user-record-nss.c:431:21
    #3 0x7f9ad9bcebd7 in groupdb_by_gid_fallbacks /work/build/../../src/systemd/src/shared/userdb.c:1372:29
```
2025-05-09 12:10:28 +09:00
Yu Watanabe
f9550d1182 prioq: make prioq_ensure_put() type safe 2025-05-08 05:58:33 +09:00
Yu Watanabe
4699f0e68a prioq: check if identical compare func is specified if already allocated 2025-05-08 05:58:33 +09:00
Yu Watanabe
bc169c4fa2 hashmap: check if identical hash_ops is specified if already allocated 2025-05-08 05:58:33 +09:00
Yu Watanabe
54bbfa007d set: rename _set_ensure_allocated() -> set_ensure_allocated()
Follow-ups for c09ce222b6.
2025-05-08 05:58:33 +09:00
Yu Watanabe
8449d38d6f boot: Add EDID (#36843)
This adds a couple of custom CHIDs which include panel manufacturer and
product code.
2025-05-08 02:48:00 +09:00
Todd C. Miller
ffb6adb763 flush_ports: flush POSIX message queues properly
On Linux, read() on a message queue descriptor returns the message
queue statistics, not the actual message queue data.  We need to use
mq_receive() to drain the queues instead.

Fixes a problem where a POSIX message queue socket unit with messages
in the queue at shutdown time could result in a hang on reboot/shutdown.
2025-05-08 02:37:45 +09:00
Mike Yuan
398b3e4472 path-util: introduce filename_or_absolute_path_is_valid() helper 2025-05-07 18:32:19 +02:00
Mike Yuan
72758ef117 env-util: add missing assertions 2025-05-07 18:32:18 +02:00
anonymix007
f504ce8407 fundamental: Move common string constants from basic/string-util.h to string-util-fundamental.h 2025-05-07 18:10:51 +03:00
Daan De Meyer
decad4826d static-destruct: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
e53d4f343d iovec-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
6553db6063 strv: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
d9ccf6b349 path-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
fda652117e fs-util: Reduce transitive includes 2025-05-07 22:04:46 +09:00
Daan De Meyer
c034915cb6 af-list: Remove transitive includes 2025-05-07 22:04:46 +09:00
Mike Yuan
b04ddbcbd7 string-table: annotate _to_string and _from_string with _const_ and _pure_, respectively
Follow-up for c94f6ab1bf
2025-05-06 23:07:00 +02:00
Daan De Meyer
1fbfbe81b5 tree-wide: Get rid of prefix_roota() in favor of path_join()
We deprecated prefix_roota() in favor of chase() and path_join().
Let's finish the removal by replacing the few remaining call sites
with path_join().
2025-05-06 17:40:33 +02:00
Daan De Meyer
38c9ca5380 tree-wide: Remove strv_from_stdarg_alloca()
It's trivial to replace all uses of this function with STRV_MAKE()
and strv_new_ap() so let's get rid of this variant.
2025-05-06 17:40:01 +02:00
Mike Yuan
c0239e5f11 macro: implement ABS via __builtin_imaxabs() 2025-05-06 17:39:01 +02:00
Daan De Meyer
efc529cfbd Add missing alloc-util.h to string-util.h
Used by strndupa_safe() and strdupa_safe().

Follow up for 02207b54d5
2025-05-06 17:38:11 +02:00