Commit graph

62878 commits

Author SHA1 Message Date
Lennart Poettering b7dc40e663 test: add test for new memory pressure logic
it tests both real PSI stuff (if available) and fake pressure via
AF_UNIX and FIFO notification.
2023-02-22 13:14:36 +01:00
Lennart Poettering 158fe190af sd-event: add high-level sd_event_add_memory_pressure() event source
Typically, in reasonably complex programs we want to realease various
caches (such as glibc allocation caches) in case of memory pressure.
Let's add explicit infrastructure for that to sd-event, that can hook
Linux' Pressure Stall Information (PSI) logic with our event loop.

This adds sd_event_add_memory_pressure() as easy, one-step API to
install an even source that is called under memory pressure.

The parameters which file to watch (the per-cgroup PSI file, or the
system-wide file /proc/pressure/memory) can be configured via env vars.
The idea is that the service manager sooner or later gains controls for
setting this up correctly.

Alternatively to the PSI a similar logic is supported but instead of
waiting for POLLPRI on a procfs/cgroupfs fd we'll wait for POLLIN on
FIFO or AF_UNIX sockets. This is useful for testing, and possibly in
other environments, for example to hook up this protocol directly with
GNOME's low memory monitor.

By default this watches on the cgroup-local PSI so that we aren't
affected by pressure on cgroups we are not related to.
2023-02-22 13:09:42 +01:00
Daan De Meyer 4d8ff4e868 repart: Exclude APIVFS mountpoint directories
Also exclude APIVFS and temporary files directories from the copy
operation so that these files don't accidentally end up in images.
2023-02-22 12:44:39 +01:00
Daan De Meyer b63bd125d4 copy: Support both inode exclusion and contents exclusion
In some cases, we want to exclude a directory's contents but not
the directory itself. In other cases, we want to exclude a directory
and its contents. Let's extend the denylist logic in copy.h to support
both by changing the denylist from a set to hashmap so we can store the
deny type as the value.

We also modify the repart ExcludeFiles= option to make use of this. If
a directory to exclude ends with a "/", we'll only exclude its contents.
Otherwise, we'll exclude the full directory.
2023-02-22 12:44:36 +01:00
Daan De Meyer 5ab863be51 repart: Refactor make_copy_files_denylist() a bit 2023-02-22 12:44:18 +01:00
Zbigniew Jędrzejewski-Szmek 18e100172c test-set: inline two iterator declarations 2023-02-22 11:39:44 +01:00
Zbigniew Jędrzejewski-Szmek 3dc6b0fcb2 sd-journal: use a dynamic check for valgrind
I left this one as a separate commit because it is more involved.
We want people to compile with valgrind support, but we don't want to
use a slow hash function unless we're actually running under valgrind.
So the compile-time check is changed to a runtime check. When compiled
with optimization, the compiler should elide the checks on the constants,
and only leave the check for RUNNING_ON_VALGRIND. It is wrapped with
_unlikely_ so that the else branch is put in the hot path.
2023-02-22 11:39:44 +01:00
Zbigniew Jędrzejewski-Szmek 50b35193ec meson: merge our two valgrind configuration conditions into one
Most of the support for valgrind was under HAVE_VALGRIND_VALGRIND_H, i.e. we
would enable if the valgrind headers were found. The operations then we be
conditionalized on RUNNING_UNDER_VALGRIND.

But in a few places we had code which was conditionalized on VALGRIND, i.e. the
config option. I noticed because I compiled with -Dvalgrind=true on a machine
that didn't have valgrind.h, and the build failed because
RUNNING_UNDER_VALGRIND was not defined. My first idea was to add a check that
the header is present if the option is set, but it seems better to just remove
the option. The code to support valgrind is trivial, and if we're
!RUNNING_UNDER_VALGRIND, it has negligible cost. And the case of running under
valgrind is always some special testing/debugging mode, so we should just do
those extra steps to make valgrind output cleaner. Removing the option makes
things simpler and we don't have to think if something should be covered by the
one or the other configuration bit.

