Commit Graph

7323 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
6e6e96f628 udev: define a generic helper to print messages about unknown users and groups
We cannot just use %m, because strerror returns a confusing error message
for ESRCH or ENOEXEC. udev code was doing a good job, but the error handling
was very verbose. Let's encapsulate the customized error messages in a
helper.

No functional change, except that the error messages have a slightly different
form now. The old messages were a bit better, but we don't have as much
flexibility in the new scheme. "Failed to resolve user 'foo': Unknown user"
should be good enough.
2025-11-18 16:23:29 +01:00
Lennart Poettering
0712316e8e fs-util: enable automatic access mode logic in xopenat() 2025-11-18 01:31:49 +09:00
Yu Watanabe
07910c73b0 test: modernize test-log and add test cases for log_format_iovec() (#39750) 2025-11-18 01:31:02 +09:00
Lennart Poettering
1daf7b56bb tmpfile-util: make sure errno is left untouched by CLEANUP_TMPFILE_AT()
This mimics how rm_rf_physical_and_free() operate, and we should do the
same here, and make clean-up error paths not touch errno needlessly.
2025-11-17 16:53:31 +01:00
Yu Watanabe
d753c0c658 log: replace format string in LOG_ITEM() to a dummy one when analyzed by Coverity
Hopefully silence many false-positives.
2025-11-17 23:06:53 +09:00
Yu Watanabe
1f546ab779 log: make each string generated in log_format_iovec() NUL terminated
Nowadays, we append an extra NUL for each data if possible for safety.
We already do the same for example at write_to_kmsg(), log_do_context(),
write_to_journal(), log_struct_iovec_internal(), and so on.
This does not change any behavior, as the iov_len field is unchanged.
2025-11-17 22:38:38 +09:00
Yu Watanabe
44440ea658 cgroup-util: drop outdated comments 2025-11-17 21:31:51 +09:00
Yu Watanabe
4434fd76f1 cgroup-util: drop unused SYSTEMD_CGROUP_CONTROLLER_{LEGACY,HYBRID} 2025-11-17 21:31:51 +09:00
Yu Watanabe
b9e612e070 cgroup-util: do not check validity of controller in cg_split_spec()
Now the controller part is always ignored, hence let's skip check for
the controller part of the spec. This also make it acceppt unnormalized
path. Previously paths were checked by path_is_normalized(), but now
checked by path_is_safe(). Also, now this mapps an empty path to NULL.
2025-11-17 21:31:51 +09:00
Yu Watanabe
6a8ab5f062 cgroup-show: drop unnecessary call of cg_mangle_path()
As the caller already dropped controller part.
2025-11-17 21:31:51 +09:00
Yu Watanabe
a8156588fa cgroup-util: drop 'controller' argument from cg_get_path()
The argument is not used anymore. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe
5d397dc7f4 cgroup-util: drop 'controller' argument from cg_get_keyed_attribute() and cg_is_empty()
The argument is completely unused. Let's drop it.
2025-11-17 21:31:50 +09:00
Yu Watanabe
3454b160e4 cgroup-util: drop unused cg_unified() and friends 2025-11-17 21:31:50 +09:00
Yu Watanabe
2fe89e3b0f limits-util: drop cgroup v1 support from physical_memory() 2025-11-17 21:30:29 +09:00
Yu Watanabe
2d6dd692be cgroup-util: drop cgroup v1 support in cg_get_path()
We have dropped cgroup v1 support in v258. Let's assume we are running
on cgroup v2 and drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe
f5a48af34b cgroup-util: use cg_is_available() in cg_kill_supported() 2025-11-17 21:30:29 +09:00
Yu Watanabe
57c16d344b cgroup-util: drop cgroup v1 support from cg_mask_supported_subtree()
We have dropped cgroup v1 support in v258. Let's drop unused legacy code.
2025-11-17 21:30:29 +09:00
Yu Watanabe
0ab90015e0 tree-wide: replace cg_get_path_and_check() with cg_get_path()
We have dropped cgroup v1 support in v258. When running on cgroup v2,
cg_get_path_and_check() with SYSTEMD_CGROUP_CONTROLLER as controller is
equivalent with checking if we are running on cgroup v2 and then
cg_get_path(). As we can assume we are running on cgroup v2, then the
check is not necessary anymore, thus we can replace
cg_get_path_and_check() with cg_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe
b525a72f7b cgroup-util: drop cgroup v1 support from cg_pid_get_path()
We have dropped cgroup v1 support in v258. Let's drop legacy code.
Then, we can drop 'controller' argument from cg_pid_get_path() and
cg_pidref_get_path().
2025-11-17 21:30:29 +09:00
Yu Watanabe
6475926a59 cgroup-util: drop 'controller' argument from cg_path_open()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4dbf06bd85 cgroup-util: drop 'controller' argument from cg_set_attribute(), cg_get_attribute() and friends
Non-null controller arguments are always ignored when running on cgroup v2.
Let's drop the argument.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4d1badbbc4 cgroup-util: drop 'controller' argument from cg_enumerate_subgroups()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
f8de2107a7 cgroup-util: drop 'controller' argument from cg_enumerate_processes()
Nowadays it always takes SYSTEMD_CGROUP_CONTROLLER as controller.
Let's drop it.

No functional change, just refactoring.
2025-11-17 21:30:29 +09:00
Yu Watanabe
4365351b93 cgroup-util: introduce cg_is_available() and check it in tests
Now most of our code does not support cgroup v1. Let's skip test cases
if we are running on cgroup v1.
2025-11-17 21:29:51 +09:00
Yu Watanabe
07e437f569 musl: glob-util: filter out . and .. even if GLOB_ALTDIRFUNC is not supported
musl neither support GLOB_ALTDIRFUNC nor GLOB_BRACE.
Let's make safe_glob() work even when GLOB_ALTDIRFUNC is not supported.
Currently, GLOB_BRACE is simply ignored when it is not supported.
2025-11-17 12:19:22 +09:00
Yu Watanabe
e7254f9f4e efivars: fix typo
Follow-up for ab69a04600.
2025-11-16 11:12:10 +09:00
Yu Watanabe
6412e540bc path-util: add generic ignore extension to the hidden files (#39554) 2025-11-15 10:05:38 +09:00
Mike Yuan
0cb7dd5b96 fd-util: do not block O_TMPFILE with -EISDIR
Follow-up for 7cf4f07567
2025-11-14 21:51:28 +01:00
Mike Yuan
87ed096657 fs-util: simplify open_parent_at() a bit
Let's refrain from specifying any access mode when opening
a directory, which matches our usual style and allows us
to drop one condition.
2025-11-14 21:51:28 +01:00
Daan De Meyer
bc8aebdce9 log-context: Don't add log context if value is NULL
This avoids if conditions at the callsite which mess up stack based
lifetimes.
2025-11-14 11:38:59 +01:00
Daan De Meyer
5cf894ad58 basic-forward: Add WaitFlags forward decl 2025-11-14 11:38:59 +01:00
Mike Yuan
b0e7c6141f efivars: insert a newline below fstat() call 2025-11-13 21:17:32 +01:00
Yu Watanabe
1abe8dd9eb efivarfs readv() size fixes and more (#39715)
Fixes: #39695
2025-11-14 00:38:29 +09:00
Yu Watanabe
32d1bed50b tree-wide: assorted fixes/workarounds for supporting musl (#39687) 2025-11-14 00:16:50 +09:00
Lennart Poettering
dbc25d84ae efivars: seek back to beginning in each efi_get_variable() loop
We try to read again from the beginning, hence let's seek back.
Apparently efivarfs doesn't strictly require this, but it's really weird
that it doesn't.
2025-11-13 14:19:29 +01:00
Lennart Poettering
40cb2aa4f8 efivars: validate we are actually talking about a regular file
We already have the stat data, let's actually check if things are
alright before relying on .st_size
2025-11-13 14:19:29 +01:00
Lennart Poettering
ab69a04600 efivars: fix size checks in efi_get_variable()
writev() returns the full size, not just the payload size, hence always
add sizeof(attr) where necessary.

Let's also change a couple of "4" into sizeof(attr) all over the place,
to make clear what they are about.

Fixes: #39695
Follow-up for: 9db9d6806e
2025-11-13 14:19:29 +01:00
Lennart Poettering
88e26303ce efivars: don't bother with realloc() if we have no interest in the old data
We shouldn't ask glibc to keep the old data around (which realloc() is
about), given we overwrite it entirely anyway. Let's hence speed things
up here, and allow glibc to just allocate a new block for us (and
shorten the code a bit)
2025-11-13 12:37:08 +01:00
Mike Yuan
6dd412bc50 time-util: do not carry musl-specific fallback logic on glibc systems
Follow-up for 3ac4d68498

We have no sensible way to detect why strptime() fails, hence
the fallback path as it is now would fire on glibc systems too,
pointlessly. Let's guard it behind ifdeffery.
2025-11-13 09:40:20 +01:00
Yu Watanabe
4a028994df user-util: fix typo
Follow-up for b10fd796f5.
2025-11-13 15:36:47 +09:00
Yu Watanabe
a580dd4e53 musl: format-util: use %llu for formatting rlim_t
glibc uses uint32_t or uint64_t for rlim_t, while musl uses unsigned long long.
2025-11-13 08:02:05 +09:00
Yu Watanabe
4b774c740b musl: build-path: fix reading DT_RUNPATH or DT_RPATH
musl records DT_STRTAB as offset, rather than address. So, need to add
obtained bias to read runpath or rpath.
2025-11-13 08:02:05 +09:00
Yu Watanabe
5bb9063505 musl: hostname-util: introduce LINUX_HOST_NAME_MAX
glibc defines HOST_NAME_MAX as 64 and our code rely on that, but musl
defines the constant as 255. Let's provide our own definition for the
maximum length.
2025-11-13 08:02:05 +09:00
Yu Watanabe
43e4c91fc0 musl: avoid conflict between fcntl.h and basic-forward.h
glibc defines AT_FDCWD as -100, but musl defines it as (-100).
In basic-forward.h, we also define AT_FDCWD as -100, hence musl's fcntl.h
conflicts with forward.h. This is for avoiding the conflict.
2025-11-12 23:28:01 +01:00
Yu Watanabe
fe6e6cb6a0 time-util: several fixlets/workarounds for supporting musl (#39688) 2025-11-13 05:18:25 +09:00
Yu Watanabe
8d5b306bb9 musl: time-util: skip tm.tm_wday check
musl does not set tm_wday when it is explicitly requested.
The check is not necessary at all, it is just for safety.
Let's skip it when built with musl.
2025-11-13 03:13:59 +09:00
Yu Watanabe
6431f2e072 musl: time-util: introduce get_tzname() helper function
musl leaves the DST timezone name unset if there is no DST.
The helper function maps that back to no DST.
2025-11-13 03:13:55 +09:00
Yu Watanabe
3ac4d68498 musl: time-util: make parse_gmtoff() accept extended timezone offset format
musl v1.2.5 does not support %z specifier in strptime(). Since
fced99e93d
%z is supported, but it only supports strict RFC-822/ISO 8601 format,
that is, 4 digits with sign (e.g. +0900 or -1400), but does not support
extended format: 2 digits or colon separated 4 digits (e.g. +09 or -14:00).
Let's add fallback logic to make it support the extended timezone spec.
2025-11-13 02:40:32 +09:00
Mike Yuan
7cf4f07567 fd-util: introduce fd_vet_accmode()
Inspired by #39674
2025-11-12 15:44:50 +01:00
Zbigniew Jędrzejewski-Szmek
3b3113b87c locale-util: two fixlets for supporting musl (#39689) 2025-11-12 10:38:29 +01:00