Commit Graph

5758 Commits

Author SHA1 Message Date
Matteo Croce
912a48572d test-network: check that network configuration is stable with KeepConfiguration=yes
Check that when networkd restarts, and the network configures
KeepConfiguration=yes, the network configuration is never changed.

Ensure this by dumping the `ip monitor` output when networkd is restarting.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2025-03-15 10:26:20 +09:00
Andrii Chubatiuk
5209e9cb05 journal-remote: added custom headers support 2025-03-15 07:27:38 +09:00
Yu Watanabe
d8a353552a TEST-73-LOCALE: do not unnecessarily restart systemd-localed
It is not necessary to clear previous keymap assignment, as
`localectl set-keymap` will anyway overwrite the previous assignment.

This drops the unnecessary restart of systemd-localed in the loop.
The mkosi test image contains about 500~700 keymaps. The test
performance is greatly improved by reducing the number of restarts,
especially when the test is running with sanitizers.

On Fedora 41 with sanitizers,
Before:
1/1 systemd:integration-tests / TEST-73-LOCALE OK             1157.50s
After:
1/1 systemd:integration-tests / TEST-73-LOCALE OK              104.43s
2025-03-13 09:24:49 +01:00
Yu Watanabe
b15053de89 udev/net: fix assignment of ID_NET_NAME=
E.g. sd_device object of network interface 'hoge!foo' has sysname 'hoge/foo'.
So, previously udevd assigned 'hoge/foo' rather than 'hoge!foo' to ID_NET_NAME,
hence even when renaming is not requested, such interface was renamed to 'hoge_foo'
(note '/' cannot be used in network interface name, hence escaped to underbar).
2025-03-13 01:48:33 +09:00
Lennart Poettering
d54196a4cd Fixes several recent CI issues (#36691)
- Fixes a race in systemd-run caused by
b7ba8d55b8, which causes issue #36679.
- Skip verifying masked units in TEST-23.
- Avoid false-positive ASan warning by switching sanitizer run from
Fedora rawhide to Fedora 41, caused by recent update from
llvm-19.1.7-11.fc43 to llvm-20.1.0-1.fc43. Hopefully issue #36678 should
be fixed.

Closes #36678.
Closes #36679.
2025-03-12 15:32:58 +01:00
Yu Watanabe
07355061db TEST-74-AUX-UTILS: fail earlier when systemd-run fail to reconnect to bus
Note, the default timeout for systemctl daemon-reload is 270 seconds.
Hence, 300 seconds should be enough.
2025-03-12 04:33:46 +09:00
Yu Watanabe
e5e7cc9a98 TEST-23-UNIT-FILE: skip verifying masked unit
This fixes the following failure:
TEST-23-UNIT-FILE.sh[2408]: + systemd-analyze --recursive-errors=no --man=no verify /usr/lib/systemd/system/sysinit.target.wants/systemd-hwdb-update.service
systemd-analyze[2737]: sys-kernel-config.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: proc-sys-fs-binfmt_misc.automount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: dev-hugepages.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: sys-kernel-tracing.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: sys-kernel-debug.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: sys-fs-fuse-connections.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: dev-mqueue.mount: symlinks are not allowed for units of this type, rejecting.
systemd-analyze[2737]: Unit systemd-hwdb-update.service is masked.
TEST-23-UNIT-FILE.sh[166]: + :
TEST-23-UNIT-FILE.sh[166]: + kill -0 2408
TEST-23-UNIT-FILE.sh[166]: + wait 2408
TEST-23-UNIT-FILE.sh[166]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE.verify-unit-files.sh failed'
TEST-23-UNIT-FILE.sh[166]: Subtest /usr/lib/systemd/tests/testdata/units/TEST-23-UNIT-FILE.verify-unit-files.sh failed
2025-03-12 04:33:46 +09:00
Lennart Poettering
f1bc816c09 test: add test checking if pattern based hostnames work 2025-03-11 18:01:42 +01:00
Yu Watanabe
51c086b9cc meson: use more features provided by newer meson
No functional change. Preparation for future bump of required meson
version.
2025-03-10 02:41:40 +09:00
Yu Watanabe
c0cc01de8a meson: use install_symlink() where applicable
Now our baseline of meson is 0.62, hence install_symlink() can be used.

Note, install_symlink() implies install_emptydir() for specified
install_dir. Hence, this also drops several unnecessary
install_emptydir() calls.

Note, the function currently does not support 'relative' and 'force' flags,
so several 'ln -frsT' inline calls cannot be replaced.
2025-03-10 02:41:40 +09:00
Yu Watanabe
ff697bb909 meson: invert version check condition to magically suppress warning
Then, it works with --fatal-meson-warnings.
2025-03-10 02:41:40 +09:00
Yu Watanabe
5506aff98d test-network: replace symlink to 99-default.link with a copy
Then, we can drop ugly workaround in meson.build.
The .link file is not necessarily synced with 99-default.link.
Also, 99-default.link is not updated so frequently.
Let's manually sync it when necessary.
2025-03-10 02:41:40 +09:00
Luca Boccassi
d9208ff9a4 keyutil: support adding content into PKCS#7 signature (#36663)
Support including the data that was signed inside the PKCS#7 signature.
This creates a self-contained file where the signature of the data can
be verified without any other information, since the file contains the
data, signature, and certificate (which contains the public key used for
the signing).

One use case of this is IPE which requires a PKCS#7 signature that is
not "detached", i.e. includes the IPE configuration that has been
signed.

This also slightly adjusts the test case to use the x509 certificate
inside the PKCS#7 signature instead of supplying it externally during
verification.
2025-03-08 01:42:20 +00:00
Dan Streetman
f80bb317f6 keyutil: support adding content into PKCS#7 signature 2025-03-07 18:36:23 -05:00
Lennart Poettering
b9f711b66e test: add integration test for the functionality added in this PR 2025-03-07 18:15:10 +01:00
Lennart Poettering
fd0dd2d4bc userdbctl: optionally show user/group data from JSON filerather than from system 2025-03-07 18:13:36 +01:00
Dan Streetman
2d09fd72ea test: run PKCS#7 verification with both internal and external certificates 2025-03-07 11:52:44 -05:00
Daan De Meyer
65ac4d06e0 mkosi: Disable BuildSourcesEphemeral= (#36646)
None of the package specs leave leftover files in the source directory
anymore, so let's stop using BuildSourcesEphemeral=yes and check in CI
that we don't regress.
2025-03-07 15:55:05 +01:00
Daan De Meyer
2e6a041376 mkosi: Disable BuildSourcesEphemeral=
Let's stop using BuildSourcesEphemeral= and instead make sure we don't
generate any auxiliary files during the mkosi build process.

We achieve this through a combination of trap to remove any new files
we create and bind mounts from /tmp over existing files whenever we need
to modify an existing file.

We also add a CI step to ensure we don't regress
2025-03-07 15:28:53 +01:00
Daan De Meyer
cbcaf9f47e TEST-13-NSPAWN: Set TERM=dumb when calling machinectl shell
We only consider something not a tty if it's not connected to a tty
and not connected to /dev/null, so let's use the environment variable
instead to tell machinectl shell that it shouldn't do any of its TTY
stuff.
2025-03-06 22:33:54 +00:00
Yu Watanabe
51e60dac12 test-network: drop deprecated ExecStart= modifier 2025-03-05 18:17:19 +09:00
Daan De Meyer
88400145ea test: Connect test unit to console when running interactively (#36586) 2025-03-04 17:06:49 +01:00
Lennart Poettering
591e1492b7 Coverity fixups (#36503)
Details in individual commits.
2025-03-03 22:54:42 +01:00
Michal Koutný
c4b7596607 TEST-13-NSPAWN.nss-mymachines: Use negative matching switch
The test expects _not_ to find the patterns but the run_and_grep would
still print 'FAIL:' message. Use the dedicated -n option that inverts
the semantics cleaner than shell's !.
2025-03-03 19:27:17 +01:00
Daan De Meyer
fe7413d195 test: Connect test unit to console when running interactively
When running interactively, let's connect the test unit directly
to the console. This enables adding "bash" anywhere within an
integration test to get a shell within the test environment.
2025-03-03 12:35:11 +01:00
Daan De Meyer
070de658a9 test: Disable status messages when we start running a test
As soon as we start running a test, we want pid 1 to stop showing
status messages so let's tell pid 1 to stop showing status messages.
2025-03-03 12:33:56 +01:00
Daan De Meyer
854a8c21d0 test: Move getty-pre.target logic into integration-test-wrapper.py
Also pull in getty-pre.target via Wants= so it actually gets pulled
into the transaction.
2025-03-03 11:51:13 +01:00
Daan De Meyer
c9a50ebd8f test: Check stdin for interactivity, not stderr 2025-03-03 11:44:42 +01:00
Jörg Behrmann
759fdb3a35 tests: remove cache=unsafe from TEST-64-UDEV-STORAGE
mkosi switch to the newer -blockdev qemu option in systemd/mkosi#3557 [1], but
cache=unsafe is an option only -drive supports.

Since the qemu-system_x86-64 man page [2] says this, cache.writeback=on is the
default and mkosi setting the other two options to the values corresponding to
unsafe, it should be fine to drop the cache=unsafe option.

┌─────────────┬─────────────────┬──────────────┬────────────────┐
│             │ cache.writeback │ cache.direct │ cache.no-flush │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│writeback    │ on              │ off          │ off            │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│none         │ on              │ on           │ off            │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│writethrough │ off             │ off          │ off            │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│directsync   │ off             │ on           │ off            │
├─────────────┼─────────────────┼──────────────┼────────────────┤
│unsafe       │ on              │ off          │ on             │
└─────────────┴─────────────────┴──────────────┴────────────────┘

[1] https://github.com/systemd/mkosi/pull/3557
[2] https://manpages.ubuntu.com/manpages/noble/en/man1/qemu-system-x86_64.1.html
2025-03-03 09:45:49 +01:00
Daan De Meyer
38701809a8 core: Add DelegateNamespaces= (#36532) 2025-03-01 15:18:45 +01:00
Daan De Meyer
8234cd9989 core: Add DelegateNamespaces=
This delegates one or more namespaces to the service. Concretely,
this setting influences in which order we unshare namespaces. Delegated
namespaces are unshared *after* the user namespace is unshared. Other
namespaces are unshared *before* the user namespace is unshared.

Fixes #35369
2025-03-01 13:54:58 +01:00
Yu Watanabe
94dc76c996 test-network: extend test case for static routes
- split out verifications into two functions,
- also check the following scenarios:
  * unmanaging an existing interface,
  * re-managing an unmanaged interface,
  * adding a new unmanaged interface,
  * removing an unmanaged interface.
2025-02-28 08:51:14 +01:00
Lennart Poettering
46bd501faa Issue OSC ANSI sequence whenever we change "context" of a TTY, i.e. acquire privs, enter container or VM or similar (#35224)
This is mostly a strawman to get a discussion going regarding how to
communicate to terminal emulators such as ptyxis about run0 (and nspawn,
and vmspawn, and moe) and what it does.

It's hierarchical and I think still relatively simple.

/cc @chergert
2025-02-27 22:12:54 +01:00
Lennart Poettering
bbdad5c025 core: also issue OSC 3008 from service context
(Note: we also change TEST-13-NSPAWN.machined.sh minimally here, because
it checks for byte precise output of a pty allocated for a service
invocation - which it's not going to get if it claims that the pty is an
all-powerful one. After all this PR ensures that we'll generate the new
OSC sequence on non-dumb terminals associated with services. Hence, set
TERM=dumb explicitly to ensure no ANSI sequences are generated, ever.
Which is a nice test btw that TERM=dumb really does its thing here.)
2025-02-27 15:17:34 +01:00
Daan De Meyer
8c0098d486 sbsign: Add support for offline signing
Add new options --prepare-offline-signing, --signed-data= and
--signed-data-signature= which allow for offline signing in a
similar manner to pesign.
2025-02-27 13:47:07 +01:00
Yu Watanabe
44dc0c8c51 test: fix typo
Follow-up for f01132aacf.
2025-02-27 13:42:09 +09:00
Lennart Poettering
263ea62468 test: extend test case to validate per-area $XDG_RUNTIME_DIR 2025-02-26 22:07:05 +01:00
Lennart Poettering
9a4f9e84c4 pam_systemd_home: tweak order in authentication stack
Let's move pam_systemd_home before pam_unix in the authentication hook.

Since a while we are exposing shadow entries for homed log entries via
NSS. This means that pam_unix now potentially has enough data for
authenticating a user on its own, without letting pam_systemd_home do
that. This is superficially OK, but also means that authentication will
always go via password, even if pkcs11/fido2 is registered.

Let's move this around, but be careful about it: let's list the precise
errors which we think are enough to terminating further PAM processing,
so that pam_unix comes into control in all cases where it's not clear
that pam_systemd_home owns the user record.

This previously wasn't visible to me, because on Fedora until authselect
1.5.1 (released earleir this year) the NSS shadow stuff was not enabled.

This does the same also for the "account" stack, except that the order
there already was as we want it.

Finally, shorten the account stack, by just requiring pam_unix.so and
dropping pam_permit.so, because it doesn't really serve much purpose
(and Fedora doesn't use it by default either.)
2025-02-26 18:12:08 +01:00
Daan De Meyer
2dbc2d1d0f docs: Use mkosi -R instead of mkosi -t none (#36528)
mkosi now supports -R to rerun build scripts without rebuilding the
image so let's document that instead of the current hack to prevent
the rebuild by changing the output format.
2025-02-26 15:56:51 +01:00
Daan De Meyer
031a474c91 docs: Use mkosi -R instead of mkosi -t none
mkosi now supports -R to rerun build scripts without rebuilding the
image so let's document that instead of the current hack to prevent
the rebuild by changing the output format.
2025-02-26 14:58:53 +01:00
Jelle van der Waa
39936a1b89 test: assert that product_serial is preferred over board_serial 2025-02-26 11:18:08 +01:00
Daan De Meyer
75cf5b0d3a mkosi: Enable History= option
This option makes mkosi "remember" all the CLI options specified on
the command line when building an image. This means they don't need
to be specified again when booting the image afterwards or doing any
other operation on the image with "mkosi xxx".

As an example of how this is useful, currently, when running "mkosi
-d opensuse -f" to build an opensuse image and then running "mkosi
sandbox -- meson test -C build TEST-86-MULTI-UKI-PROFILE", running
the test will try to add virtiofs mounts of the fedora~rawhide build
directory on my machine instead of the opensuse one. With the History=
option enabled, it will use the opensuse tumbleweed directory as expected.

We stop setting --extra-search-path and --output-dir in the integration test
wrapper as these are settings that are "remembered" by enabling the History=
option.
2025-02-25 10:59:50 +01:00
Daan De Meyer
890e1ad318 test: Do not add integration tests if want_tests == 'false' 2025-02-25 10:59:50 +01:00
Daan De Meyer
ba29de84cf TEST-64-UDEV-STORAGE: Stop using mkosi configure scripts
Now that we have mkosi sandbox, meson runs with the mkosi tools tree
mounted (if one is used at all), so we can implement all the qemu feature
checks in meson itself, removing the need for mkosi configure scripts.
2025-02-25 10:13:50 +01:00
Daan De Meyer
2db2cb3034 TEST-53-ISSUE-16347: Implement rtc via custom argument
Let's get rid of the configure script for this use case by just
implementing the necessary logic in integration-test-wrapper.py.
We need to get rid of our usage of configure scripts to allow enabling
the History= setting.
2025-02-25 10:13:48 +01:00
Yu Watanabe
1930f5afe6 fuzz: decompress_startswith() may return zero (#36490)
Also, disables fuzz-compress on oss-fuzz.
Fixes #36472.
2025-02-25 11:05:06 +09:00
Dan Streetman
af69ea714d systemd-keyutil: add verb to conver PKCS#1 to PKCS#7
Add verb that takes a PKCS#1 signature (plain rsa) as input and a
certificates, and outputs a PKCS#7 binary detached signature (p7s),
which is what the kernel dm-verity driver expects.

Co-authored-by: Luca Boccassi <bluca@debian.org>
2025-02-23 14:14:09 +00:00
Yu Watanabe
339f2f2eeb fuzz: decompress_startswith() may return zero
Fixes #36472.
2025-02-23 05:04:49 +09:00
Lennart Poettering
3d49850096 import-generator: give import services better names
Previously, we'd name the import services numerically. Let's instead use
the local target file name, i.e. the object we are creating with these
services locally. That's useful so that we can robustely order against
these service instances, should we need to one day.
2025-02-21 10:03:32 +01:00
Lennart Poettering
b4bee5684d fstab-generator: support creating bind mounts via root= kernel cmdline switches
This is useful for bind mounting a freshly downloaded and unpacked tar
disk images to /sysroot to mount into.

Specifically, with a kernel command line like this one:

  rd.systemd.pull=verify=no,machine,tar:root:http://_gateway:8081/image.tar root=bind:/run/machines/root ip=any

The first parameter downloads the root image, the second one then binds
it to /sysroot so that we can boot into it.
2025-02-21 10:03:32 +01:00