I had a vague recollection that in some places we used -Dvalgrind=true not
for valgrind support, but to enable additional cleanup under other sanitizers.
But that code would fail to build without the valgrind headers anyway, so
I'm not sure if that was still used. If there are uses like that, we can
extend the condition for cleanup_pools().
2023-02-22 11:39:44 +01:00
Zbigniew Jędrzejewski-Szmek 3f275dcb84 test-set: drop left-over valgrind check
In b01f31954f mempool_use_allowed
was dropped, but apparently it was forgotten here.
2023-02-22 11:13:57 +01:00
Vít Zikmund 81cfea95e5 hwdb: fix swapped buttons for Logitech Lift left 2023-02-22 19:10:10 +09:00
Yu Watanabe a2e41b817b test: add another stress test for devlink creation 2023-02-22 19:08:26 +09:00
Yu Watanabe 60c5bd7759 tree-wide: fix typo 2023-02-22 14:46:19 +09:00
Yu Watanabe 4788f635e3
Merge pull request #26203 from medhefgo/meson
meson: Use dicts for test/fuzzer definitions
2023-02-22 10:27:16 +09:00
Yu Watanabe b5eba967a9
Merge pull request #26529 from medhefgo/boot-misc
boot: Misc changes
2023-02-22 10:16:23 +09:00
Yu Watanabe 086234e39b
Merge pull request #26491 from dtardon/list-paths
Add systemctl list-paths
2023-02-22 09:29:54 +09:00
mooo 8e46b195e0 po: Translated using Weblate (Lithuanian)
Currently translated at 78.2% (151 of 193 strings)

Co-authored-by: mooo <hazap@hotmail.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/lt/
Translation: systemd/main
2023-02-22 08:37:52 +09:00
Yu Watanabe a06f85a073
Merge pull request #26527 from mrc0mmand/more-tests
test: provide coverage for #26467 and #26483
2023-02-22 08:01:07 +09:00
Дамјан Георгиевски 37fe75a2e6 socket-proxyd: support Type=notify
update examples in the man page too
2023-02-21 22:59:04 +00:00
Luca Boccassi fd4ba8a7db
Merge pull request #26349 from yuwata/safe-fork-rearrange-stdio
process-util: introduce FORK_REARRANGE_STDIO
2023-02-21 22:58:52 +00:00
Lennart Poettering e7906abeb8 pam-systemd: split up weight helper funcs
There are three conditionalizations in the status quo ante function,
which kinda indicates this should not be the same function in the first
place. Hence split this up, simplify it, and have two distinct functions
without conditionalizations.
2023-02-21 22:54:12 +00:00
Lennart Poettering 01e4f03f34 journal: move journal_file_compare_locations() from journal-file.c → sd-journal.c
It's only used from sd-journal.c, and we soon would like to pass in an
sd_journal object, hence let's move this over.

This only moves code, doesn't change behaviour
2023-02-21 21:08:21 +01:00
Jan Janssen 5fa3e628cd boot: Drop _harder suffix
Since there is no use of gnu-efi functions anymore, we don't need to
distinguish them by name.
2023-02-21 21:07:04 +01:00
Jan Janssen 3ceaa05d56 boot: Do not use errno.h/inttypes.h
These are provided by libc instead of the compiler and are not supposed
to be used in freestanding environments.
When cross-compiling with clang and the corresponding gcc
cross-toolchain is not around, clang may pick up the wrong header from
the host system.
2023-02-21 21:07:04 +01:00
Jan Janssen a4ab05e296 fundamental: Drop some unnecessary ifdefs
With gnu-efi headers gone, we don't need these guards anymore.
2023-02-21 21:07:04 +01:00
Aidan Dang d59025698f Enable TPM by default with SetCredentialEncrypted 2023-02-21 21:07:02 +01:00
Jan Janssen 024951fb22 stub: Fix unaligned read 2023-02-21 21:01:47 +01:00
Zbigniew Jędrzejewski-Szmek 377d36898c
Merge pull request #26446 from medhefgo/efi-headers
boot: Provide our own EFI API headers
2023-02-21 20:59:33 +01:00
Zbigniew Jędrzejewski-Szmek 1eca770933 efi: drop executable-stack bit from .elf file
An rpminspect test in Fedora/RHEL is flagging our stub files as having an
executable stack. The check is correct:

$ readelf --wide --program-headers build/src/boot/efi/linuxx64.elf.stub | rg -i stack
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RWE 0x10

It seems to be just an omission in the linker script… None of the objects that
are linked into the stub are marked as requiring an executable stack:

