Commit Graph

5678 Commits

Author SHA1 Message Date
Luca Boccassi
055ca3cd0a Merge pull request #29644 from poettering/json-iovec
add iovec/base64 json helpers and other iovec tweaks
2023-10-20 15:54:29 +01:00
Daan De Meyer
26204e1a4a Merge pull request #29630 from DaanDeMeyer/manager-json
Various refactoring in preparation for adding JSON dump to pid 1
2023-10-20 16:42:12 +02:00
Luca Boccassi
f455365031 Merge pull request #29626 from bluca/auto_soft_reboot
systemctl: automatically softreboot/kexec if set up on reboot
2023-10-20 13:46:46 +01:00
Lennart Poettering
3a856171c2 iovec-util: add some useful helpers for dealing with iovecs that refer to dynamic memory 2023-10-20 14:38:16 +02:00
Daan De Meyer
b2e9d80956 hashmap: Add extra uncounted entry to returned array from hashmap_dump_sorted()
This allows using the returned array as a strv.
2023-10-20 14:09:32 +02:00
Daan De Meyer
1b17dd9099 Add unit_type_to_capitalized_string() 2023-10-20 13:30:11 +02:00
Luca Boccassi
beea591742 Merge pull request #29627 from poettering/io-split
split up io-util.[ch], and some clean-ups
2023-10-20 12:19:22 +01:00
Luca Boccassi
665a3d6d15 systemctl: automatically softreboot/kexec if set up on reboot
Automatically softreboot if the nextroot has been set up with an OS
tree, or automatically kexec if a kernel has been loaded with kexec
--load.

Add SYSTEMCTL_SKIP_AUTO_KEXEC and SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT to
skip the automated switchover.
2023-10-20 11:45:37 +01:00
Luca Boccassi
ed51ccf4b8 Merge pull request #29618 from bonktree/fchmodat2
seccomp: get `fchmodat2(2)` covered by `RestrictSUIDSGID=`
2023-10-20 10:49:46 +01:00
Lennart Poettering
ea1f38146a io-util: split out iovw_xyz into iovec-wrapper.h
Let's split these APIs out, they are kinda their own thing.
2023-10-20 10:43:50 +02:00
Lennart Poettering
986235a99a iovec-util: make IOVEC_INCREMENT a regular function too
Even more than with the previous commit, this is not a trivial function
and there's no reason to believe this will actually be inlined nor that
it would be beneficial.
2023-10-20 10:43:50 +02:00
Lennart Poettering
9599ea28b4 iovec-util: make IOVEC_MAKE_STRING() safer
Let's not accept arbitrary types, but only char* and const char*.
2023-10-20 10:43:50 +02:00
Lennart Poettering
e2a3bb22c8 iovec-util: make IOVEC_NULL const
compound initialized structs can be placed im immutable memory if const,
hence there's benefit in making this one const too
2023-10-20 10:43:50 +02:00
Lennart Poettering
c24e0dbea1 iovec-util: make IOVEC_TOTAL_SIZE() a regular function
The function isn't necessarily fast (it's O(n)), and there's no reason
to have it defined as inline function, since it's neither fast, nor
entirely trivial.
2023-10-20 10:43:50 +02:00
Lennart Poettering
bd1ae17833 io-util: split out "struct iovec" related calls into their own .c/.h files
This is preparation for #28891, which adds a bunch more helpers around
"struct iovec", at which point this really deserves its own .c/.h file.

The idea is that we sooner or later can consider "struct iovec" as an
entirely generic mechanism to reference some binary blob, and is the
go-to type for this purpose whenever we need one.
2023-10-20 10:34:33 +02:00
Lennart Poettering
9bb64f1b8d pidref: make PIDREF_NULL const
That way compiler can put it in an immutable section
2023-10-19 18:59:51 +01:00
Mike Yuan
f65a40fb0b cgroup-util: use RET_GATHER more, return first error 2023-10-19 21:37:33 +08:00
Yu Watanabe
be3b6b6fe5 cgroup-util: drop dead code block
Follow-up for 4d1b2df199.

Fixes CID#1522888.
2023-10-19 20:24:54 +08:00
Arseny Maslennikov
3677364cc3 basic/missing_syscall: generate defs for fchmodat2(2)
We will need this to set seccomp filters on this system call regardless
of libseccomp or kernel support.
2023-10-19 14:07:54 +03:00
Arseny Maslennikov
c83f838193 Update system call tables for Linux 6.6
We are doing this to obtain the definition of fchmodat2.
2023-10-19 14:07:54 +03:00
Lennart Poettering
81c1c387fe Merge pull request #29594 from poettering/cgroup-rename-ret-params
more pidfdification
2023-10-18 17:25:44 +02:00
Lennart Poettering
2d79017564 killall: port killing spree loop over to PidRef 2023-10-18 14:49:40 +02:00
Lennart Poettering
eefb7d22ce process-util: add API for enumerating processes in /proc/ and pinning them via PidRef 2023-10-18 14:49:40 +02:00
Lennart Poettering
4d9f092b5e process-util: add pidref_is_unwaited() and make pid_is_unwaited() return errors 2023-10-18 14:49:40 +02:00
Lennart Poettering
6774be4206 process-util: add pidref_is_my_child() 2023-10-18 14:49:40 +02:00
Lennart Poettering
becdfcb9f1 process-util: change pid_is_alive() to not eat up errors, and add pidref_is_alive()
Let's no eat up errors, but propagate unexpected ones.
2023-10-18 14:40:25 +02:00
Lennart Poettering
8b51341545 process-util: add pidref_get_uid() and rename get_process_uid() → pidref_get_uid() 2023-10-18 14:39:33 +02:00
Lennart Poettering
4d1b2df199 core: port unit/process kill logic to pidref 2023-10-18 14:39:33 +02:00
Lennart Poettering
a7a877697f pidref: add new pidref_is_self() helper
This simply checks if the specified PidRef refers to the process we are
running in.

