Commit Graph

5640 Commits

Author SHA1 Message Date
Yu Watanabe
90cf374e45 run: add --job-mode= argument (#34708)
systemctl has a --job-mode= argument, and adding the same argument to
systemd-run is useful for starting transient scopes with dependencies.
For example, if a transient scope BindsTo a service that is stopping,
specifying --job-mode=replace will wait for the service to stop before
starting it again, while the default job mode of "fail" will cause the
systemd-run invocation to fail.
2025-01-23 18:11:30 +09:00
Gavin Li
706a953504 run: add --job-mode= argument
systemctl has a --job-mode= argument, and adding the same argument to
systemd-run is useful for starting transient scopes with dependencies.
For example, if a transient scope BindsTo a service that is stopping,
specifying --job-mode=replace will wait for the service to stop before
starting it again, while the default job mode of "fail" will cause the
systemd-run invocation to fail.
2025-01-23 02:08:32 -05:00
Yu Watanabe
b6b8148459 core/device: do not drop backslashes in SYSTEMD_WANTS=/SYSTEMD_USER_WANTS= (#35869)
Let consider the following udev rules:
```
PROGRAM="/usr/bin/systemd-escape foo-bar-baz", ENV{SYSTEMD_WANTS}+="test1@$result.service"
PROGRAM="/usr/bin/systemd-escape aaa-bbb-ccc", ENV{SYSTEMD_WANTS}+="test2@$result.service"
```
Then, a device expectedly gains a property:
```
SYSTEMD_WANTS=test1@foo\x2dbar\x2dbaz.service test2@aaa\x2dbbb\x2dccc.service
```
After the event being processed by udevd, PID1 processes the device, the
property previously was parsed with
`extract_first_word(EXTRACT_UNQUOTE)`, then the device unit gained the
following dependencies:
```
Wants=test1@foox2dbarx2dbaz.service test2@aaax2dbbbx2dccc.service
```
So both `%i` and `%I` for the template services did not match with the
original data, and it was hard to use `systemd-escape` in `PROGRAM=`
udev rule token.

This makes the property parsed with
`extract_first_word(EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE)`, hence the
device unit now gains the following dependencies:
```
Wants=test1@foo\x2dbar\x2dbaz.service test2@aaa\x2dbbb\x2dccc.service
```
and `%I` for the template services match with the original data.

Fixes a bug caused by ceed8f0c8b (v233).

Fixes #16735.
Replaces #16737 and #35768.
2025-01-23 09:04:12 +09:00
Yu Watanabe
af9e8ad4e8 pretty-print: fix handling of line continuation in cat_file() (#35886)
Fixes #35878.
2025-01-23 08:59:24 +09:00
Yu Watanabe
60ce6a3413 test-network: add test case for [IPv6RoutePrefix] Preference= 2025-01-22 20:48:31 +00:00
Yu Watanabe
41a1e3012e TEST-65-ANALYZE: add detailed test case for cat-config 2025-01-22 20:43:16 +00:00
Yu Watanabe
4c9da4dc91 test: add test cases for parsing SYSTEMD_WANTS=/SYSTEMD_USER_WANTS= 2025-01-22 20:41:00 +00:00
Daan De Meyer
d3d501e949 test: Make sure we run lcov from the meson source directory
In ac75c51927, we accidentally changed
the working directory that the tools executed in the wrapper script
are invoked in. This broke our invocations of lcov. Let's explicitly
run those in the meson source directory again to fix the coverage
workflow.
2025-01-23 01:32:37 +09:00
Yu Watanabe
e887b3006c networkd-test: unconditionally stop previous invocation of networkd before starting new one
When networkd is already running, creating some .network files and
friends and starting networkd does not take any effect. Let's always
restart networkd when we want to start a new invocation.
2025-01-22 10:29:59 +00:00
Daan De Meyer
d641a1f8f7 mkosi: Various tools tree fixes (#36059) 2025-01-21 15:17:36 +01:00
Daan De Meyer
c0165676e9 TEST-74-AUX-UTILS: Move run0 pcrlock test to TEST-70-TPM
On CentOS Stream 9/10 booting mkosi qemu with --firmware=linux doesn't
add the virtual TPM to the virtual machine which means TEST-74-AUX-UTILS.run.sh
fails because it requires a TPM.

Let's move the systemd-pcrlock logic that requires a TPM to
TEST-70-TPM.pcrlock to avoid the problem.
2025-01-21 13:48:13 +01:00
Daan De Meyer
34da8dd345 test: Look for qemu in /usr/libexec/qemu-kvm as well
On CentOS Stream, the qemu binary is /usr/libexec/qemu-kvm so use
that if it's available.
2025-01-21 12:29:56 +01:00
Lennart Poettering
853e9b754a test: add test for homed alias and realm user resolution 2025-01-21 09:59:13 +01:00
Yu Watanabe
e7e707f058 networkd-test.py: generate debugging logs of networkd 2025-01-21 09:48:17 +01:00
Luca Boccassi
175cb87a1c measure: add policy-digest verb
When doing offline signing we need to know the exact payload
to sign, and the 'calculate' verb doesn't really show that, it
shows the PCR values. But what we sign is the hash of the policy.
So add a new verb that outputs the json payload that goes in the
.pcrsig section, without the .sig object, so that we can take them
and give the .pol object to an offline and asynchronous signing
service, such as SUSE's Open Build Service, and then add the .sig
object to the json and attach it to a UKI.
2025-01-21 00:07:58 +00:00
Yu Watanabe
25a2e4738b udevadm-control: allow to enable/disable trace logging in systemd-udevd
Should be useful for debugging udev rules.
2025-01-21 04:12:18 +09:00
Lennart Poettering
078ddcb7ce test: add superficial test for generic per-service varlink API 2025-01-18 23:24:29 +01:00
Yu Watanabe
8846df63fa udevadm-test: introduce -v/--verbose option to show verbose log messages
Currently this does not show any extra log messages. In later commits,
more verbose log messages will be added.
2025-01-18 04:19:52 +09:00
Luca Boccassi
0ec19b311b test: add link to Ubuntu autopkgtest status page in README
Known issues will be listed there by the team managing the infra
2025-01-16 14:50:55 +01:00
Lennart Poettering
09fbff57fc pid1: add GracefulOptions= setting to .mount units
This new setting can be used to specify mount options that shall only be
added to the mount option string if the kernel supports them.

This shall be used for adding "usrquota" to tmp.mount without breaking compat,
but is generally be useful.
2025-01-15 21:05:06 +01:00
Lennart Poettering
ef5f72437e run0: allow explicit control of service manager activation for run0 sessions
This adds a new --lightweight=yes/no switch which allows controlling
whether the invoked service will have the service manager around or not.

Moreover, this changes that if the target user is root it will now
support to the lightweight mode, i.e. run0 towards root will no longer
pull in the service manager (a real tty login via getty still will
though!).

My thinking here is that quickly raising privileges via run0 probably
shouldn't be considered a proper login but just something short lived,
temporary for a single command or similar.
2025-01-15 17:03:21 +01:00
Lennart Poettering
cf8f6cd057 logind: introduce "user-light" session class
This new session class is to "user" what "background" is to
"background-light": it doesn't cause the per-user service manager to
start.

This new session class is now the default if no session class was
provided at session registration time and the following conditions hold:

1. The session is not graphical
2. The user is not a regular user (but not root)

Or in other words root and system users won't get a service manager
started automatically if they go through a PAM session as part of things
like cron or ftp. They will however still get one if they log in
graphically.

This changes behaviour a bit, but hopefully in OK was.

This also makes "background-light" for system users incl. root.

This addresses one of the ideas discussed in #34988.
2025-01-15 17:03:21 +01:00
Lennart Poettering
d2c7f8242b logind: register PAM sessions via Varlink instead of D-Bus (#35264)
This makes things a bit faster (because it cuts down a bit on
roundtrips) and prepares ground so that one day we can let logind run in
earlier boot already, making it a bit less special.

communication between logind and pid1 is still dbus only, hence there's
a lot of room for further improvement I guess.
2025-01-15 16:53:43 +01:00
Lennart Poettering
fc6192f52b machine: introduce io.systemd.MachineImage.SetPoolLimit (#35953)
This PR introduces io.systemd.MachineImage.SetPoolLimit method which is
alternative to DBus's SetPoolLimit.

This is last function for org.freedesktop.machine1 Dbus interface
2025-01-15 16:52:24 +01:00
Lennart Poettering
2baca6c22b logind: add basic Varlink API
For now this only covers CreateSession() and ReleaseSession(), i.e. the
two operations pam_systemd cares about.
2025-01-15 11:56:47 +01:00
Ivan Kruglov
4daecc8af5 machine: tests for io.systemd.MachineImage.SetPoolLimit 2025-01-15 02:47:58 -08:00
Daan De Meyer
ac75c51927 test: Drop sandbox() from integration test wrapper
With the latest changes, this is not required anymore as mkosi sandbox
will set up the proper $PATH to make sure the executables from the build
directory are used.
2025-01-15 10:21:33 +01:00
Sea-Eun Lee
015a3b8cb1 oomd: support reloading configuration at runtime 2025-01-14 14:42:23 +01:00
Daan De Meyer
3c2fa8e050 fmf: Only move logs if corresponding directory exists
Otherwise find fails with an error.
2025-01-14 12:07:53 +01:00
Daan De Meyer
1d77ac19cf test: Only move journal file if we didn't just unlink it 2025-01-14 10:21:45 +01:00
Daan De Meyer
79ac78e368 test: Fix bug in integration test wrapper 2025-01-13 11:06:37 +01:00
Daan De Meyer
e0c2fd6a33 fmf: Skip TEST-21-DFUZZER
Similar to Github Actions, since we don't build with sanitizers in
the packit job, let's skip TEST-21-DFUZZER.
2025-01-10 16:14:01 +01:00
Daan De Meyer
53546c71fe fmf: Use different heuristic on beefy systems
If we save journals in /tmp, we can run a larger number of tests in
parallel so let's make use of the larger number of CPUs if the tests
run on a beefy machine.
2025-01-10 16:14:01 +01:00
Daan De Meyer
c32a8cdaa0 fmf: Bump inotify limits to avoid systemd-nspawn failures 2025-01-10 16:14:01 +01:00
Daan De Meyer
1f17ec0ed4 test: Move StateDirectory= directive into dropin
The integration-test-setup calls require StateDirectory= but some
tests override the test unit used which then won't have StateDirectory=
so let's move StateDirectory= into the dropin as well to avoid this
issue.
2025-01-10 16:14:01 +01:00
Daan De Meyer
84b30442d2 test: Don't register machines with machined unless we're in interactive mode 2025-01-10 16:14:01 +01:00
Daan De Meyer
e49fdecd16 test: Add option to save in progress test journals to /tmp
The journal isn't the best at being fast, especially when writing
to disk and not to memory, which can cause integration tests to
grind to a halt on beefy systems due to all the systemd-journal-remote
instances not being able to write journal entries to disk fast enough.

Let's introduce an option to allow writing in progress test journals
to use /tmp which can be used on beefy systems with lots of memory to
speed things up.
2025-01-10 16:13:58 +01:00
Daan De Meyer
96403d5121 tree-wide: Fix python formatting
The new release of ruff formats a few more things which causes linter
failures in CI so let's fix those formatting nits.
2025-01-10 14:58:56 +09:00
Yu Watanabe
ac27ee5fcb fmf: Move meson logs and failed test journals to test artifacts dir (#35939) 2025-01-10 14:57:57 +09:00
Daan De Meyer
8965d57f4b fmf: Use one fewer than number of available CPUs again
This effectively reverts b8582198ca
as I can not get the testing farm bare metal machines working
downstream and even if I managed to, without also using the testing
farm bare metal machines upstream (for which there is no capacity),
the setup would very quickly bitrot anyway so we'll just run the
container based tests for now.
2025-01-09 15:45:41 +01:00
Daan De Meyer
6e761c5a93 fmf: Log clock source 2025-01-09 15:24:51 +01:00
Daan De Meyer
0e444c948e fmf: Move meson logs and failed test journals to test artifacts dir 2025-01-09 15:13:18 +01:00
Lennart Poettering
c0041cd8f1 pam: add session class "none" to disable logind sessions (#35171)
pam_systemd is used to create logind sessions and to apply extended
attributes from json user records. Not every application that creates a
pam session expects a login scope, but may be interested in the extended
attributes of json user records. Session class "none" implements this
service by disabling logind for this session altogether.

---

Closes: #34988
2025-01-09 14:08:06 +01:00
Daan De Meyer
606034cc1e machine: introduce io.systemd.Machine.OpenRootDirectory method (#35880)
This PR introduces io.systemd.Machine.OpenRootDirectory method which is
DBus's alternative to OpenMachineRootDirectory.
2025-01-09 13:06:38 +01:00
Daan De Meyer
103e92810a mkosi: Re-enable TEST-21-DFUZZER when running with sanitizers
Similar to how CentOS CI did it previously, let's only run
TEST-21-DFUZZER when built with sanitizers for maximum effect.
2025-01-09 11:48:23 +00:00
Daan De Meyer
c286e8b616 Two integration test fixes (#35937) 2025-01-09 12:25:41 +01:00
Daan De Meyer
e1c883bf32 fmf: Force SELinux relabel when running within testing farm
We expect to run as root within testing farm and to have permissions
to do selinux relabelling so let's enable it explicitly.
2025-01-09 11:59:34 +01:00
Daan De Meyer
de19520ec9 TEST-06-SELINUX: Add knob to allow checking for AVCs
When running the integration tests downstream, it's useful to be
able to test that a new systemd version doesn't introduce any AVC
denials, so let's add a knob to make that possible.
2025-01-09 11:59:30 +01:00
Daan De Meyer
794d456cf4 test: Only plug in integration-test-setup.sh in interactive mode
If we're not running interactively, there's no point in the features
from integration-test-setup.sh which are intended for interactive
development and debugging so lets skip adding it in that case.
2025-01-09 11:28:15 +01:00
Daan De Meyer
90538ede55 test: Drop set -x from integration-test-setup.sh 2025-01-09 11:27:51 +01:00