$ readelf --wide --sections build/src/boot/efi/*.c.o \
  /usr/lib/gnuefi/x64/libgnuefi.a \
  /usr/lib/gnuefi/x64/libefi.a \
  /usr/lib/gcc/x86_64-redhat-linux/12/libgcc.a \
  | rg '.note.GNU-stack.*X'
(nothing)

On aarch64 we end up with a nonexecutable stack, but on ia32 and x64 we get one,
so this might be just a matter of defaults in the linker. It doesn't matter
greatly, but let's mark the stack as non-executable to avoid the warning.

Note: '-Wl,-z' is not needed, things work with just '-z'.
2023-02-21 20:51:47 +01:00
David Tardon 6269ffe7ee logind-session: make stopping of idle session visible to admins 2023-02-21 20:50:24 +01:00
Mike Yuan e0b3a70fab sleep: check if we're on AC power before checking battery capacity
Before this commit, battery_is_low() returns
true if there's no battery on the system.
It's now modified to check if the system is
on AC power first, and returns false early
if that's the case.

Fixes #26492
2023-02-21 20:48:33 +01:00
Frantisek Sumsal adae3552f0 test: add coverage for #26483 2023-02-21 19:39:52 +01:00
Frantisek Sumsal 4190124b3c test: add coverage for #26467 2023-02-21 19:39:52 +01:00
David Tardon f8979e8698 install: fail early if specifier expansion failed
Before:

systemd[1]: Assertion 'path' failed at src/shared/install.c:288, function install_changes_add(). Aborting.
systemd[1]: Caught <ABRT> from our own process.
systemd[1]: Caught <ABRT>, dumped core as pid 2525.
systemd[1]: Freezing execution

After:

Failed to enable unit: Invalid specifier in user-%J.service

Fixes #26467.

Follow-up for: f5a0162
2023-02-21 18:39:07 +00:00
David Tardon a2ceb88005 test: add a minimal test for list-paths 2023-02-21 19:03:26 +01:00
David Tardon 7336968488 shell-completion: add systemctl list-paths 2023-02-21 19:03:26 +01:00
David Tardon 160b8e981b man: document systemctl list-paths 2023-02-21 19:03:26 +01:00
David Tardon 5fb5f49bec systemctl: add list-paths verb
Fixes #6054.
2023-02-21 19:03:24 +01:00
Daan De Meyer 6c53840958
Merge pull request #26518 from DaanDeMeyer/mkosi-stuff
mkosi: Drop build script workarounds
2023-02-21 18:23:06 +01:00
Lennart Poettering c56be2c294 bootctl: add new --print-root-device option
We already have this nice code in system that determines the block
device backing the root file system, but it's only used internally in
systemd-gpt-generator. Let's make this more accessible and expose it
directly in bootctl.

It doesn't fit immediately into the topic of bootctl, but I think it's
close enough and behaves very similar to the existing "bootctl
--print-boot-path" and "--print-esp-path" tools.

If --print-root-device (or -R) is specified once, will show the block device
backing the root fs, and if specified twice (probably easier: -RR) it
will show the whole block device that block device belongs to in case it
is a partition block device.

Suggested use:

        # cfdisk `bootctl -RR`

To get access to the partition table, behind the OS install, for
whatever it might be.
2023-02-21 18:19:38 +01:00
Lennart Poettering b469b969f3
Merge pull request #26265 from poettering/journal-refresh-fixes
journal: journal file header IDs refresh fixes and corrections
2023-02-21 18:19:12 +01:00
David Tardon f748b2d01a systemctl: prepend machine ID to unit ID in list-sockets
We do it that way in all other list-* functions, so let's be consistent.
2023-02-21 17:15:12 +01:00
David Tardon ac1405960a systemctl: extract common code to a function 2023-02-21 17:15:12 +01:00
David Tardon f4384e199d systemctl: use table_add_triggered 2023-02-21 17:15:12 +01:00
David Tardon 531a45f35a systemctl: extract code to a helper function
It will be used more in subsequent commits.
2023-02-21 17:15:12 +01:00
Daan De Meyer 1ad84c9af8 mkosi: Reduce postinst script indentation 2023-02-21 15:23:15 +01:00
Daan De Meyer d2a0ca2440 mkosi: Simplify BUILDDIR/SRCDIR handling a bit 2023-02-21 15:20:20 +01:00
Daan De Meyer 01a0756427 mkosi: Move more logic to the postinst script
Let's move stuff that only applies to the final image to the
postinst script. Let's also move out some of the static files to
mkosi.extra/ instead of hardcoding them in scripts.
2023-02-21 15:20:18 +01:00
Jan Janssen 2ed35b2f3e meson: Use dicts for fuzzer definitions 2023-02-21 15:10:26 +01:00
Jan Janssen a9a7153cd2 meson: Add simple_fuzzers list 2023-02-21 15:10:26 +01:00
Jan Janssen 822cd3ff25 meson: Use dicts for test definitions
Although this slightly more verbose it makes it much easier to reason
about. The code that produces the tests heavily benefits from this.

Test lists are also now sorted by test name.
2023-02-21 15:10:26 +01:00