1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00
Commit Graph

65746 Commits

Author SHA1 Message Date
Lennart Poettering
f7bccef178 automont: rework expiry to use subprocess rather than thread
One more step towards a thread-free PID1: let's do automount expiry in a
subprocess rather than a thread.
2023-06-23 10:02:15 +02:00
Lennart Poettering
01ab446c35 basic: add comments about raw_clone() calls not supporting threads/malloc in child 2023-06-23 10:02:15 +02:00
Lennart Poettering
c26d7837bb async: stop using threads for asynchronous_close()
Let's work towards PID1 being purely single threaded again. Let's rework
asynchronous_close() on top of clone() with CLONE_FILES (so that we
can manipulate PID1's fd table correctly).

One less use of pthread_create() in PID 1.
2023-06-23 10:00:30 +02:00
Lennart Poettering
29c3520f28 process-util: add clone_with_nested_stack() helper
This wraps glibc's clone() but deals with the 'stack' parameter in a
sensible way. Only supports invocations without CLONE_VM, i.e. when
child is a CoW copy of parent.
2023-06-23 10:00:30 +02:00
Lennart Poettering
09f9530baf process-util: add helper that detects if we are a reaper process 2023-06-23 10:00:30 +02:00
Lennart Poettering
da3cd87ab4
Merge pull request #28129 from poettering/userdb-ratelimit
userdbd: make sure we don't exit under pressure
2023-06-23 09:53:21 +02:00
Lennart Poettering
e6421b6ccd man: correct and extend JournalSizeMax=
The man page claimed the default was 10M, but that's not true, it's
767M.

Also mention there's no point in increasing it further.

See: #26748
2023-06-23 09:49:41 +02:00
Lennart Poettering
4a78074fc1 coredump: clamp JournalSizeMax= to maximum journald would accept
See: #26748
2023-06-23 09:45:50 +02:00
Lennart Poettering
a73c74db66 coredump: use loop_read() for reading coredump into memory
Fixes: #26748
2023-06-23 09:38:12 +02:00
Lennart Poettering
6270b2e67e tpm2-util: look for tpm2-pcr-signature.json directly in /.extra/
So far we relied on tmpfiles.d to copy tpm2-pcr-signature.json from
/.extra/ into /run/systemd/. This is racy however if cryptsetup runs too
early, and we cannot unconditionally run it after tmpfiles completed.

hence, let's teach cryptsetup to directly look for the file in /.extra/,
in order to simplify this, and remove the race. But do so only in the
initrd (as only there /.extra/ is a concept).

We generally prefer looking in /run/systemd/, since things are under
user control then. In the regular system we exclusively want that
userspace looks there.

Fixes: #26490
2023-06-23 09:32:33 +02:00
Yu Watanabe
b62e2891ef copy: propagate error in fd_copy_directory()
Follow-up for 01428141ba.

Fixes CID#1513190.
2023-06-23 10:11:17 +09:00
Yu Watanabe
440ccf0424 copy: fix fd leak
Follow-up for 01428141ba.
2023-06-23 10:11:06 +09:00
Yu Watanabe
dcd407b5e7 copy: add one more assertions about copy_flags
Follow-up for 01428141ba.
2023-06-23 10:07:38 +09:00
Lennart Poettering
19b761a097 tree-wide: getpid() → getpid_cached()
This doesn't really matter, but let's be systematic and prefer
getpid_cached() in our codebase.
2023-06-22 17:07:59 -06:00
Lennart Poettering
2543deada3 userdbd: when we hit a flood of requests to start more workers, don't exit
Let's tweak what we do if we detect a flood of requests to start more
workers: if none of the workers ever sticks (i.e. the worker count is
zero) then let's just give up, as before.

Otherwise, let's just not start more workers for a while, and do so
again after a while. Thus spawning ofr workers will "cool off" for a
while.

Fixes: #27028
2023-06-22 18:59:24 +02:00
Lennart Poettering
3ef0103f22 userdbd: prefix parameters with their names more 2023-06-22 18:58:31 +02:00
Lennart Poettering
c659d0f55e userdbd: drastically raise ratelimit we apply on requests for more worker processes
These requests might come in during lookup floods very quickly, since
multiple worker processes might detect that things should be scaled up
at the same time. Hence, let's substantially raise the limit so that it
doesn't get hit in real-life scenarios and acts more like a safety net.
2023-06-22 18:57:30 +02:00
Yu Watanabe
742aebc5a7 meson: merge two similar loops for unit files
This also merges two arrays units and in_units, and uses dictionary
for declaring units.

This also fixes the condition handling, that previously only two
conditions were handled and rests were ignored.
2023-06-22 10:19:51 -06:00
Lennart Poettering
7e81ce6bb8 docs: describe $TESTFUNCS briefly
Follow-up for f1a83e41ae
2023-06-22 15:14:47 +01:00
Lennart Poettering
f1a83e41ae tests: teach tests boilerplate to run selected tests only
sometimes its useful to only run a specific test (or multiple) instead
of all implemented in a test. Allow the test name(s) to be specified on the
in a $TESTFUNCS env var, separated by colons.
2023-06-22 16:07:57 +02:00
Lennart Poettering
58373cebb8
Merge pull request #28104 from DaanDeMeyer/emergency-kexec-halt
core: Add halt and kexec emergency actions
2023-06-22 16:07:35 +02:00
Daan De Meyer
4638e18593 hwdb: Don't generate hwdb if no hwdb files are found 2023-06-22 16:07:22 +02:00
Lennart Poettering
947c4d3952 core: restrict ImportCredential= globbing
Let's restrict how we apply credential globbing in ImportCredential=, so
that we have some flexibility in automatically extending the glob
expression with per-instance data eventually without getting into
conflict with the globbing parts.

In our current uses we only allow globbing at the end of the expression,
and this is a new, unreleased feature hence let's be restrictive on this
initially. We can still relax this later if we feel the need to after
all.

Fixes: #28022
2023-06-22 16:07:09 +02:00
Lennart Poettering
54c0ba3409 pid1: use FORK_DEATHSIG where appropriate 2023-06-22 16:05:37 +02:00
Jan Luebbe
173d47f788 man: correct reference to sd_id128_get_boot_app_specific
The function sd_id128_get_boot_app_specific is the app specific variant of
sd_id128_get_boot.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
2023-06-22 12:34:00 +01:00
Daan De Meyer
c9c9e87b80
Merge pull request #28115 from yuwata/meson-tiny-fixes
meson: several tiny fixes
2023-06-22 11:49:36 +02:00
Daan De Meyer
9a0eade760 units: Use built-in halt and kexec features instead of systemctl 2023-06-22 10:33:18 +01:00
Daan De Meyer
3cf848f6cd core: Add halt and kexec emergency actions
Let's complete the picture by adding the missing halt and kexec
emergency actions.
2023-06-22 10:33:13 +01:00
Lennart Poettering
665ca08b6e sleep-util: mention that offset is in memory pages 2023-06-22 10:30:23 +02:00
Franck Bui
e538927918 rpm: fix lua trigger priority for sysusers
Commit cd621954ed probably forgot to fix the lua
implementation.
2023-06-22 16:18:01 +09:00
Yu Watanabe
4251512ea9 time-util: introduce usleep_safe()
We use usec_t for storing time value, which is 64bit.
However, usleep() takes useconds_t that is (typically?) 32bit.
Also, usleep() may only support the range [0, 1000000].

This introduce usleep_safe() which takes usec_t.
2023-06-22 15:33:56 +09:00
Yu Watanabe
a100936847 test: check size detections by meson 2023-06-22 15:24:57 +09:00
Yu Watanabe
84d953e87a meson: sort types 2023-06-22 15:24:57 +09:00
Yu Watanabe
c20d291416 meson: fix test dependency
Follow-up for daf4e78e48.
2023-06-22 14:37:45 +09:00
Yu Watanabe
1782534bb1 meson: shorten code a bit 2023-06-22 14:37:24 +09:00
Yu Watanabe
e04e42312d meson: drop wrong and redundant assignment
Follow-up for b62ee354dd.
2023-06-22 14:20:32 +09:00
Yu Watanabe
d37dee7450 meson: also build symbol tests for static-libsystemd=no-pic 2023-06-22 14:20:32 +09:00
Yu Watanabe
67b1c943cb meson: add dependency for udev runner to test 2023-06-22 14:20:32 +09:00
Yu Watanabe
50cf2032a0 sd-journal: verify journal file header in more detail
Fixes #27635.
2023-06-21 18:25:07 -06:00
Zbigniew Jędrzejewski-Szmek
27ccba2621 pam: add macro wrapper to make code shorter
The same pattern is repeated so many times that it seems worth making a
shorthand for it.

Follow-up for f71b55b510 and
2675747f3c.
2023-06-22 00:47:32 +01:00
Luca Boccassi
0b1e55a616
Merge pull request #28109 from mrc0mmand/more-journal-shenanigans
test: cover a couple of missed code paths in journalctl/journald
2023-06-22 00:46:06 +01:00
Ronan Pigott
f24590df43 systemd-analyze: allow --quiet for condition checks
I figure these messages are rather unnecessary, so let the user quiet
them with the existing --quiet flag if desired. Makes systemd-analyze
condition a little more ergonomic in scripts.
2023-06-21 19:56:43 +01:00
Romain Geissler
21a2c735e2 elf-util: discard PT_LOAD segment early based on the start address.
Indeed when iterating over all the PT_LOAD segment of the core dump
while trying to look for the elf headers of a given module, we iterate
over them all and try to use the first one for which we can parse a
package metadata, but the start address is never taken into account,
so absolutely nothing guarantees we actually parse the right ELF header
of the right module we are currently iterating on.

This was tested like this:
 - Create a core dump using sleep on a fedora 37 container, with an
   explicit LD_PRELOAD of a library having a valid package metadata:

    podman run -t -i --rm -v $(pwd):$(pwd) -w $(pwd) fedora:37 bash -x -c \
        'LD_PRELOAD=libreadline.so.8 sleep 1000 & SLEEP_PID="$!" && sleep 1 && kill -11 "${SLEEP_PID}" && mv "core.${SLEEP_PID}" the-core'

 - Then from a fedora 38 container with systemd installed, the resulting
   core dump has been passed to systemd-coredump with and without this
   patch. Without this patch, we get:

       Module /usr/bin/sleep from rpm bash-5.2.15-3.fc38.x86_64
       Module /usr/lib64/libtinfo.so.6.3 from rpm coreutils-9.1-8.fc37.x86_64
       Module /usr/lib64/libc.so.6 from rpm coreutils-9.1-8.fc37.x86_64
       Module /usr/lib64/libreadline.so.8.2 from rpm coreutils-9.1-8.fc37.x86_64
       Module /usr/lib64/ld-linux-x86-64.so.2 from rpm coreutils-9.1-8.fc37.x86_64

   While with this patch we get:

       Module /usr/bin/sleep from rpm bash-5.2.15-3.fc38.x86_64
       Module /usr/lib64/libtinfo.so.6.3 from rpm ncurses-6.3-5.20220501.fc37.x86_64
       Module /usr/lib64/libreadline.so.8.2 from rpm readline-8.2-2.fc37.x86_64

So the parsed package metadata reported by systemd-coredump when the module
files are not found on the host (ie the case of crash inside a container) are
now correct. The inconsistency of the first module in the above example
(sleep is indeed not provided by the bash package) can be ignored as it
is a consequence of how this was tested.

In addition to this, this also fixes the performance issue of
systemd-coredump in case of the crashing process uses a large number of
shared libraries and having no package metadata, as reported in
https://sourceware.org/pipermail/elfutils-devel/2023q2/006225.html.
2023-06-21 19:07:20 +01:00
Daan De Meyer
33885343cf
Merge pull request #27942 from DaanDeMeyer/root-ephemeral
core: Add RootEphemeral= setting
2023-06-21 17:24:39 +02:00
Frantisek Sumsal
51a05be9a2 test: cover a couple of missed code paths in journalctl/journald 2023-06-21 17:08:55 +02:00
Daan De Meyer
cdad1f1407 test: Add RootEphemeral= integration test 2023-06-21 12:48:48 +02:00
Daan De Meyer
d110169b65 test: Add touch into minimal verity test image 2023-06-21 12:48:48 +02:00
Daan De Meyer
9c0c670125 core: Add RootEphemeral= setting
This setting allows services to run in an ephemeral copy of the root
directory or root image. To make sure the ephemeral copies are always
cleaned up, we add a tmpfiles snippet to unconditionally clean up
/var/lib/systemd/ephemeral. To prevent in use ephemeral copies from
being cleaned up by tmpfiles, we use the newly added COPY_LOCK_BSD
and BTRFS_SNAPSHOT_LOCK_BSD flags to take a BSD lock on the ephemeral
copies which instruct tmpfiles to not touch those ephemeral copies as
long as the BSD lock is held.
2023-06-21 12:48:46 +02:00
Frantisek Sumsal
2411e990a4 journal-remote: fix typo in an error message 2023-06-21 11:09:12 +02:00
Zbigniew Jędrzejewski-Szmek
8a38b62f37 meson: update man rules
Fixup for 403082602d.
2023-06-21 07:29:23 +02:00