Commit Graph

80354 Commits

Author SHA1 Message Date
Lennart Poettering
8b21bbd6f0 pcrextend: whenever we fail to extend PCRs, reboot immediately
PCR extensions are supposed to be useful for "destroying" the ability to
access TPM bound secrets. Hence, if for some reason we fail to extend a
PCR, it's safer to just reboot, instead of going on without the
extension, leaving secrets potentially accessible which should not be
accessible.

Note that the services exit gracefully if no TPM is found, hence this
should not be triggered on TPM-less systems. However, this enforces that
if there is a TPM that is accessible to Linux and that works properly,
the PCR measurement must complete too.

Inspired by this thread:

https://lists.freedesktop.org/archives/systemd-devel/2025-March/051244.html
2025-03-31 21:13:33 +09:00
Busayo Dada
1220625a81 socket-proxy: add syntax highlighting to help output 2025-03-31 21:09:14 +09:00
Luca Boccassi
da24983526 test: skip networkd tests if networkd/resolved are disabled at build time 2025-03-30 10:18:18 +02:00
Luca Boccassi
75b16ac59e test: skip TEST-75-RESOLVED if resolved is disabled at build time 2025-03-30 10:18:18 +02:00
Mike Yuan
6b4a05519b sd-bus/bus-common-errors: add missing error map entries 2025-03-29 19:51:13 +01:00
Luca Boccassi
fce07bcb7a meson: add feature flag for nspawn build (#36876)
Other tools have it, nspawn doesn't, add one
2025-03-28 13:55:19 +00:00
Luca Boccassi
6561d02ee1 mkosi: Use build image prepare scripts for tools tree as well (#36861)
Instead of listing dependencies manually for the default tools tree,
let's reuse the prepare scripts from the build image. To make this work,
the sync script has to be configured for the tools tree as well so that
it's invoked both when building the tools tree and for the regular
image,
otherwise, when doing the first build in a fresh checkout, the sync
script
won't have executed yet as sync scripts for the regular images are
executed
after building the default tools tree.
2025-03-28 13:31:28 +00:00
Daan De Meyer
848b5ae0d1 test: Drop --no-rebuild from meson test invocations
With meson 1.7.0, meson won't rebuild the world anymore when running
meson test so since meson 1.7.0 is in tumbleweed, debian testing, fedora
rawhide and Arch Linux, drop --no-rebuild from the docs since all the default
tools trees built by mkosi in the systemd repo will have meson 1.7.0 or newer
installed.

We keep --no-rebuild in CI because in CI we run with the same tools tree
distribution as the target distribution we're building and in those it's not
guaranteed for meson 1.7.0 to be available yet.

The advantage of dropping --no-rebuild is that meson will now reconfigure itself
if needed, which is required if we change or move around meson files, as otherwise
meson tends to explode spectacularly in hard to debug ways.

https://mesonbuild.com/Release-notes-for-1-7-0.html#test-targets-no-longer-built-by-default
2025-03-28 13:02:20 +01:00
Daan De Meyer
1b49fb9aaa mkosi: Use build image prepare scripts for tools tree as well
Instead of listing dependencies manually for the default tools tree,
let's reuse the prepare scripts from the build image. To make this work,
the sync script has to be configured for the tools tree as well so that
it's invoked both when building the tools tree and for the regular image,
otherwise, when doing the first build in a fresh checkout, the sync script
won't have executed yet as sync scripts for the regular images are executed
after building the default tools tree.
2025-03-28 12:29:09 +01:00
Daan De Meyer
e7df838a07 test: Use /dev/shm for TEST_JOURNAL_USE_TMP if /tmp isn't tmpfs
If /dev/shm is a tmpfs and /tmp isn't, use /dev/shm instead.
2025-03-28 11:40:39 +01:00
Daan De Meyer
29a1e7df64 test: Mark tests as skipped if requirements were not satisfied
Instead of not creating the test at all, let's always create test but
simply mark them as skipped as this is more observable than simply not
creating the test at all.
2025-03-28 11:40:39 +01:00
Daan De Meyer
c2d2b382b6 TEST-06-SELINUX: Only enable if meson was invoked as root
This test only works if the image was built as root. Since that's
impossible to check as meson generally runs before we build the image,
let's use whether meson is run as root as a proxy.
2025-03-28 11:40:39 +01:00
Daan De Meyer
51b4920746 test: Boot integration test VMs without an initrd if possible
If we don't need an initrd, let's not waste time in one. We have to
gate this by distributions that have the necessary kernel modules to
make this work as builtin modules, hopefully we can expand the list in
the future.
2025-03-28 11:40:39 +01:00
Daan De Meyer
c4fcd6ea78 mkosi: Bump minimum version to 25~devel 2025-03-28 11:40:39 +01:00
Luca Boccassi
980aced10b test: always install test-resolve subdir
Content is also used by unit tests, not just resolved tests,
so they are needed even when resolved is disabled, as unit
tests are still built and run
2025-03-28 10:34:02 +00:00
Luca Boccassi
d95818f522 meson: add feature flag for nspawn build
Other tools have it, nspawn doesn't, add one
2025-03-28 10:34:02 +00:00
Daan De Meyer
858e59c82c mkosi: Mark /etc /var as updated in a finalize script
Let's make sure we don't run ldconfig.service and other services
again on first boot.
2025-03-28 09:49:17 +01:00
Daan De Meyer
d3ae14bd2f mkosi: Disable various extra things in the default preset 2025-03-28 09:49:17 +01:00
Daan De Meyer
eeb43426de mkosi: Remove debian/ubuntu pinning
mkosi does this natively now.
2025-03-28 09:49:17 +01:00
Daan De Meyer
ddc2234f4a mkosi: Update to latest 2025-03-28 09:49:15 +01:00
Allison Karlitskaya
f32962d758 test/README.md: mention mkosi genkey
This is a required first step before testing and it's not specifically
mentioned in the doc.  This tripped me up for a while, so let's save the
trouble for the next person.
2025-03-28 09:42:51 +01:00
Luca Boccassi
3f8431d038 mkosi: update fedora commit reference (#36875)
* 617952132d Run integration testsuite standalone if available
2025-03-28 02:06:06 +00:00
Daan De Meyer
803e2e24df mkosi: update fedora commit reference
* 617952132d Run integration testsuite standalone if available
2025-03-27 22:49:26 +01:00
Daan De Meyer
926adc6617 test: Fix symlink location of standalone tests
This was accidentally moved to the wrong folder so fix up the location
so it's located in the standalone/ folder as expected.
2025-03-27 22:49:26 +01:00
Daan De Meyer
e213ecd484 test: Make it possible to run the integration tests standalone (#36868)
Currently, to run the integration tests, it's still necessary to
install various other build tools besides meson: A compiler, gperf,
libcap, ... which we want to avoid in CI systems where we receive
prebuilt systemd packages and only want to test them. Examples are
Debian's autopkgtest CI and Fedora CI. Let's make it possible for
these systems to run the integration tests without having to install
any other build dependency besides meson by extracting the logic
required to run the integration tests with meson into a separate
subdirectory and adding a standalone top-level meson.build file which
can be used to configure a meson tree with as its only purpose running
the integration tests.

Practically, we do the following:
- all the integration test directories and integration-test-wrapper.py
  are moved from test/ to test/integration-tests/.
- All the installation logic is kept out of test/integration-tests/ or
  any of its subdirectories and moved into test/meson.build instead.
- We add test/integration-tests/standalone/meson.build to run the
  integration tests standalone. This meson file includes
  test/integration-tests via a cute symlink hack to trick meson into
  including a parent directory with subdir().
- Documentation is included on how to use the new standalone mode.
2025-03-27 21:38:00 +01:00
Daan De Meyer
d9f48358bd test: Make it possible to run the integration tests standalone
Currently, to run the integration tests, it's still necessary to
install various other build tools besides meson: A compiler, gperf,
libcap, ... which we want to avoid in CI systems where we receive
prebuilt systemd packages and only want to test them. Examples are
Debian's autopkgtest CI and Fedora CI. Let's make it possible for
these systems to run the integration tests without having to install
any other build dependency besides meson by extracting the logic
required to run the integration tests with meson into a separate
subdirectory and adding a standalone top-level meson.build file which
can be used to configure a meson tree with as its only purpose running
the integration tests.

Practically, we do the following:
- all the integration test directories and integration-test-wrapper.py
  are moved from test/ to test/integration-test/.
- All the installation logic is kept out of test/integration-test/ or
  any of its subdirectories and moved into test/meson.build instead.
- We add test/integration-test/standalone/meson.build to run the
  integration tests standalone. This meson file includes
  test/integration-test via a cute symlink hack to trick meson into
  including a parent directory with subdir().
- Documentation is included on how to use the new standalone mode.
- TEST-64-UDEV-STORAGE and TEST-85-NETWORK are changed to generate separate
  units for each testcase to make them behave more like the other integration
  tests.
2025-03-27 21:37:13 +01:00
ZIHCO
72586a971b ac-power: update the help output to use the ansi-color functions 2025-03-27 14:58:08 +09:00
Yu Watanabe
e2c801e767 core: drop manager_get_unit_by_pid() and friends (#36872)
Except for one place, they are only used by test-watch-pid. Let's also
use manager_get_unit_by_pidref() and friends in the test, and drop the
_pid() variants.
2025-03-27 06:10:53 +09:00
msizanoen
85d00912c0 core/cgroup: Properly handle aborting a pending freeze operation
We must thaw the cgroup even if cgroup.events/frozen=0 if a freeze
operation is in flight as it means the cgroup is already partially
frozen.
2025-03-26 21:39:50 +01:00
Yu Watanabe
3432d5e21f coredump: make sure pid1/journal coredumps are not lost when Storage=journal is selected (#36870)
It confused the hell of me, that if pid1 crashes in an mkosi system run
from the build tree there's no coredump kept. Because mkosi configures
journal storage for coredumps, but that's not going to work for pid1 or
journald. Hence use external storage for these two even if everything
else is stored in the journal.
2025-03-27 04:27:01 +09:00
Yu Watanabe
eb3554666e core: drop unused wrappers of manager_get_unit_by_pidref() and friends 2025-03-27 04:15:43 +09:00
Yu Watanabe
56691ea753 test-watch-pid: use pidref_safe_fork() with FORK_FREEZE
Then, use pidref version of functions.
2025-03-27 04:13:54 +09:00
Yu Watanabe
017f9bc1d7 test-watch-pid: move required test conditions to intro()
Follow-up for 7bcd76513a.
2025-03-27 03:57:02 +09:00
Lennart Poettering
ed2e3a8404 coredump: do not disable removal of temporary coredump file 2025-03-26 11:37:15 -04:00
Lennart Poettering
dc8e3118f9 coredump: make sure we initialize all return parameters on success of save_external_coredump() 2025-03-26 11:37:11 -04:00
Lennart Poettering
5125a0b8fa coredump: do not remove PID1/journal coredumps if Storage=journal is used
We always redirect PID1/journal coredumps directly onto disk instead of
the journal even if that's configured because that might cause a
deadlock because we are still pinning the old journal process while
processing the coredump. However, so far we then immediately deleted the
coredumps because of Storage=journal, which is very annoying, since
there's hence no copy kept whatsoever.

Let's hence exclude PID1+journal from the removal.

This in particulary brings the code in line with the log messages which
claim we kept the file around but we actually did not.
2025-03-26 11:37:08 -04:00
Lennart Poettering
2d0bcf1e02 coredump: rename fix_permissions() → fix_permissions_and_link()
The function doesn't just adjust permissions, it actually moves the
file into place. The function name should really make this fundamental
fact clear.
2025-03-26 11:33:38 -04:00
Luca Boccassi
3d9f3420b5 test: update to use the new ASSERT_OK() macro and friends (#36838)
Converted the unitest implemented in src/test/test-watch-pid.c that
still uses assert_se() to use the new ASSERT_OK() macro and friends.
2025-03-26 15:21:55 +00:00
Daan De Meyer
b4b1d94a09 meson: Drop project_source_root and project_build_root variables
We can now rely on meson.project_source_root() and meson.project_build_root()
which do the same thing.
2025-03-26 14:45:34 +01:00
Daan De Meyer
d22ffb44c1 tree-wide: Update outdated docs on removed old integration test stuff 2025-03-26 14:40:14 +01:00
Daan De Meyer
5944dc07cf Revert "test: dynamically generate list of test cases"
We want to decouple the integration tests in meson from the
rest of the source files so the integration tests can be run
without the source files available. Let's revert the change to
dynamically figure out the test cases from the networkd tests for
now so that the tests can be generated without the test source file
being available.

This reverts commit 514458604b.
2025-03-26 14:40:14 +01:00
Daan De Meyer
420b875ccb README: Drop test packages
This has bitrotted so let's just drop it as it's woefully out of date
and not really in the right location to be useful to anyone.
2025-03-26 14:40:14 +01:00
Daan De Meyer
20a4f117d9 test: Make sure serial is always set explicitly for scsi-hd qemu devices
Now that mkosi uses -blockdev instead -drive, the device_id property
of scsi-hd devices is not populated automatically anymore so we have to
make sure to always specify serial= to make sure /dev/disk/by-id is populated
as expected in the test.
2025-03-26 14:40:14 +01:00
Daan De Meyer
8a87f70e3b mkosi: Add back .mkosi-private/ to .gitignore
Required to exclude the history data;
2025-03-26 14:40:14 +01:00
ZIHCO
7bcd76513a test: update to use DEFINE_TEST_MAIN_WITH_INTRO() macro 2025-03-26 11:55:30 +00:00
ZIHCO
a87a1669a4 test: update to use the new ASSERT_OK() macro and friends 2025-03-26 11:55:30 +00:00
Steve Ramage
3e2c67bfb4 man: Add AssertVersion= to documentation (#36862) 2025-03-26 16:11:59 +09:00
Luca Boccassi
1cc8e4a183 logind: inhibitor fixups (#36817) 2025-03-26 00:22:27 +00:00
Nick Rosbrook
971fb3b0bc polkit: use -EBUSY to indicate shortcut after error or denial
Commit 536c18e5c3 ("bus-polkit: shortcut auth. after first denial")
added logic to async_polkit_query_check_action() that returns
-EALREADY when a failure or denial decision was made for a previous
action.

Tweak this to return -EBUSY instead of -EALREADY. This hopefully makes
the intent of the error more clear. EALREADY suggests that the request
is OK, but polkit is processing something else, and we should come back
later. EBUSY suggests that polkit is busy or unusable, hence the
request cannot be processed, and we should go away.
2025-03-25 16:15:34 -04:00
Nick Rosbrook
bc3a11097f login: add polkit example rules for allowing root to ignore inhibitors
The semantics of strong inhibitors require that POLKIT_ALWAYS_QUERY
always be set when checking if we can allow blocking inhibitors to be
ignored on shutdown, reboot, etc. With the default polkit rules and
policy, users may experience a situation where users in the sudo group
are authorized to run:

 systemctl reboot --check-inhibitors=no

but the root user is not authorized. Instead, the following error is
given:

 Call to Reboot failed: Interactive authentication required.

While this is correct according to the semantics of strong inhibitors,
it is confusing. To help the situation, provide example polkit rules
that allow root to perform these actions.

Finally, when root receives SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED
when calling e.g. systemctl reboot, print a message explaining that this
is due to the current polkit policy, and point to the new example rule.

Related: https://github.com/systemd/systemd/issues/36786
2025-03-25 16:15:34 -04:00