Commit Graph
7428 Commits
Author SHA1 Message Date
Yu Watanabe e6a25c2fc7 stat-util: make proc_mounted() not update errno
Typically, proc_mounted() is used in error handling. Hence, it is better
to make it not update the original errno.

Currently, there are two places that returns wrong error code:
- pidref_get_capability() in src/basic/capability-util.c
```c
        _cleanup_fclose_ FILE *f = fopen(path, "re");
        if (!f) {
                if (errno == ENOENT && proc_mounted() == 0)
                        return -ENOSYS;

                return -errno;
        }
```
- fdset_new_fill() in src/shared/fdset.c
```c
        d = opendir("/proc/self/fd");
        if (!d) {
                if (errno == ENOENT && proc_mounted() == 0)
                        return -ENOSYS;

                return -errno;
        }
```

Rather than fixing them, let's make proc_mounted() not update errno,
otherwise we may make a similar failure in a future.
2026-01-20 22:37:04 +09:00
Yu Watanabe b7dd507cae tree-wide: use consistent format of short comment for constant argument
Follow-ups for recent changes after 93378148d4.
2026-01-20 00:22:15 +09:00
Mike Yuan 5f90e4e4bc stat-util: O_NOCTTY is nop with O_PATH 2026-01-19 13:33:27 +01:00
Mike Yuan b0906b1216 stat-util: do not use RET_NERRNO for our own function
Follow-up for 95abe4beff
2026-01-19 13:33:27 +01:00
Mike Yuan 02bf2b7cdf fs-util: optimize xopenat(XAT_FDROOT, ...) a bit
Follow-up for ef582ab201

