Lennart Poettering
adcc805929
namespace-util: return recognizable error if namespace_open_by_type() fails because ns type not supported
...
This makes sure the the codepath that derives an nsfd from a pid works
the same for the pidfd case and the non-pidfd case: if we can verify
that /proc/ is mounted but the /proc/$PID/ns/ files are missing, we can
assume the ns type is not supported by the kernel. Hence return the same
ENOPKG error in this case as we already do in the pidfd ioctl based
codepath.
2025-01-07 23:51:28 +01:00
Mike Yuan
16ac586e5a
Bump minimum kernel baseline to 5.4, recommended version to 5.7
...
As requested, a list of kernel version to feature mapping
for kernels older than minimum baseline is also included,
in order to ease potential backport work.
2025-01-07 22:43:45 +01:00
Lennart Poettering
56a07d10a5
xopenat(): introduce new XO_REGULAR flag ( #35834 )
...
This is something I think we should have added a long time ago: a
flavour of open() that safely ensures the inode we are opening is a
regular file, before we open it. It does this by means of pinning the
inode via O_PATH first, and after verification actually opening it.
This ports some code over to this, but sooner or later we should
probably use this a lot more, so that we don't accidentally open weird
stuff such as device nodes or pipes, where we should not.
2025-01-07 08:55:56 +01:00
Lennart Poettering
9ed2725867
process-util: a process from a foreign pidns is definitely not our child
...
Addresses: https://github.com/systemd/systemd/pull/35242#pullrequestreview-2531712318
2025-01-07 08:55:21 +01:00
Yu Watanabe
62e9cd6b09
basic/linux: update kernel headers from v6.13-rc6
...
This also removes README and moves the explanation about the header
modification to the script.
2025-01-06 23:35:14 +00:00
Lennart Poettering
dffafa47ae
fs-util: add XO_REGULAR flag for xopenat()
...
If this flag is set we guarantee that the fd returned refers to a
regular file. If the file exists and is not one, fails.
2025-01-06 23:20:09 +01:00
Lennart Poettering
336acebc77
basic: port various pidfd/pidref helpers to PIDFD_GET_INFO and PIDFD_GET_*_NAMESPACE ( #35242 )
...
Supersedes #35308 (cherry-picked one commit and replaced the rest)
(I left a few comments that's folded by GitHub. Please make sure to
check them too.)
2025-01-06 11:23:08 +01:00
Lennart Poettering
7f72184f12
more pidref'ification ( #35839 )
...
This is split out of #35264 , but makes a ton of sense on its own.
2025-01-06 11:21:43 +01:00
Lennart Poettering
dd445d6e99
cgroup-util: add remoteness checks to all cg_pidref_get_xyz() calls
2025-01-06 09:54:41 +01:00
Lennart Poettering
92d78966fd
cgroup-util: add pidref counterparts for cg_pid_get_session() + cg_pid_get_owner_uid()
2025-01-06 09:54:41 +01:00
Lennart Poettering
b2206fe514
socket-util: introduce getpeerpidref()
...
This combines getpeercred() and getpeerpidfd() and returns a PidRef
2025-01-06 09:45:57 +01:00
Mike Yuan
9598708a12
cgroup-util: explain why cg_pidref_get_path() cannot be ported over to pidfd helpers (yet)
...
See also: https://github.com/systemd/systemd/pull/35242#issuecomment-2506686806
2025-01-04 17:48:23 +01:00
Mike Yuan
f1ba5c900b
cgroup-util: introduce generic cg_path_from_cgroupid() helper
...
Taken from nsresourced/userns-registry.c userns_destroy_cgroup()
2025-01-04 17:48:22 +01:00
Mike Yuan
223d455670
process-util: make pid_is_unwaited() wrapper around pidref version
2025-01-04 17:48:22 +01:00
Mike Yuan
47f64104d1
process-util: port pidref_get_uid() and pidref_is_my_child() to pidfd helpers
2025-01-04 17:48:22 +01:00
Mike Yuan
85e7bbfaa4
pidfd-util: introduce pidfd_get_{ppid,uid,cgroupid} which goes via PIDFD_GET_INFO too
2025-01-04 17:08:01 +01:00
Mike Yuan
dcf0ef3f42
pidfd-util: try to translate pidfd -> pid through ioctl(PIDFD_GET_INFO)
2025-01-04 17:08:01 +01:00
Mike Yuan
92b8e5e72f
namespace-util: introduce pidref_in_same_namespace()
2025-01-04 17:08:01 +01:00
Mike Yuan
a33f691374
process-util: move namespace_get_leader() to namespace-util
...
This allows us to drop the hack for recursive includes.
2025-01-04 17:08:00 +01:00
Mike Yuan
4cad58788b
namespace-util: hook pidref_namespace_open() up with pidfd_get_namespace()
...
Supersedes #35308
2025-01-04 17:08:00 +01:00
Mike Yuan
2f7cd6c70a
namespace-util: correct assertion in namespace_is_init()
...
Follow-up for 18ead2b03d
2025-01-04 17:07:59 +01:00
Mike Yuan
07610cafcf
namespace-util: modernize fd_is_namespace() and is_our_namespace()
...
- Make fd_is_namespace() take NamespaceType
- Drop support for kernel without NS_GET_NSTYPE (< 4.11)
- Port is_our_namespace() to namespace_open_by_type()
(preparation for later commits, where the latter
would go by pidfd if available, avoiding procfs)
2025-01-04 17:07:59 +01:00
Yu Watanabe
1775337a36
namespace-util: refuse remote pidref in pidref_namespace_open()
2025-01-04 17:07:59 +01:00
Mike Yuan
72661e0091
pidfd-util: introduce helper for obtaining ns fd using PIDFD_GET_*_NAMESPACE directly
2025-01-04 17:07:59 +01:00
Mike Yuan
9a7b20b6a6
errno-util: add ERRNO_IS_IOCTL_NOT_SUPPORTED that checks EINVAL additionally
2025-01-04 17:07:58 +01:00
Mike Yuan
2fa42318c3
pidref: move generic pidfd_get_inode_id() to pidfd-util
...
Prompted by https://github.com/systemd/systemd/pull/35224/commits/221d6e54c60389f26c2c79dbfa4e83204d2775d7
Also generalize pidfd_check_pidfs() and expose have_pidfs for later use.
2025-01-04 17:07:58 +01:00
Mike Yuan
ebddfb0dee
basic: introduce missing_pidfd.h
2025-01-04 16:58:13 +01:00
Mike Yuan
b234026d09
process-util: extract pidfd-related funcs into pidfd-util.[ch]
2025-01-04 16:58:13 +01:00
Mike Yuan
5734893f82
tree-wide: make sigactions static const
2025-01-04 16:40:53 +01:00
Mike Yuan
bed4386e29
signal-util: generalize sigaction_nop_nocldstop
2025-01-04 16:40:53 +01:00
Lennart Poettering
57e55f93bb
terminal-util: modernize vtnr_from_tty() a bit
2025-01-03 21:05:58 +01:00
Daan De Meyer
d0d647e084
Introduce systemd-pty-forward ( #35761 )
...
This allows running a command with tinted terminal background.
2025-01-03 19:34:42 +01:00
Lennart Poettering
8beb8c3e35
fs-util: teach xopenat_full() to pick automatically if given as MODE_INVALID
2025-01-03 12:58:43 +01:00
Daan De Meyer
9fbecf12fb
tree-wide: Rename ret_slave to ret_peer
2025-01-03 09:28:13 +01:00
Daan De Meyer
de8466e436
random-util: our baseline includes getrandom() (v3.17) now ( #35816 )
2025-01-03 09:23:06 +01:00
Mike Yuan
1de1282320
terminal-util: introduce terminal_{new,detach}_session helpers
...
Prompted by #35761
2025-01-02 21:14:38 +01:00
Mike Yuan
217bd588c2
terminal-util: regroup some functions
2025-01-02 20:42:20 +01:00
Mike Yuan
c439bd25ca
random-util: our baseline includes getrandom() (v3.17) now
...
Plus, linux/random.h never defined getrandom(), hence remove
the custom machinery for sys/random.h vs linux/random.h
in favor of single HAVE_GETRANDOM.
2025-01-02 20:40:45 +01:00
Mike Yuan
2627cd1343
random-util: drop needless conditionalization of sys/auxv.h
...
We assume its existence in basic/build-path.c, shared/userdb.c,
and coredump/coredump.c already, for which nothing has been reported
so far. So this seems safe to drop.
2025-01-02 20:34:21 +01:00
Mike Yuan
aad028e187
missing_syscall: mandate __NR_memfd_create
...
Follow-up for 6db5a6e799
For basic system functionality we require memfd nowadays,
so fail the build if syscall number not available.
2025-01-02 20:34:20 +01:00
Lennart Poettering
ed8e7e2393
core/socket: several fixlets ( #35637 )
...
Fixes https://github.com/systemd/systemd/issues/35635
2025-01-02 18:20:48 +01:00
Mike Yuan
03ccee1939
errno-list: prefer strerrorname_np() as errno_to_name() provider
2025-01-02 12:01:53 +01:00
Mike Yuan
58a86a1504
core/socket: introduce intermediate SOCKET_START_OPEN state
...
Prior to this commit, if no Exec*= is defined for socket,
and the unit was in SOCKET_FAILED state, failure of socket_open_fds()
would induce state transition SOCKET_FAILED -> SOCKET_FAILED,
and OnFailure= deps get unexpectedly skipped. Let's introduce
an intermediate state, so that during unit start we enter
UNIT_ACTIVATING at least once.
Fixes #35635
2024-12-31 00:22:52 +01:00
Mike Yuan
90761f7f68
basic/recurse-dir: modernize readdir_all()
2024-12-30 23:52:19 +01:00
Mike Yuan
1e4e557262
tree-wide: replace FLAGS_SET(..., 1 << v) with BIT_SET(..., v)
2024-12-28 15:08:00 +01:00
Mike Yuan
6f3854fd63
capability-util: make CAPABILITY_QUINTET_NULL const, introduce capability_quintet_is_fully_set() helper
...
Follow-up for 1184626a26
See 9bb64f1b8d for rationale
of the first change.
2024-12-28 15:08:00 +01:00
Mike Yuan
d5e12dc75e
capability-util: minor modernizations
2024-12-28 15:08:00 +01:00
Yu Watanabe
ac3f3026a9
string-util: modernize split_pair()
...
- use _cleanup_free_ attribute,
- rename output arguments,
- trigger assertion when an empty separator is passed.
2024-12-28 16:16:27 +09:00
Mike Yuan
c415a4816c
tree-wide: drop inclusion of linux/memfd.h
...
We carry our own definitions in missing_mman.h, and otherwise
sys/mman.h is employed. Let's drop the unneeded detection/inclusion
of linux/memfd.h hence.
2024-12-24 16:56:21 +01:00
Mike Yuan
3ac386de0a
basic/missing_threads: drop glibc < 2.16 check
...
glibc 2.16 has been our baseline for ~10y
(c.f. 3dd26f3e3a )
2024-12-24 16:55:21 +01:00