(In case you wonder why this is not a static inline: to avoid cyclic
header inclusion problems between pidref.h + process-util.h)
2023-10-18 14:39:33 +02:00
Lennart Poettering
d7d748548b process-util: add pidref_get_comm() and rename get_process_comm() to pid_get_comm() 2023-10-18 14:39:33 +02:00
Lennart Poettering
fc87713bed process-util: add pidref_is_kernel_thread() 2023-10-18 14:39:33 +02:00
Lennart Poettering
a034620f1a process-util: add pidref_get_cmdline() 2023-10-18 14:39:33 +02:00
Lennart Poettering
3d7ba61a7b pidref: we never have to verify PID 1
The process exists as long as the kernel/userns exists at all, hence we
don't have to verify a pidfd to it.
2023-10-18 14:39:33 +02:00
Lennart Poettering
f2a2e60be6 cgroup-util: make cg_pidref_get_path() PidRef parameter const 2023-10-18 14:39:33 +02:00
Lennart Poettering
44c55e5a3f pidref: make signal sending calls take const PidRef 2023-10-18 14:38:07 +02:00
Lennart Poettering
cf45db5598 fd-util: use close_many() where appropriate 2023-10-18 14:03:47 +02:00
Lennart Poettering
d3eb74f8f8 fd-util: add new helper close_many_unset() 2023-10-18 14:03:36 +02:00
Lennart Poettering
3b444970e6 serialize: add serialize_fd_many() helper 2023-10-18 13:51:02 +02:00
Lennart Poettering
bd389293f0 pidref: make pidref_verify() parameter const 2023-10-18 10:32:03 +02:00
Lennart Poettering
820fe745c7 cgroup-util: rename all return parameters in cgroup-util to ret_xyz 2023-10-18 10:02:43 +02:00
Lennart Poettering
0ff6ff2b29 tree-wide: port various parsers over to read_stripped_line() 2023-10-17 14:36:54 +02:00
Lennart Poettering
c56cb33f09 fileio: add read_stripped_line() as trivial read_line() + strstrip() combo 2023-10-17 14:36:54 +02:00
Lennart Poettering
cde8cc946b Merge pull request #29272 from enr0n/coredump-container
coredump: support forwarding coredumps to containers
2023-10-16 16:13:16 +02:00
Luca Boccassi
7c83d42ef8 mount-util: use mount beneath to replace previous namespace mount
Instead of mounting over, do an atomic swap using mount beneath, if
available. This way assets can be mounted again and again (e.g.:
updates) without leaking mounts.
2023-10-16 14:33:47 +01:00
Luca Boccassi
0e3986bc1c Merge pull request #29525 from poettering/confext-sysext-multimodal
dissect: make sure we can dissect and inspect DDIs that are both confext *and* sysext
2023-10-14 00:28:47 +01:00
Luca Boccassi
ccba67f494 Merge pull request #27890 from bluca/executor
core: add systemd-executor binary
2023-10-13 22:01:16 +01:00
Nick Rosbrook
ade39d9ab8 process-util: introduce namespace_get_leader helper
For a given PID and namespace type, this helper function gives the PID
of the leader of the namespace containing the given PID. Use this in
systemd-coredump instead of using the existing get_mount_namespace_leader.

This helper will be used again in a later commit.
2023-10-13 15:13:11 -04:00
Nick Rosbrook
6cf96ab456 core: add CoredumpReceive= setting
This setting indicates that the given unit wants to receive coredumps
for processes that crash within the cgroup of this unit. This setting
requires that Delegate= is also true, and therefore is only available
where Delegate= is available.

This will be used by systemd-coredump to support forwarding coredumps to
containers.
2023-10-13 15:13:11 -04:00
Nick Rosbrook
b426b4eed8 cgroup-util: add cg_is_delegated helper
Take is_delegated from cgroup-show.c, and make it a generic helper
function. This new helper will be used again in a later commit.
2023-10-13 15:13:11 -04:00
Luca Boccassi
5986e3f4db Merge pull request #29502 from keszybz/sd-boot-config-tweaks
Tweaks to sd-boot UX
2023-10-12 23:08:56 +01:00