* Open / with O_PATH
* Shortcut to fd_reopen() directly if path is empty
2026-01-19 13:33:27 +01:00
Mike Yuan 9b906ae48e fs-util: group access_fd() with access_nofollow() 2026-01-19 13:33:27 +01:00
Mike Yuan 52bf232e82 fs-util: drop fallback for kernels without AT_EMPTY_PATH support (< 5.8) 2026-01-19 13:33:26 +01:00
Mike Yuan 6753bd8a2f mountpoint-util: assume MS_NOSYMFOLLOW is available
Since our kernel baseline is v5.10 now.
2026-01-19 13:33:26 +01:00
Mike Yuan 537045ec2f recurse-dir: remove stale comment
Follow-up for 6393b847f4
2026-01-19 03:06:30 +01:00
cyclopentane 465f6a6284 cryptenroll,cryptsetup,shutdown: only call mlockall if we have CAP_IPC_LOCK
Calling mlockall in an unprivileged process most notably had the effect
of making systemd-cryptenroll OOM while trying to open a normal-sized
argon2 keyslot due to it hitting RLIMIT_MEMLOCK.
2026-01-18 19:15:30 +01:00
Daan De Meyer 103f7d2303 fd-util: introduce XAT_FDROOT fd shortcut for the root dir (#39244) 2026-01-18 11:57:11 +01:00
Lennart Poettering 95abe4beff stat-util: write up XAT_FDROOT in stat-util.[ch] 2026-01-17 12:37:39 +01:00
Lennart Poettering c67abc9c43 chase: extend coverage of the root fd shortcut
Let's use dir_fd_is_root() to check if we are looking at the real root
fs.
2026-01-17 12:37:39 +01:00
Lennart Poettering ded2531764 chase: optimize the special case where no root dir specified
Now that we can recognize the root dir in chaseat() sanely, let's use it
top optimize the very common special case where we have no root dir to
consider, and directly call open_tree().
2026-01-17 12:37:39 +01:00
Lennart Poettering 874971b1c0 chase: wire up XAT_FDROOT 2026-01-17 12:37:39 +01:00
Lennart Poettering 5667cbcacf fd-util: wire up XAT_FDROOT in various really basic fd-util.h calls 2026-01-17 12:37:39 +01:00
Lennart Poettering ef582ab201 fs-util: wire up XAT_FDROOT in xopenat_full() and access_fd() 2026-01-17 12:37:33 +01:00
Lennart Poettering ee79c9d309 fd-util: introduce XAT_FDROOT fd shortcut for the root dir
This takes inspiration from AT_FDCWD, but always references the root dir
rather than the cwd. This allows various convenience uses, as we can now
reference the root dir without actually allocating an fd for chaseat(),
fd_get_path() and various others.

The value of XAT_FDROOT is chosen so that it is not a valid fd (essential,
because we do not intend to hook this up everywhere, just where we need
it, just like AT_FCWD only works in some syscalls), and we want uses at
the wrong places to fail cleanly. It also uses a valud outside of the
range where we usually return negative errnos, i.e. < -ERRNO_MAX.
2026-01-17 12:35:33 +01:00
Lennart Poettering e09b5366e5 string-util: accept ":" when stripping ANSI color sequences
Since 6eabe9f2ff we generate sequences
with ":", hence we better also know how to strip them.

(Without this patch we'd strip simple ANSI colors, but not RGB ones that
use ":" syntax).

(While we are at it, also drop a duplicate "0" in the list of valid
chars)
2026-01-17 12:07:36 +01:00
Lennart Poettering 24c315e911 ansi-color: convert one more ANSI sequence from ";" to ":" separators
This is a follow-up for 6eabe9f2ff where
one sequence was forgotten.
2026-01-17 12:07:05 +01:00
Yu Watanabe 2aa496312e conf-files: introduce CONF_FILES_WARN flag and set it at various places
Closes #40285.
2026-01-16 23:05:33 +09:00
Yu Watanabe 5d0dc9915c conf-files: make conf_file_new() take ConfFilesFlags rather than ChaseFlags
No functional change, preparation for later commit.
2026-01-16 23:01:04 +09:00
Yu Watanabe 0c109deda1 conf-files: use empty_to_root()
No functional change. For consistency with conf_file_chase_and_verify().
2026-01-16 23:01:04 +09:00
Yu Watanabe 4a8e0ea4ec conf-files: split out several helper functions from files_add()
No functional change, preparation for later commit.
2026-01-16 23:01:01 +09:00
Yu Watanabe fce7ad481b process-util: drop unnecessary E2BIG error handling
E2BIG is returned when the kernel does not support CLONE_INTO_CGROUP,
but the flag is supported since kernel v5.7.
2026-01-13 10:21:36 +09:00
Yu Watanabe d58c826c54 fd-util: drop close_all_fds_by_proc()
With the previous commit, now the function is used only on OOM.
In that case, let's do like close_all_fds_without_malloc().
2026-01-13 10:21:36 +09:00
Yu Watanabe c471cca093 fd-util: close_range() is available since kernel 5.9
Our baseline on kernel is 5.10, hence we can always use it.
2026-01-13 10:21:36 +09:00
Yu Watanabe d377cc5244 stat-util: STATX_TYPE and STATX_INO should be always set 2026-01-13 10:21:05 +09:00
Yu Watanabe 7ecfa87c56 fd-util,mountpoint-util: STATX_MNT_ID is supported since kernel 5.10
Our baseline on kernel is 5.10, hence we can assume it works.
2026-01-13 10:21:05 +09:00
Yu Watanabe 7f6cf19513 mountpoint-util: make is_mount_point_at() take usual dir_fd + path style arguments 2026-01-13 10:21:05 +09:00
Yu Watanabe a98a6eb95c tree-wide: statx() supports STATX_ATTR_MOUNT_ROOT since kernel 5.8
Our baseline on kernel is 5.10, hence we can unconditionally use it.
2026-01-13 10:21:04 +09:00
Yu Watanabe ec21e5c58e random-util: assume getrandom(GRND_INSECURE) works
GRND_INSECURE was added in kernel 5.6, and our baseline on kernel is
5.10. Let's assume it always works. Even if it does not work, we have
further fallback logics. So, this should be safe.
2026-01-13 10:21:04 +09:00
Yu Watanabe 1aeba33d8f Bump required minimum kernel version to 5.10 and the recommended baseline to 5.14.
The previous minimum required version 5.4 will be EOL on 2025-12.
Let's bump the required minimum kernel version to the next LTS release 5.10
(released on 2020-12-13, EOL on 2026-12, CIP support until 2031-01).

The new recommended baseline 5.14 is the version that CentOS 9 uses.
CentOS 9 will EOL on 2027-05.

See also #38608.
2026-01-13 10:21:04 +09:00
Luca Boccassi 986fee6217 Drop support for sysvinit scripts
As announced by a few releases now, finally drop support for
sysvinit scripts.
Keep rc-local generator for now, as it's really a distinct
feature even though from the same era.
2026-01-06 10:34:02 +01:00
Yu Watanabe 76ed202b7f compress: do not call lzma_end_wrapper() when failed to load liblzma
Fixes a bug in 3fc72d5413 (v256).
Fixes #40277.
2026-01-05 21:30:27 +09:00
Mike Yuan 429cbac508 idn: drop support for libidn
The current tree doesn't even compile with libidn(1) after
2c7bdaf9f1, which included
a non-existent call to check_dlopen_blocked() somehow.
Hence, it feels safe to just nuke legacy support from
our repo.
2026-01-05 21:29:52 +09:00
Zbigniew Jędrzejewski-Szmek 4a4be1015b inhibit: fix borked double logging on error
Previously, if execution failed, we'd log at error level both from the
child and the parent, and we were using a bogus variable for the argument
name:
$ build/systemd-inhibit list
Failed to execute : No such file or directory
list failed with exit status 1.

In general, we can and should assume that the program the user is calling
is well behaved, so it'll log the error on its own if appropriate. So we
shouldn't log on "normal errors", but only if the child is terminated by
a signal.

And since the program name is controlled by the user, use quotes everywhere
to avoid ambiguity.

Now:
$ build/systemd-inhibit false
(nothing)
$ build/systemd-inhibit bash -c 'kill -SEGV $$'
src/basic/process-util.c:895: 'bash' terminated by signal SEGV.
2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek 22aa8c4879 basic/process-util: reduce scope of variables 2026-01-04 14:07:57 +01:00
Zbigniew Jędrzejewski-Szmek 1ee73c884e basic/process-util: use synthetic errno in two more places 2026-01-04 14:07:57 +01:00
Yu Watanabe 30b9fa495c clang-tidy: Enable more warnings (#39910) 2026-01-03 06:00:30 +09:00
Daan De Meyer 52ecf376fa tree-wide: Migrate to pidref_safe_fork()
Let's migrate all remaining callers of safe_fork()
to pidref_safe_fork() and get rid of safe_fork().
2026-01-02 20:08:41 +01:00
Daan De Meyer e6703a9aa4 process-util: Use ret as output parameter name
There's only one output parameter for all these
functions, so let's just name it ret following the
coding style.
2026-01-02 19:44:18 +01:00
Daan De Meyer 1dcdb3e439 basic: Gate conditional includes behind ifdef 2026-01-02 09:39:32 +01:00
Daan De Meyer 18842be4be tree-wide: Various coding style cleanups 2026-01-02 09:22:59 +01:00
DaanDeMeyer 46e3fef1a8 tree-wide: Drop NOLINTNEXTLINE comments
Not needed anymore after recent refactoring.
2026-01-02 09:22:23 +01:00
DaanDeMeyer 47d22e41e4 unit-def: Clean up whitespace 2026-01-02 06:28:39 +09:00
Daan De Meyer aec52c1e6e string-table: Introduce DECLARE_STRING_TABLE_LOOKUP() and friends
Let's introduce these for the following two reasons:
- Using them makes sure the parameter names match between declaration
  and definition (if both use the corresponding macros).
- They make sure developers can't forget the _const_ and _pure_
  attributes for the declarations.

This commit also includes some include sorting fixes
2026-01-02 04:05:45 +09:00
Daan De Meyer daff8ea8bb tree-wide: Introduce DECLARE_TRIVIAL_REF_UNREF_FUNC() and friends 2026-01-02 04:04:19 +09:00
Lennart Poettering ceaa36c21e terminal-util: use the right ANSI ST sequence
There are multiple ways to encode ANSI ST, and we generally prefer ESC \
for it, for reasons explained in terminal-util.h. Hence, let's actually
follow this rule in the terminal reset logic, and use the ANSI_ST macro.

This will change the byte sequence generated (as it means we use ESC \
rather than BEL), but it doesn't change behaviour, as the two sequences
should be equivalent.
2025-12-24 09:40:43 +01:00
Jörg Behrmann 1afe5c7b4b terminal-util: also send ANSI_NORMAL in terminal_reset_ansi_seq
Certain terminal emulators (alacritty, ghostty and kitty) require ANSI_NORMAL
to be sent to reset the colours.

Followup for 3d97db8f3c.

Fixes: #40163
2025-12-24 07:59:42 +01:00