Commit Graph

5741 Commits

Author SHA1 Message Date
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
Lennart Poettering
a932d2f23e test: fix racy machined test
Previously, one of the io.systemd.Machine.Open() tests would invoke a
command line via machined, and then check if it ran properly. This was
implemented in a racy fashion: the client side would immediately close
the pty fd allocated for the operation, thus triggering an immediate
SIGHUP on the other side. Now, depending whether this client was quicker
in closing or the server was quicker in executing the command line this
was a race.

Fix this comprehensively: let's first wait for the varlink operation to
complete via the new "systemd-notify --fork" logic (because varlinkctl
sends out READY=1 once handing off to --exec). Secondly let's use
varlinkctl's --exec logic to invoke a process which keeps open the open
pty until we kill it (we just use sleep for that).

(Also add some more tests for the varlinkctl --exec stuff)
2025-02-20 18:12:13 +01:00
Lennart Poettering
6828cc112a resolve: cleanups for validating query flags and fix resolving service with record type filter (#36398)
Follow-up for 81ae2237c1.
Fixes
https://github.com/systemd/systemd/pull/36353#issuecomment-2659558382.
2025-02-20 17:31:19 +01:00
Pavithra Barithaya
6a12c90ca3 timedated: Send error when time set is past build date time
When the user/customer sets the time on the system which is prior
than that of the systemd build time, as systemd doesn't allow time
before it's build date after a reboot, systemd is resetting it but
there is no error or exception present in the setTime method due
to which user/customer is unaware of why the time is reset back to
the systemd-build time.

Added a condition check in the set_time() method to return an
error when tried to set time past the systemd build date.

Tested: Verified that it throws an error when we try to set the
time prior to systemd build date.

Change-Id: Ia6b58320bdb7234a21885a44af8fd3bda64c3789
2025-02-20 15:22:15 +01:00
Daan De Meyer
a102b28ad4 mkosi: Do not run unit tests during build by default (#36450) 2025-02-20 13:25:03 +01:00
Daan De Meyer
bddfcd9629 mkosi: Do not run unit tests during build by default
We want the incremental builds to be as fast as possible, so let's
not run the unit tests locally during the image build by default.
2025-02-20 10:31:19 +01:00
Luca Boccassi
5dbc4f37c5 tree-wide: tweaks to mount point inode creation (#36308)
Some love for make_mount_point_inode_from_xyz() and ports PID 1 over to
it for mount units.

Alternative to #36290
2025-02-19 22:09:52 +00:00
Luca Boccassi
4225242149 repart: add parameter to attach offline verity signature (#36405)
Add --join-signature=hash:sig - when a verity signature partition
has been deferred in a previous run, this allows attaching a signature
that was created offline, for example on a build system like OBS where
the private key is not available to the build process.

Can be specified multiple times, the right partition to act upon will
be selected by matching the data+verity partitions UUIDs with the
provided roothash(es)
2025-02-19 18:12:19 +00:00
Luca Boccassi
09fd125059 repart: add parameter to attach offline verity signatures
Add --join-signature=hash:sig - when a verity signature partition
has been deferred in a previous run, this allows attaching a signature
that was created offline, for example on a build system like OBS where
the private key is not available to the build process.

Can be specified multiple times, the right partition to act upon will
be selected by matching the data+verity partitions UUIDs with the
provided roothash(es)
2025-02-19 16:26:05 +00:00
Yu Watanabe
134bb7bfdf nspawn: unconditionally enable FUSE and use FOREACH_ARRAY() (#36407)
- FUSE is unconditionally enabled in the container, as our kernel base
line (v5.4) supports userns-safe FUSE, which is supported since v4.18.
- Create /dev/net/tun only when it is accessible.
- Replaces several loops with FOREACH_ARRAY().
2025-02-19 02:09:58 +09:00
Yu Watanabe
011a83e42b network: fix KeepConfiguration=yes (#36414)
Fixes a regression in dd6d53a8dc (v257).
Fixes #36411.
2025-02-19 02:09:09 +09:00
Steve Ramage
a4750ae156 network: doc and code typo fixes (#36422)
This fixes some typos in the documentation, both grammar as well as
incorrect field names.
It also changes the casing of CheckSum to Checksum in L2TP to match
other casings.
2025-02-19 02:08:16 +09:00
Yu Watanabe
9fff6bf59e nspawn: create /dev/net/tun only when it is accessible
Follow-up for 985ea98e7f.

When DevicePolicy= is enabled, but DeviceAllow= for /dev/net/tun is not
specified, bind-mounting the device node from the host system is
meaningless, as it cannot be used in the container anyway.

Let's check the device node is accessible before creating or
bind-mounting.
2025-02-18 23:24:20 +09:00
Yu Watanabe
1cac0676da test-network: add test case for KeepConfiguration=yes with RTPROT_BOOT
For issue #36411.
2025-02-18 23:01:53 +09:00
Lennart Poettering
a34ce4842b ci: test new logic 2025-02-18 13:49:24 +01:00
Yu Watanabe
7ffa9dc616 TEST-75-RESOLVED: add test cases for resolving service with record type filter 2025-02-16 23:22:50 +09:00
Yu Watanabe
d13b5fdc01 TEST-75-RESOLVED: check TXT field 2025-02-16 23:10:16 +09:00
Yu Watanabe
5a07bb2c55 TEST-75-RESOLVED: revert changes done in each test case 2025-02-16 22:55:22 +09:00