Commit Graph
6832 Commits
Author SHA1 Message Date
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
Yu Watanabe 5f29c86ace audit-util: rename output parameter
To make them consistent with in audit-util.c.

Follow-up for 7e02ee98d8.
2024-12-20 09:37:25 +01:00
Yu Watanabe 8a135111ca capability-util: generalize helper to acquire local caps (#35403)
This generalizes and modernizes the code to acquire set of local caps,
based on the code for this in the condition logic. Uses PidRef, and
acquires the full quintuplet of caps.

This can be considered preparation to one day maybe build without
libcap.
2024-12-20 11:52:24 +09:00
Lennart Poettering 9aee971185 tree-wide: use pidref_is_self() at more places 2024-12-18 13:34:35 +01:00
Lennart Poettering 25b1a73f71 journald: get rid of get_process_capeff(), use pidref_get_capability() instead
This does pretty much the same, but is nicer, since it parses things
properly.
2024-12-17 19:06:54 +01:00
Lennart Poettering a5370d35d6 capability-util: introduce capability_is_set() helper 2024-12-17 19:06:54 +01:00
Lennart Poettering 1184626a26 capability-util: generalize helper to acquire local caps
This generalizes and modernizes the code to acquire set of local caps,
based on the code for this in the condition logic. Uses PidRef, and
acquires the full quintuplet of caps.

This can be considered preparation to one day maybe build without
libcap.
2024-12-17 19:06:54 +01:00
Lennart Poettering 4dac692094 fuzz-journal-remote: use memfd_new_and_seal() where appropriate
This means we can drop memfd_new_and_map() and results in generally
shorter code.
2024-12-17 18:26:15 +01:00