Commit Graph
7411 Commits
Author SHA1 Message Date
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
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
Luiz Amaral c1c787651b Add support for binding a unit to a network iface 2025-12-24 07:37:58 +01:00
Daan De Meyer 5b830eda79 signal-util: Use act instead of __act in comment
The clang-tidy check ignores trailing and
preceeding underscores, so let's just use act
instead of __act.
2025-12-21 19:21:08 +01:00
Lennart Poettering b6aa78f707 recursedir: introduce new RECURSE_DIR_UNLINK callback return value
This introduces RECURSE_DIR_UNLINK + RECURSE_DIR_UNLINK_GRACEFUL as new
return values for recurse_dir() callbacks. If either is returned the
inode currently processed will be removed and iteration continues with
the next item.

This is useful to have in the recurse_dir() mechanism itself (rather
than implement in the callback itself), due to ordering: we want to pin
the inodes via an fd while calling the callbacks, but we have to close
it before removal of the inodes. By moving this into the recurse_dir()
infra, we can implement this easily.
2025-12-21 07:04:42 +01:00
Mike Yuan f3c6660b9c pidref: several follow-ups for pidref_wait_for_terminate_full()
Follow-up for e74b571004

* Do not reuse si
* Refuse timeout == 0
* Use usec_add()
* Rename ret to ret_si - unlike others this one is not so obvious
2025-12-20 21:41:01 +01:00
Mike Yuan eb17c37df7 process-util: drop unused sched_priority_is_valid() 2025-12-20 18:38:56 +01:00
Matt Fleming 4dcbfbb1ad process-util: Add support SCHED_EXT scheduling policy
Allow CPUSchedulingPolicy to be set to "ext". SCHED_EXT is a new
scheduling policy in Linux v6.12 that allows processes to be scheduled
using custom BPF schedulers instead of the default in-kernel ones.

Selectively setting the SCHED_EXT policy is useful for systems running
in "partial mode" where not all processes are run using a custom
scheduler.

Fallback to SCHED_OTHER and print an error message for systems where
SCHED_EXT isn't available.
2025-12-20 18:31:55 +01:00
Daan De Meyer fbd276cb86 tree-wide: Use pidref_wait_for_terminate_and_check()
Let's use the pidref variants for waiting and
checking a process everywhere and get rid of the
non pidref variants.
2025-12-20 15:50:47 +01:00
Daan De Meyer e74b571004 pidref: Add pidref_wait_for_terminate_full()
We can use this to replace wait_for_terminate_with_timeout(). Because
we poll a pidfd, we don't need to block SIGCHLD anymore in umount.c.
2025-12-20 15:49:26 +01:00
Daan De Meyer 8c367868ee process-util: Use pidref_wait_for_terminate_and_check in pidref_safe_fork()
Note that we still have to block SIGCHLD so that
we can be certain the process is not reaped before
we get the pidfd to it. safe_fork() and friends are
used in libsystemd where we don't control how the
SIGCHLD signal is configured. Specifically, kernel
autoreaping could be enabled which is why we have
to block SIGCHLD until we get the pidfd so that the
kernel cannot autoreap the process before we get
the pidfd.
2025-12-20 15:44:20 +01:00
Daan De Meyer a1e5d7f865 sd-event: Clean up SIGCHLD conditions for sd_event_add_child()
First, don't require blocking SIGCHLD for WEXITED. We watch for WEXITED
via pidfd instead of signalfd, so no need to insist on blocking SIGCHLD
anymore if we're only watching for WEXITED.

Second, do a proper check to see if the kernel autoreaping logic is
enabled. That has nothing to do with SIGCHLD being blocked for the current
thread or not. Instead, the kernel autoreaping logic is enabled either if
the disposition is set to SIG_IGN or if the SA_NOCLDWAIT flag is enabled.
2025-12-20 15:27:22 +01:00
Mike Yuan 73c40aa1f6 process-util: synchronously wait for namespace_enter() before returning
Additionally, report actual errors using errno pipe too.
2025-12-20 14:27:46 +01:00
Mike Yuan ed0f6758c8 process-util: revamp flags handling in namespace_fork()
* Specifying all 3 of FORK_DEATHSIG_SIG{KILL,TERM,INT} for
  the middle man makes zero sense. Use SIGKILL only.
* Make sure operations on except_fds work sensibly - close/pack/
  de-ocloexecify fds only in the second level, so that the namespace
  fds remain usable across first safe_fork().
* Fire FORK_NEW_*NS after attaching to the desired namespaces,
  not already in the outer process.
* Insist on PDEATHSIG being enabled to ensure propagation of killing.
* Suppress more redundant flags.
2025-12-20 14:14:24 +01:00
Daan De MeyerandMike Yuan 8c007f68ff process-util: Migrate namespace_fork() to PidRef
Co-authored-by: Mike Yuan <me@yhndnzj.com>
2025-12-20 13:45:22 +01:00
Mike Yuan 3532691d72 process-util: trivial cleanup for read_errno() 2025-12-20 13:45:22 +01:00
Mike Yuan e48e098db1 process-util: dedup restore_sigsetp() with block_signals_reset() 2025-12-20 13:45:21 +01:00
Lennart Poettering 627e583c64 Use ANSI CSI 18 to query console size (#39833) 2025-12-18 20:49:26 +01:00
Daan De Meyer 30465f789c test: introduce test-sleep and use it in several integration tests (#40086) 2025-12-18 17:47:57 +01:00