Commit graph

63587 commits

Author SHA1 Message Date
Lennart Poettering 6f1fe575f0 TODO: drop items regarding swap-for-hibernate-only-use
I doubt we should bother. Swap always makes sense, and having a swap
partition for hibernate only without using it all the time just makes
the system worse overall.
2023-03-31 12:21:35 +02:00
Ludwig Nussel 6fb595bc2f docs: fix coredump legacy example 2023-03-31 11:47:17 +02:00
Daan De Meyer 84d421d4fe
Merge pull request #27080 from yuwata/rm-rf
rm-rf: also chmod() directory if it cannot be opened
2023-03-31 09:59:06 +02:00
Yu Watanabe 5b6f203c95 Revert "Revert "test: add more testcases for rm_rf()""
This reverts commit 8c81a61810.
2023-03-31 11:54:23 +09:00
Yu Watanabe 7be9657706 rm-rf: also chmod() directory if it cannot be opened
Otherwise, directory with zero access mode cannot be removed.

This is a revised version of 808c8b25ee,
- dropped O_NOFOLLOW from fd_reopen()
- fixed error handling on opening path in rm_rf().
2023-03-31 11:52:03 +09:00
Mike Yuan 5171356eee core: always calculate the next restart interval
Follow-up for #26902 and #26971

Let's always calculate the next restart interval
since that's more useful.

For that, we add 1 to s->n_restarts unconditionally,
and change RestartUSecCurrent property to RestartUSecNext.
2023-03-31 01:22:58 +01:00
Luca Boccassi ed2a4e8d78
Merge pull request #27075 from mrc0mmand/test-tweaks
test: a couple of coverage-related test tweaks
2023-03-31 01:18:15 +01:00
Zbigniew Jędrzejewski-Szmek 9b9f6aa412 bootctl: clean up handling of files with no version information
get_file_version() would return:
- various negative errors if the file could not be accessed or if it was not a
  regular file
- 0/NULL if the file was too small
- -ESRCH or -EINVAL if the file did not contain the marker
- -ENOMEM or permissions errors
-  1 if the marker was found

bootctl status iterates over /EFI/{systemd,BOOT}/*.efi and checks if the files
contain a systemd-boot version tag. Resource or permission errors should be
fatal, but lack of version information should be silently ignored.

OTOH, when updating or installing bootloader files, the version is expected
to be present.

get_file_version() is changed to return -ESRCH if the version is unavailable,
and other errnos for permission or resource errors.

The logging is reworked to always display an error if encountered, but also
to log the status at debug level what the result of the version inquiry is.
This makes it figure out what is going on:
  /efi/EFI/systemd/systemd-bootx64.efi: EFI binary LoaderInfo marker: "systemd-boot 253-6.fc38"
  /efi/EFI/BOOT/BOOTfbx64.efi: EFI binary has no LoaderInfo marker.
  /efi/EFI/BOOT/BOOTIA32.EFI: EFI binary has no LoaderInfo marker.
  /efi/EFI/BOOT/BOOTX64.EFI: EFI binary LoaderInfo marker: "systemd-boot 253-6.fc38"

Replaces #27034.
Fixes https://github.com/NixOS/nixpkgs/issues/223579.
2023-03-30 20:52:05 +01:00
Luca Boccassi 9a39283e02
Merge pull request #27072 from bluca/man_example
man: further shorten print-unit-path example
2023-03-30 19:56:14 +01:00
Frantisek Sumsal 1d6052ba5c test: make make_addresses() actually return the addresses
I noticed missing coverage in the reports and turns out this has been
broken since forever (i.e. 2016 - 9f7672b3bc), whoopsie.
2023-03-30 20:42:47 +02:00
Frantisek Sumsal 4388541237 coverage: add a wrapper for execveat()
gcov provides wrappers for the exec*() calls but there's none for execveat(),
which means we lose all coverage prior to the call. To mitigate this, let's
add a simple execveat() wrapper in gcov's style[0], which dumps and resets
the coverage data when needed.

This applies only when we're built with -Dfexecve=true.

[0] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libgcc/libgcov-interface.c;h=b2ee930864183b78c8826255183ca86e15e21ded;hb=HEAD
2023-03-30 20:42:47 +02:00
Luca Boccassi ce199d12e9 man: add example for sd_bus_call_method 2023-03-30 18:55:55 +01:00
Luca Boccassi d10a5f6c3d man: further shorten print-unit-path example 2023-03-30 18:29:49 +01:00
Lennart Poettering bba6046b24 man: link up new online coredump docs from man page 2023-03-31 01:15:24 +08:00
Luca Boccassi fec36c3ba7
Merge pull request #27074 from bluca/revert_rm
Revert rm-rf changes that are causing test failures
2023-03-30 18:07:27 +01:00
Luca Boccassi cfe9d45207 Revert "rm-rf: also chmod() directory if it cannot be opened"
This reverts commit 808c8b25ee.
2023-03-30 16:48:22 +01:00
Luca Boccassi 8c81a61810 Revert "test: add more testcases for rm_rf()"
This reverts commit 0278b1c801.
2023-03-30 16:48:18 +01:00
Zbigniew Jędrzejewski-Szmek 26134d198a pid1: fully disable coredumping to $PWD
We have three states:
- ENABLE_COREDUMP and systemd-coredump is installed,
- ENABLE_COREDUMP but systemd-coredump is not installed,
- !ENABLE_COREDUMP.

In the last case we would not do any coredumping-related setup in pid1, which
means that coredumps would go to to the working directory of the process, but
actually limits are set to 0. This is inherited by children of pid1.

As discussed extensively in https://github.com/systemd/systemd/pull/26607, this
default is bad: dumps are written to arbitrary directories and not cleaned up.

Nevertheless, the kernel cannot really fix it. It doesn't know where to write,
and it doesn't know when that place would become available. It is only the
userspace that can tell this to the kernel. So the only sensible change in the
kernel would be to default to '|/bin/false', i.e. do what we do now.

In the middle case, we disabled writing of coredumps via a pattern, but raise
the RLIMIT_CORE. We need to raise the limit because we can't raise it later
after processes have been forked off. This means we behave correctly, but allow
coredumping to be enabled at a later point without a reboot.

This patch makes the last case behave like the middle case. This means that
even if systemd is compiled with systemd-coredump, it still does the usual
setup. If users want to restore the kernel default, they need to provide two
drop-in files:
  for sysctl.d, with 'kernel.core_pattern=core'
  for systemd.conf, with 'DefaultLimitCORE=0'.

The general idea is that pid1 does the safe thing. A distro may want to use
something different than the systemd-coredump machinery, and then that would
could packaged together with the drop-ins to change the configuration.

Alternative-for: #26607
2023-03-30 16:15:58 +02:00
Lennart Poettering b6bd98ebd5 docs: add a document with an overview over systemd's coredump handling 2023-03-30 16:11:26 +02:00
Xiaotian Wu a4a2077df5 basic: update the Arch tuples for LoongArch
After this commit[1], LoongArch now uses these Multiarch specs:

- Double float: loongarch64-linux-gnu
- Single float: loongarch64-linux-gnuf32
- Soft float: loongarch64-linux-gnusf

You can visit here[2] to view the full documentation.

[1]: 55dbaadaaa
[2]: https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html
2023-03-30 15:44:03 +02:00
Zbigniew Jędrzejewski-Szmek e61bab2b55
Merge pull request #26883 from yuwata/rm-rf
rm-rf: also chmod directory if cannot be opened
2023-03-30 14:54:59 +02:00
Daan De Meyer 65e179a1e7 tmpfiles: Try to take a BSD lock on files as well
Similar to what we do for directories, just before we remove a file,
let's try to take a BSD lock on it. If that fails, skip removing the
file.
2023-03-30 11:45:05 +02:00
Daan De Meyer 5ccf06074a
Merge pull request #27064 from DaanDeMeyer/chase-fixes
Chase fixes
2023-03-30 11:44:33 +02:00
Daan De Meyer ee6fea2b7f
Merge pull request #27063 from yuwata/chase-graceful
chase: gracefully drop CHASE_AT_RESOLVE_IN_ROOT when AT_FDCWD is specified
2023-03-30 11:44:17 +02:00
Daan De Meyer 1b07fd3c22
Merge pull request #27041 from poettering/fdstore-dump
add ability to show contents of service fdstore + teach systemd-notify passing fds into the fdstore
2023-03-30 09:32:13 +02:00
Yu Watanabe 8bf26bfe26 chase: add CHASE_AT_RESOLVE_IN_ROOT only when it is necessary 2023-03-30 16:29:45 +09:00
Yu Watanabe e115daa6a8 chase: drop CHASE_AT_RESOLVE_IN_ROOT when AT_FDCWD or root dir fd is specified
If we get AT_FDCWD or root dir fd, we always resolve symlinks relative to the host's root.
Hence, the flag is meaningless.
2023-03-30 16:29:37 +09:00
Yu Watanabe 0362953e9a test-kernel-install: several cleanups
- allow to run without $PROJECT_BUILD_ROOT,
- drop unnecessary export for bootctl,
- enable -x option to show commands,
- use 'test ! -e' to check the nonexistence of files,
- show more debugging logs.
2023-03-30 09:23:07 +02:00
Yu Watanabe 85db5602e0 man: drop trailing space and mention uki_generator at one more place
Follow-up for 600362aa11.
2023-03-30 09:20:56 +02:00
Daan De Meyer 708e88704b chase: Simplify chase_and_open() and chase_and_openat()
xopenat() now calls fd_reopen() if an empty path is specified, so
let's make use of that to simplify the chase open helpers.
2023-03-30 09:04:14 +02:00
Daan De Meyer fedceeba2e fs-util: Strip O_NOFOLLOW in xopenat() when calling fd_reopen()
We definitely want to follow symlinks when calling fd_reopen() so
let's strip O_NOFOLLOW when we call it from xopenat().
2023-03-30 09:04:14 +02:00
Daan De Meyer 16859751ca chase: Fix error code check 2023-03-30 09:04:14 +02:00
Daan De Meyer 11659e4830 chase: Fix formatting 2023-03-30 09:04:14 +02:00
Daan De Meyer 47ef19d6b9
Merge pull request #27062 from yuwata/chase-trivial
chase: trivial cleanups
2023-03-30 08:45:38 +02:00
Lennart Poettering d53bda316b service: drop redundant unit_ref_unset() call
The immediately preceeding service_close_socket_fd() call does that
internally anyway. No need to do this again right after.
2023-03-30 08:44:59 +02:00
Daan De Meyer 2e82d82445
Merge pull request #27060 from yuwata/fd-get-path
fd-util: make fd_get_path() support AT_FDCWD
2023-03-30 07:59:25 +02:00
Yu Watanabe 6d5d3e207b chase: fix indentation 2023-03-30 14:52:13 +09:00
Yu Watanabe 52576a7503 chase: fix comment 2023-03-30 14:52:13 +09:00
Daan De Meyer c4406ff710
Merge pull request #27061 from yuwata/test-chase
test: split out tests for chase() and friends
2023-03-30 07:17:40 +02:00
Yu Watanabe 8f22fe3207 test: split-out tests for chase() and friends to test-chase.c 2023-03-30 12:18:40 +09:00
Yu Watanabe 564a7545aa test: rename test-chase -> test-chase-manual 2023-03-30 12:18:40 +09:00
Yu Watanabe 46693a7925 fd-util: make fd_get_path() support AT_FDCWD 2023-03-30 12:03:33 +09:00
Yu Watanabe 8067fe86ff test: add tests for fd_get_path() 2023-03-30 12:03:33 +09:00
Lennart Poettering 62c72c60b5 units: let's establish the coredump socket before writting core_pattern sysctl
It's a bit nicer if we only write the sysctl core_pattern once the
coredump socket is established, since it's the backend for the handler.

Given the systemd-coredump.socket basically has no dependencies that run
before it this should not really make things slower or so, it just
removes the tiny window where core pattern is in effect that wants to
connect to the backend socket but cannot.

The status quo isn't terrible, and not too different in effect: either
way, until the socket unit is up we won't process coredumps. It's mostly
what kind of behaviour you get then: an error due to /bin/false being
invoked, or an error because systemd-coredump can't connect to its
socket. After this patch we'll exclusively see the former.
2023-03-30 08:53:52 +09:00
Mike Yuan c884484956
Merge pull request #27053 from DaanDeMeyer/firstboot-followups
Firstboot followups
2023-03-30 04:22:16 +08:00
Lennart Poettering 2e34aed32b
Merge pull request #26971 from poettering/autostart-dead-failed
pid1: introduce new SERVICE_{DEAD|FAILED}_BEFORE_AUTO_RESTART service…
2023-03-29 21:41:31 +02:00
Lennart Poettering a7b6eee4ac
Merge pull request #26968 from DaanDeMeyer/exec-runtime
core: Introduce unit private exec runtime
2023-03-29 21:40:48 +02:00
Lennart Poettering 3739c2fdfc update TODO 2023-03-29 19:09:10 +02:00
Lennart Poettering b0717f1b82 test: add test case for fdstore dumping logic, and systemd-notify --fd= 2023-03-29 19:09:10 +02:00
Lennart Poettering 6e4a324574 notify: add support for sending fds with notification messages
This exposes the fd passing we support via sd_pid_notify_with_fds() also
via the command line tool systemd-notify.
2023-03-29 19:09:10 +02:00