Commit graph

1742 commits

Author SHA1 Message Date
Daan De Meyer dcbf0be1b7 TEST-50-DISSECT: Don't log image contents to console
These can contain quite a few files, so let's not write every single
file and directory straight to the console to speed things up.
2024-04-26 13:51:49 +02:00
Daan De Meyer 536b5c0748
Merge pull request #32445 from DaanDeMeyer/mkosi-images
mkosi: Build minimal images and enable related integration tests
2024-04-25 21:59:23 +02:00
Daan De Meyer c77dad706b mkosi: Build minimal images and enable related integration tests
This commit adds definitions to build the minimal_0 and minimal_1
images with mkosi and includes them into the system image. We also
move the building of the various app-xxx and similar images that are
extremely minimal into the tests itself by moving the related logic
from install_verity_minimal() into a new function
install_extension_images() in util.sh. Because the mkosi /usr is
read-only, we now place the extension images in /tmp instead of
/usr/share.

Co-authored-by: Richard Maw <richard.maw@codethink.co.uk>
Co-authored-by: sam-leonard-ct <sam.leonard@codethink.co.uk>
2024-04-25 21:06:30 +02:00
Daan De Meyer 69dc36f69b TEST-50-DISSECT: Make sure logging sockets are mounted into images
Otherwise we lose valuable logging from systemd-executor when things
go wrong since it can only log to the journal and not to the console
in these cases.
2024-04-25 19:39:31 +02:00
Luca Boccassi d1c4174d69
Merge pull request #32475 from bluca/skip
test: skip testsuite-50.mountnfsd if kernel/polkit are too old
2024-04-25 18:48:57 +02:00
Luca Boccassi f9419fe610 test: skip testsuite-50.mountnfsd if kernel/polkit are too old
Need full support of pidfd to work, so skip the test if it's not
available
2024-04-25 13:32:35 +01:00
Luca Boccassi c790537b89 test: use sd-analyze for kernel version check in TEST-62 2024-04-25 13:32:10 +01:00
Lennart Poettering 3c1d1ca146 manager: switch service unit type over to using new handoff timestamping logic
Also: rename Handover → Handoff. I think it makes it clearer that this
is not really about handing over any resources, but that the executor is
out off the game from that point on.
2024-04-25 13:40:41 +02:00
Daan De Meyer 5ae6ff1258 TEST-50-DISSECT: Skip mutable sysext tests on virtiofs
virtiofs cannot be used as the upper fs for overlayfs, so skip all
the sysext mutable tests that would try to use virtiofs as the
upper fs.
2024-04-24 19:30:00 +02:00
Daan De Meyer c709499a4e TEST-50-DISSECT: Use --apparent-size when calling du
Otherwise if the file is full of holes we get the wrong size and
we'll fail later on.
2024-04-24 15:51:37 +02:00
Daan De Meyer 2a9184b902 TEST-50-DISSECT: Skip mountfsd test if the user namespace interface is not supported 2024-04-24 15:51:35 +02:00
Richard Maw 796cf1b483 test: document when writable /usr overlays may be needed 2024-04-24 11:01:45 +02:00
Daan De Meyer 741d59b326 test: Rework TEST-02-UNITTESTS
Currently, A large amount of unit test output is logged directly
to the console instead of to the per test log file as any subprocesses
executed by a test manager will detect that stderr is not connected
to the journal and log directly to /dev/console instead.

To solve this issue, let's make sure all tests are connected directly
to the journal by running them with systemd-run. We also simplify the
entire test script by getting rid of the custom queue and replicating
it with xargs instead. By using bash's function export feature, we can
make our run_test() function available to the bash subprocess spawned
by xargs.

Once a test is finished, we read its logs from the journal and put them
in the appropriate file if needed.
2024-04-22 19:37:13 +02:00
Luca Boccassi edd3d4d7c2 nspawn: ensure single-process container running as --user can access credentials
When starting a container with --user, the new uid will be resolved and switched to
only in the inner child, at the end of the setup, by spawning getent. But the
credentials are set up in the outer child, long before the user is resolvable,
and the directories/files are made only readable by root and read-only, which
means they cannot be changed later and made visible to the user.

When this particular combination is specified, it is obvious the caller wants
the single-process container to be able to use credentials, so make them world
readable only in that specific case.

Fixes https://github.com/systemd/systemd/issues/31794
2024-04-22 15:47:44 +02:00
Luca Boccassi 93cb78aee2 core: add ExecMainHandoverTimestamp property recording time-of-execve
Enable the exec_fd logic for Type=notify* services too, and change it
to send a timestamp instead of a '1' byte. Record the timestamp in a
new ExecMainHandoverTimestamp property so that users can track accurately
when control is handed over from systemd to the service payload, so
that latency and startup performance can be trivially and accurately
tracked and attributed.
2024-04-22 15:16:05 +02:00
Lennart Poettering b7866fa6aa
Merge pull request #31987 from flatcar-hub/krnowak/usr-perm-check
sysext: Fix issues with merged hierarchy mode
2024-04-22 11:14:35 +02:00
Luca Boccassi 8257508c58 portable: support vpick
Resolve at attach/detach/inspect time, so that the image is pinned and requires
re-attaching on update, given files are extracted from it so just passing
img.v/ to RootImage= is not enough to get a portable image updated
2024-04-19 13:25:32 +01:00
Krzesimir Nowak d74d69ae53 test: Make the sysext test to run with --root and without
I was bitten several times by testing things only with --root flag, so this
commit prepares the existing test cases to run on / too. This required the test
cases to clean up after themselves, thus I have put each test case in a
separate subshell and used traps to do the cleanups.

I needed to change the hierarchy used by the test extension to /opt, because
unmounting /usr often failed with EBUSY.
2024-04-19 10:24:17 +02:00
Krzesimir Nowak 60c335a4bc test: Do not limit hierarchies 2024-04-19 07:20:52 +02:00
Krzesimir Nowak 140f834333 test: Add sysext test case for checking valid mutable directory mode 2024-04-19 07:18:38 +02:00
Krzesimir Nowak 6aab53b175 test: Add sysext test-cases for checking mode preservation 2024-04-19 07:15:01 +02:00
Lennart Poettering dd37963aff
Merge pull request #31790 from poettering/pcrlock-policy-fix
Replace PolicyAuthValue by PolicySigned as access policy for pcrlock policy nvindex
2024-04-18 21:11:27 +02:00
Lennart Poettering 36769db1b0 ci: update tests to showcase new option a bit 2024-04-18 18:12:24 +02:00
Luca Boccassi 966d7977c7 portablectl: add --clean parameter for detaching
Calls CleanUnit on each portable service being removed, after it has
stopped
2024-04-18 10:47:29 +01:00
Yu Watanabe 88382e8dab test: fix typo
Follow-up for 236634c82c.
2024-04-17 13:29:39 +09:00
Yu Watanabe e27f2ad6be
Merge pull request #32300 from mrc0mmand/assorted-tweaks
test: split TEST-50-DISSECT into smaller parts
2024-04-17 11:52:30 +09:00
Sam Leonard b6183109cb
test-64-udev-storage: partition disk inside testcase - testcase_multipath_basic_failover 2024-04-16 17:02:31 +01:00
Sam Leonard 211062e3b5
test-64-udev-storage: partition disk inside testcase - testcase_virtio_scsi_identically_named_partitions 2024-04-16 16:18:55 +01:00
Sam Leonard 8d82e39046
test-64-udev-storage: partition disk inside testcase - testcase_long_sysfs_path 2024-04-16 16:18:36 +01:00
Frantisek Sumsal 236634c82c test: rework systemd-sysext test
Let's rework the test a bit, namely:
  - condense the code a bit
  - drop unnecessary braces around variables
  - drop unnecessary explanations around `touch` calls
  - drop/rename functions to make the code more self-explanatory
  - simplify cleanup a bit
  - create R/O bind mounts directly (supported since util-linux 2.27)
2024-04-16 14:25:57 +02:00
Frantisek Sumsal 5f42fae2f1 test: simplify unit check 2024-04-16 14:25:57 +02:00
Frantisek Sumsal 5d259f1236 test: split some overly long lines
Let's get the line count back up again by splitting some overly long
lines in hopes to make the code slightly more readable.
2024-04-16 14:25:57 +02:00
Frantisek Sumsal ccb2671539 test: split TEST-50-DISSECT into smaller parts
As the current version has almost 2k lines.
2024-04-16 14:25:57 +02:00
Yu Watanabe 78d5bad2f5
Merge pull request #32294 from yuwata/network-generator-creds
network-generator: also load drop-ins for networkd.conf from credentials
2024-04-16 16:42:59 +09:00
Yu Watanabe 9c202ba2e2 test: add test case for 'networkctl cat' without arguments 2024-04-16 13:31:14 +09:00
Yu Watanabe 9a4a8fbe48 test: add test case for network.conf.* credential 2024-04-16 12:45:08 +09:00
Yu Watanabe a3e4edd1af test: add test for systemd-udev-load-credentials.service 2024-04-16 10:35:13 +09:00
Yu Watanabe b2800ec597 udevadm-control: check if control command really specified
Previously, 'udevadm control' only checked the number of the arguments.
So, if only `--timeout` is specified, it spuriously did nothing and succeeded.
This makes the command request at least one control command.
2024-04-16 09:42:20 +09:00
Frantisek Sumsal 6d13aacaac test: make sd-journal-gatewayd tests even more debug-able
Unfortunately bfd30e8af6 is not enough and the test fails, that still
occasionally occur, don't provide enough information to see what's
wrong. Let's rework the test a little to improve this, namely:

  - redirect curl's output into a temporary file instead of piping it
    directly into the "check" expression; that way we can simply dump
    the temporary file when the test fails, providing potentially
    crucial information. We don't want to always dump everything to
    stdout, as some of the tests request an entire system journal (note
    that shell redirection instead of `curl -o file` is used
    intentionally, so the output file is always nuked first)
  - by dropping the pipes in curl commands we can re-enable pipefail
  - also, split some very long commands to multiple lines to (slightly)
    improve readability

Follow-up for bfd30e8af6.
2024-04-11 14:42:45 +02:00
Mike Yuan 48c21790ba
test: merge TEST-77-OPENFILE into TEST-23-UNIT-FILE
And add coverage for #32179
2024-04-10 21:49:28 +08:00
Frantisek Sumsal 721e78ff73 test: give sd-resolved enough time to timeout
The timeout on sd-resolved's side is 5-10s (UDP or TCP), but dig's
default timeout is 5s. Let's give sd-resolved enough time to timeout
before either giving up or checking if it served stale data on dig's
side.

Resolves: #31639
2024-04-09 21:39:46 +02:00
Frantisek Sumsal bfd30e8af6 test: let curl show a potential error in silent mode
I collected a couple of fails in this particular test, but without any
output they're impossible to debug. Let's make this slightly less
annoying and let curl show an error (if any) even in silent mode.

This patch uncovers that curl has been (silently) complaining about not
being able to write to the output destination, because `grep -q`
short-circuits on the first match and doesn't bother reading the rest,
so replace `grep -q` with `grep ... >/dev/null` to force grep to always
read the whole thing from curl.
2024-04-09 21:39:46 +02:00
Lennart Poettering 625646815b test: add integration test for unpriv mountfsd/nsresourced 2024-04-06 16:09:10 +02:00
Zbigniew Jędrzejewski-Szmek c1e7f938ca
Merge pull request #31435 from bluca/portable_fix_versioned
portable: assorted bug fixes
2024-04-05 17:04:17 +02:00
Zbigniew Jędrzejewski-Szmek cdba129b71 TEST-50: add tests for riscv{32,64}
Requested for the testing of F40 riscv bringup. Numbers copied from
https://uapi-group.org/specifications/specs/discoverable_partitions_specification/.

It'd be nice to do the same in TEST-58, but the code there is rather involved
and I don't have a system to test on. We can probably try that later on when F40
is available.
2024-04-04 20:07:57 +02:00
Daan De Meyer 7b62a246a6
Merge pull request #32033 from DaanDeMeyer/unit-creds
debug-generator: Add unit and drop-in credentials
2024-04-04 18:27:20 +02:00
Daan De Meyer 8595f578fe debug-generator: Add unit and drop-in credentials
These allow adding extra units and drop-ins via credentials.
2024-04-04 16:17:38 +02:00
Daan De Meyer c89b3e1dfd test: Always exit with 77 if we skip a test
Prep work for running the integration tests with meson, which requires
tests to exit with 77 to indicate they are skipped.

Note this only deals with the easy cases where there's only tests. The
hard ones where there's subtests of which only some are skipped are left
for another PR.
2024-04-03 09:14:15 +09:00
Frantisek Sumsal 5d7b7bf1d4 test: don't hide exit code of the systemd-run process 2024-04-02 19:00:42 +02:00
Frantisek Sumsal c956bf31f8 test: check if sd-executor doesn't complain during (de)serializing
This was usually caught by "accident" by other tests that parse output
of commands executed by sd-executor, so let's have an explicit check for
this.
2024-04-02 19:00:42 +02:00
Frantisek Sumsal 38d072a175 test: bump the container boot timeout when running w/o acceleration
With plain QEMU on a saturated AWS region we might just barely miss the
timeout window, causing unexpected test fails:

[  688.681324] systemd-nspawn[1332]: [  OK  ] Finished systemd-user-sessions.service.
[  689.451267] systemd-nspawn[1332]: [  OK  ] Started console-getty.service.
[  689.572874] systemd-nspawn[1332]: [  OK  ] Reached target getty.target.
[  693.634609] testsuite-74.sh[1223]: + at_exit
[  693.634609] testsuite-74.sh[1223]: + rm -fv -- /tmp/test-dump /tmp/test-usr-dump /tmp/make-dump
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/test-usr-dump'
[  693.838395] testsuite-74.sh[1502]: removed '/tmp/make-dump'
[  693.951114] testsuite-74.sh[670]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed'
[  693.951114] testsuite-74.sh[670]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-74.coredump.sh failed
[  693.951114] testsuite-74.sh[670]: + return 1
[  694.659094] systemd[1]: testsuite-74.service: Main process exited, code=exited, status=1/FAILURE
[  694.719563] systemd[1]: testsuite-74.service: Failed with result 'exit-code'.
[  694.882069] systemd[1]: Failed to start testsuite-74.service.
[  695.574445] systemd[1]: Reached target testsuite.target.
[  696.174844] systemd[1]: Starting end.service...
[  699.509408] systemd-nspawn[1332]:
[  699.509408] systemd-nspawn[1332]: CentOS Stream 9
[  699.509408] systemd-nspawn[1332]: Kernel 5.14.0-432.el9.x86_64 on an x86_64 (pts/0)
[  699.509408] systemd-nspawn[1332]:

Also, move the rest of container the setup for the user xattrs test into
the condition, since doing it without the actual test is pretty
pointless.
2024-04-02 19:00:24 +02:00
Luca Boccassi a7f2019055
Merge pull request #32010 from bluca/reexec_rate_limit
core: serialize reload rate limit and apply ReloadLimit to reexec too
2024-03-29 17:16:36 +00:00
Luca Boccassi 8312b17a29 core: apply ReloadLimit to reexec too
Same reason as the reload, reexec is disruptive and it requires the
same privileges, so if somebody wants to limit reloads, they'll also
want to limit reexecs, so use the same setting.
2024-03-29 12:03:32 +00:00
Yu Watanabe fee6510667
Merge pull request #31998 from yuwata/udev-event-mode
udev: make udevadm test and test-builtin not destructive
2024-03-29 11:31:58 +09:00
Yu Watanabe 089bef6631 udev: make udevadm test and test-builtin not destructive
Previously, 'udevadm test' performs not only processing udev rules,
but made several destructive change on the system; updating udev
database, device node permission, devlinks, network interface
properties, and so on.

Similary, 'udevadm test-builtin' may perform something destructive,
especially by 'keyboard', 'kmod', and 'net_setup_link' builtins.

Let's make these commands and test executables not change device
configurations.
2024-03-29 09:33:07 +09:00
Luca Boccassi 373a1e47b2 portable: fix 'portablectl list' to show the actual state for extensions
When listing images they are inspected one by one, so in case of a
portable with extensions they always resulted as not found.
Allow a partial match when listing, so that we can find the appropriate
unit that an image belongs to, and list the correct state as attached.
2024-03-28 14:20:20 +00:00
Luca Boccassi 1cbb792763 Ensure that a portable is not detached when another portable that shares the same base is detached
The matches line includes all images, but the logic returned
immediately with a successful match if the first element matches.
2024-03-28 14:20:20 +00:00
Luca Boccassi 37543971af os-util: allow matching versioned image with extension-release file
Currently app_1.0.raw is refused if it contains extension-release.d/extension-release.app,
which stops one from using versioned images without using the force flag to disable
the check. Relax it so that only the actual name, and not the version, is compared, like
it already happens in other places.
2024-03-28 14:20:20 +00:00
Yu Watanabe e4c7dc9418 test: disable IPv6AcceptRA= for test network interfaces with static address
This hopefully improves test performance.
2024-03-28 12:37:45 +00:00
Adrian Vovk 1eba24dac4 homed: Release(): fix assertion failure
This fixes a race condition crash in homed that would happen in the
following sequence of events:

1. Client 1 takes a ref on the home area
2. Client 1 calls some method via dbus
3. Client 2 calls Release()

In homed, the Release() would check if a ref is still held (in this
case: yes it is) and returns an error. Except that is done through a
code-path that asserts that no operations are ongoing. In this case,
it's valid to have an ongoing operation, and so the assertion fails
causing homed to crash.
2024-03-28 13:35:37 +09:00
Luca Boccassi ed35851693 run: fix generated unit name clash after soft-reboot
When sd-run connects to D-Bus rather than the private socket, it will
generate the transient unit name using the bus ID assigned by the D-Bus
broker/daemon. The issue is that this ID is only unique per D-Bus run,
if the broker/daemon restarts it starts again from 1, and it's a simple
incremental counter for each client.
So if a transient unit run-u6.service starts and fails, and it is not
collected (default on failure), and the system soft-reboots, any new
transient unit might conflict as the counter will restart:

Failed to start transient service unit: Unit run-u6.service was already loaded or has a fragment file.

Get the soft-reboot counter, and if it's greater than zero, append it
to the autogenerated unit name to avoid clashes.
2024-03-28 11:19:46 +09:00
Frantisek Sumsal c75ee69e59 test: cleanup the test script a bit 2024-03-27 20:15:02 +01:00
Frantisek Sumsal 0348b500ef test: check for /dev/loop-control when checking lodev availability
losetup in util-linux 2.40 started reporting lost loop devices [0] and
it has an unfortunate side-effect where it reports lost devices even in
containers, which then makes the loop device check "falsely" pass [1].

Let's just check for /dev/loop-control explicitly to "work around" this.

[0] a6ca0456cc
[1] https://github.com/util-linux/util-linux/issues/2824
2024-03-27 19:35:30 +01:00
Luca Boccassi 66f35161f6 core: add counter for soft-reboot iterations
Allow to query via D-Bus how many times the current booted system has
been soft rebooted
2024-03-27 01:27:35 +00:00
Jakub Sitnicki d1813ba436 test: integration test for PassFileDescriptorsToExec= option
Check if socket file descriptors are passed to ExecXYZ= commands from the
socket unit depending on whether PassFileDescriptorsToExec= option is set.
2024-03-27 01:41:26 +08:00
Luca Boccassi 14a5217679 resolved: support reloading configuration at runtime
Drop connections and caches and reload config from files, to allow
for low-interruptions updates, and hook up to the usual SIGHUP and
ExecReload=. Mark servers and services configured directly via D-Bus
so that they can be kept around, and only the configuration file
settings are dropped and reloaded.

Fixes https://github.com/systemd/systemd/issues/17503
Fixes https://github.com/systemd/systemd/issues/20604
2024-03-26 13:36:42 +00:00
Luca Boccassi 9065908483 test: use /run/ instead of /etc/ in TEST-75-RESOLVE 2024-03-26 12:52:42 +00:00
Zbigniew Jędrzejewski-Szmek c38e4e2fda
Merge pull request #29721 from poettering/systemd-project
New capsule@.service feature
2024-03-26 13:19:33 +01:00
Luca Boccassi b1d18b96c4
Merge pull request #31801 from flatcar-hub/krnowak/sysext-config
systemd-sysext: Add support for env vars, ephemeral layers and some fixes
2024-03-26 09:23:19 +00:00
Yu Watanabe 857f29a772 test: add test cases for journalctl --facility=/--output=help
Follow-up for d44233503f.
2024-03-26 04:18:23 +09:00
Yu Watanabe cbe884f13a test: add test cases for systemd-analyze --global
Follow-up for ac97053618.
2024-03-26 04:10:04 +09:00
Krzesimir Nowak 18c1ea41c1 test: Add cases for failures to import the hierarchy 2024-03-25 08:33:31 +01:00
Krzesimir Nowak baaa167926 test, sysext: Actually fail the whole operation if sd-merge worker failed
This also fixes a wrong merge failure check.
2024-03-25 08:33:22 +01:00
Krzesimir Nowak e2bdece284 test: Add test cases for sysext ephemeral-import mode 2024-03-25 08:30:09 +01:00
Krzesimir Nowak 153e7f7b24 test: Extend sysext tests with cases using ephemeral mode 2024-03-25 08:19:48 +01:00
Krzesimir Nowak 9245b547cc test: Extend sysext tests with cases using env var for mutable mode 2024-03-25 08:14:36 +01:00
Krzesimir Nowak 73cfa16d16 test: Fail sysext test if reusing a root directory 2024-03-25 08:14:36 +01:00
networkException f2cb9d17da bpf-socket-bind: fix unexpected behavior with either 0 allow or deny rules
This patch fixes an issue where, when not specifiying either at least one
`SocketBindAllow` or `SocketBindDeny` rule, behavior for the bind syscall
filtering would be unexpected.

For example, when trying to bind to a port with only "SocketBindDeny=any"
given, the syscall would succeed:

> systemd-run -t -p "SocketBindDeny=any" nc -l 8080

Expected with this set of rules (also in accordance with the documentation)
would be an Operation not permitted error.

This behavior occurs because a default initialized socket_bind_rule struct
matches what "any" represents. When creating the bpf list all elements get
default initialized, as such represeting "any". Seemingly it is necressarry
to set the size of the map to at least one, as such if no allow rule is
given default initialization and minimal map size cause one any allow rule
to be in the map, causing the behavior observed above.

This patch solves this by introducing a new "match nothing" magic stored in
the rule's address family and setting such a rule as the first one if no
rule is given, making sure that default initialized rule structs are never
used.

Resolves #30556
2024-03-24 11:08:58 +00:00
Adrian Vovk 269a3fe245 TEST-46-HOMED: Disable auth rate-limiting
Rate limiting authentication attempts in the test can cause somewhat
sporadic test failures: adding a test case might suddenly cause future
test cases to fail because of too many authentication attempts too
quickly

We're not trying to test the rate-limiting, we're trying to test the
functionality of homed. So we effectively disable rate-limiting on all
the home areas we create
2024-03-23 01:05:13 +00:00
Adrian Vovk d94c7eef12 homework: Implement offline updates
This makes it possible to update a home record (and blob directory) of a
home area that's either completely absent (i.e. on a USB stick that's
unplugged) or just inaccessible due to lack of authentication
2024-03-23 01:05:13 +00:00
Adrian Vovk 5ec87d577f homework: Accept volume key from keyring
This bypasses authentication (i.e. user_record_authenticate) if the
volume key was loaded from the keyring and no secret section is
provided.

This also changes Update() and Resize() to always try and load the
volume key from the keyring. This makes the secret section optional for
these methods while still letting them function (as long as the home
area is active)
2024-03-23 01:05:13 +00:00
Daan De Meyer 27add528d7 test: Install test journals
Let's package these just like we package other test data.
2024-03-22 15:11:39 +01:00
Yu Watanabe bf995423fd test: add test case for issue #31776 2024-03-21 04:44:39 +09:00
Zbigniew Jędrzejewski-Szmek 7aed434371 Rename uid0 to run0
Naming is always a matter of preference, and the old name would certainly work,
but I think the new one has the following advantages:
- A verb is better than a noun.
- The name more similar to "the competition", i.e. 'sudo', 'pkexec', 'runas',
  'doas', which generally include an action verb.
- The connection between 'systemd-run' and 'run0' is more obvious.

There has been no release yet with the old name, so we can rename without
caring for backwards compatibility.
2024-03-19 16:37:22 +01:00
Zbigniew Jędrzejewski-Szmek 3df28dd9b6 test/TEST-46: drop whitespace after redirection operators 2024-03-15 16:07:58 +01:00
Lennart Poettering a037f2eb9b test: add integration test for capsules 2024-03-14 11:34:04 +01:00
Mike Yuan 45bcab66a9
journal/cat: allow connecting output to specific journal namespace 2024-03-14 14:25:53 +08:00
Lennart Poettering cf1c8cdb87 resolved: expose raw RR resolver via Varlink too
Now that we have an address, hostname, and service resolve, at the last
kind of resovler we expose over D-Bus also to Varlink.
2024-03-06 19:00:53 +01:00
Luca Boccassi ba6ec879bb
Merge pull request #31621 from poettering/resolved-proxy-do
resolved: proxy upstream local requests to our stub with DO bit set
2024-03-06 13:55:14 +00:00
Frantisek Sumsal 4e5a7e1923 test: use 'ahost' instead of 'hosts' where applicable
As explained in [0] the 'hosts' database uses deprecated
gethostbyname2() which uses AF_INET6 instead of AF_UNSPEC for IPv6
lookups which is broken and makes the test fail with disabled IPv6.

[0] https://github.com/systemd/systemd/pull/28136#issuecomment-1974901039
2024-03-06 01:15:30 +00:00
Lennart Poettering df81adba88 ci: disable test that is now answered by knot
dig question with DNSSEC on will now be proxied upstream, i.e. to the
test knot server. This leads to different results, but the result isn't
tha tinteresting since we don't want to test knot, but resolved. Hence
comment this test.

There seems to be something wrong with the test though, as the upstream
server refused recursion, but if so it is not suitable as an upstream
server really, as resolved can only be client to a recursive resolver.
2024-03-05 15:29:19 +01:00
Lennart Poettering befbfca70f test: add integration test for importctl
(these are explicit tests, on top of the existing machinectl tests that
are now chainload importctl)
2024-03-01 22:29:08 +01:00
Lennart Poettering 120f4a4451 test74: create ssh empty dir all at the same place
A follow up for 8fddb50fd4, which mirrors
the change also in test 74.
2024-03-01 22:24:32 +01:00
Luca Boccassi 0abe0cd402 test: enable PAM debug logs in TEST-46-HOMED 2024-03-01 10:07:27 +00:00
Frantisek Sumsal 8fddb50fd4 test: create sshd's runtime directory (Debian variant)
sshd.service on Debian uses RuntimeDirectory=sshd, without which sshd
complains:

[ 4065.834904] sshd[711]: Missing privilege separation directory: /run/sshd
[ 4065.835785] systemd[1]: mysshserver@0-127.0.0.1:4711-127.0.0.1:58232.service: Deactivated successfully.
[ 4065.836433] testsuite-46.sh[708]: kex_exchange_identification: read: Connection reset by peer
[ 4065.836433] testsuite-46.sh[708]: Connection reset by 127.0.0.1 port 4711

Resolves: #31518
2024-02-29 13:44:29 +01:00
Frantisek Sumsal 38cbb9ab8a test: avoid SIGPIPE from ssh | tail -n 1
Addresses: https://github.com/systemd/systemd/issues/31518#issuecomment-1968295678
2024-02-29 13:43:40 +01:00
Frantisek Sumsal 905c9d2c92 test: use ECDSA keys for ssh-related tests
This should make the test faster, especially on machines without
acceleration.
2024-02-29 13:43:25 +01:00
Frantisek Sumsal 6e97142b84 test: shell & cleanup cleanup 2024-02-29 13:18:07 +01:00
Luca Boccassi 47c2a6e958
Merge pull request #31515 from keszybz/small-cleanups-after-review-of-stable-batch
Small cleanups after review of stable batch
2024-02-27 20:07:18 +00:00
Zbigniew Jędrzejewski-Szmek f7364e1a51 shared/pam-util: fix awkward tense in log message 2024-02-27 18:32:51 +01:00
Frantisek Sumsal cc48d93870 test: use socat in unidirectional mode
By default socat open a separate r/w channel for each specified address,
and terminates the connection after .5s from receiving EOF on _either_
side. And since one side of that connection is an empty stdin, we reach
that EOF pretty quickly. Let's avoid this by using socat in
"reversed unidirectional" mode, where the first address is used only for
writing, and the second one is used only for reading.

Addresses:
  - https://github.com/systemd/systemd/issues/31500
  - https://github.com/systemd/systemd/issues/31493

Follow-up for 3456c89ac2.
2024-02-27 15:24:23 +00:00
Luca Boccassi e5191faf44
Merge pull request #31000 from flatcar-hub/krnowak/mutable-overlays
systemd-sysext: Implement optional mutability for extensions
2024-02-26 16:17:11 +00:00
Zbigniew Jędrzejewski-Szmek 8e3fee33af Revert "docs: use collections to structure the data"
This reverts commit 5e8ff010a1.

This broke all the URLs, we can't have that. (And actually, we probably don't
_want_ to make the change either. It's nicer to have all the pages in one
directory, so one doesn't have to figure out to which collection the page
belongs.)
2024-02-23 09:48:47 +01:00
Krzesimir Nowak bfa2dd7558 test: Extend systemd-sysext tests to cover the mutability feature 2024-02-22 19:06:22 +01:00
Krzesimir Nowak 1212c80c71 test: Initial systemd-sysext tests
The follow-up commit will refactor some code in systemd-sysext, so add some
tests to make sure that things didn't break. The tests will be later extended
with cases for new features added.
2024-02-22 19:06:22 +01:00
hulkoba 5e8ff010a1
docs: use collections to structure the data 2024-02-22 10:11:54 +01:00
Frantisek Sumsal ff80bd2d6d test: temporarily enable session lingering for the test user #2
Similarly to bbac11c993 we need to enable session lingering for the test
user, so the long-running test units are not killed prematurely:

[   18.822261] testsuite-55.sh[403]: + systemctl start --machine testuser@.host --user testsuite-55-testchill.service
[   18.852775] systemd[1]: Started run-u17.service.
[   19.256431] (o-bridge)[526]: pam_unix(login:session): session opened for user testuser(uid=4711) by testuser(uid=0)
[   19.288346] systemd[1]: Started session-2.scope.
[   20.165874] systemd[392]: Created slice session.slice.
[   20.166459] systemd[392]: Starting dbus-broker.service...
[   20.220189] dbus-broker-launch[529]: Policy to allow eavesdropping in /usr/share/dbus-1/session.conf +31: Eavesdropping is deprecated and ignored
[   20.220189] dbus-broker-launch[529]: Policy to allow eavesdropping in /usr/share/dbus-1/session.conf +33: Eavesdropping is deprecated and ignored
[   20.220494] systemd[392]: Started dbus-broker.service.
[   20.224276] dbus-broker-launch[529]: Ready
[   20.231702] systemd[392]: Created slice testsuite.slice.
[   20.231976] systemd[392]: Created slice testsuite-55.slice.
[   20.232259] systemd[392]: Created slice testsuite-55-workload.slice.
[   31.065294] testsuite-55.sh[403]: + systemctl start --machine testuser@.host --user testsuite-55-testbloat.service
[   31.065641] (sd-pam)[528]: pam_unix(login:session): session closed for user testuser
[   31.066103] (sd-pam)[528]: pam_systemd(login:session): Failed to release session: Access denied
[   31.066152] systemd[392]: Started testsuite-55-testchill.service.
[   31.068062] systemd[1]: run-u17.service: Deactivated successfully.
[   31.068217] dbus-broker[389]: A security policy denied :1.20 to send method call /org/freedesktop/login1:org.freedesktop.login1.Manager.ReleaseSession to org.freedesktop.login1.
[   31.075901] (o-bridge)[537]: pam_unix(login:session): session opened for user testuser(uid=4711) by testuser(uid=0)
[   31.091098] systemd[1]: Stopping session-2.scope...
[   31.092158] systemd[1]: Started run-u21.service.
[   31.092993] systemd[1]: session-2.scope: Deactivated successfully.
[   31.093287] systemd[1]: Stopped session-2.scope.
[   31.095798] systemd[1]: Stopping user@4711.service...
[   31.103541] systemd[392]: Activating special unit exit.target...
[   31.108359] systemd[392]: Stopped target default.target.
[   31.109798] systemd[392]: Stopped target timers.target.
[   31.110790] systemd[392]: Stopping testsuite-55-testchill.service...
[   31.112154] systemd[392]: Stopped testsuite-55-testchill.service.
[   31.114033] systemd[392]: Removed slice testsuite-55-workload.slice.
[   31.114971] systemd[392]: Removed slice testsuite-55.slice.
[   31.115858] systemd[392]: Removed slice testsuite.slice.
...
[   31.475949] testsuite-55.sh[403]: + systemctl --machine testuser@.host --user status testsuite-55-testchill.service
[   31.490464] systemd[1]: session-3.scope: Deactivated successfully.
[   31.565929] systemd[1]: Started run-u33.service.
[   31.592437] (o-bridge)[583]: pam_unix(login:session): session opened for user testuser(uid=4711) by testuser(uid=0)
[   31.610210] systemd[1]: Started session-5.scope.
[   31.616960] testsuite-55.sh[578]: ○ testsuite-55-testchill.service - No memory pressure
[   31.616960] testsuite-55.sh[578]:      Loaded: loaded (/usr/lib/systemd/tests/testdata/units/testsuite-55-testchill.service; static)
[   31.616960] testsuite-55.sh[578]:      Active: inactive (dead)
[   31.617438] (sd-pam)[586]: pam_unix(login:session): session closed for user testuser

Addresses https://github.com/systemd/systemd/pull/31426#issuecomment-1956436844.
2024-02-21 18:24:25 +00:00
Frantisek Sumsal 5083e42765 test: verify our own units (where applicable)
This is inspired by one of our internal tests that does pretty much the
same thing. However, it is slightly more convoluted than I'd like it to
be, since I really don't want to duplicate the list of our units in
another place, so we need to, somehow, pass the list from the meson file
to the test script. I originally envisioned this to be a part of the
unit test suite, but this doesn't work for unit files with absolute
paths to binaries, as we'd have to install the build first (maybe using
a chroot would work?).

It doesn't check man pages (since they might not be installed on the
test machine) and also skip recursive dependencies (as that would trip
over issues in files that are not under our direct control), but it
should still cover typos and such.

There are currently two units for which the check had to be disabled -
syslog.socket, as the corresponding syslog.service might not be
installed, and rc-local.service as that's a compat API and the necessary
/etc/rc.d/rc.local file may not (and most likely won't be) present.
2024-02-20 15:45:50 +01:00
Frantisek Sumsal 3e7b1b5cb9 test: fix mixed indent 2024-02-20 13:31:00 +01:00
Frantisek Sumsal a69ec6fb02 test: support TEST_MATCH_* stuff in TEST-23-UNIT-FILE as well
TEST-23 uses run_subtests_with_signals() which I forgot about when
introducing the change.

Follow-up for 0efa27bd4b.
2024-02-20 13:31:00 +01:00
Yu Watanabe c6c7c461a3 resolve: several follow-ups for resolving service via varlink
Follow-ups for e1634bb832.

- Allow to call the method without "name" and "type".
- Allow to specify SD_RESOLVE_NO_TXT and SD_RESOLVE_NO_ADDRESS.
- Allow to provide multiple services, and fix memory leak.
- Rearrange the return value format.
- Encode TXT field with octescape() to make the field matches with the
  io.systemd.Resolve.Monitor interface.

Fixes #31371.
2024-02-19 22:13:07 +01:00
Luca Boccassi f927b872d6
Merge pull request #31351 from YHNdnzj/exit-status-no-executable
core/exec-invoke: record correct exit status when failed to locate executable
2024-02-19 19:17:31 +00:00
David Tardon dfdcc7c987 test: add a test for #31384 2024-02-19 16:45:19 +00:00
Mike Yuan 80b18d217a
core/exec-invoke: record correct exit status when failed to locate executable
Follow-up for 4d8b0f0f7a

After the mentioned commit, when the ExecCommand executable is missing,
and failure will be ignored by manager, we exit with EXIT_SUCCESS at executor
side too. The behavior however contradicts systemd.service(5), which states:

> If the executable path is prefixed with "-", an exit code of the command
> normally considered a failure (i.e. non-zero exit status or abnormal exit
> due to signal is _recorded_, but has no further effect and is considered
> equivalent to success.

and thus makes debugging unexpected failures harder. Therefore, let's still
exit with EXIT_EXEC, but just skip LOG_ERR level log.
2024-02-19 23:12:59 +08:00
Frantisek Sumsal ef22a3233f
Merge pull request #31386 from mrc0mmand/test-tweaks
Revert "test: use btrfs by default on Arch as well"
2024-02-19 14:53:31 +01:00
Adrian Vovk bbdd9c8d97 TEST-46-HOMED: Add tests for blob directories 2024-02-19 11:18:11 +00:00
Luca Boccassi 034569150f
Merge pull request #31364 from bluca/vpick_ext
core: add support for vpick for ExtensionImages=/ExtensionDirectories=
2024-02-19 11:15:54 +00:00
Frantisek Sumsal bbac11c993 test: temporarily enable session lingering for the test user
So the user daemon with the long-running service is not killed while we
test the journal:

[  834.077080] testsuite-04.sh[10937]: Running as unit: user-sleep.service; invocation ID: b1f2c9c9a14a40ce836c867139d14dc8
[  834.077687] systemd[10943]: Started user-sleep.service.
[  834.078437] (sd-pam)[10952]: pam_unix(login:session): session closed for user testuser
[  834.078643] systemd[1]: run-u3.service: Deactivated successfully.
[  834.078710] testsuite-04.sh[10930]: + for _ in {0..9}
[  834.078710] testsuite-04.sh[10930]: + journalctl --rotate
...
[  834.081253] systemd[1]: session-7.scope: Deactivated successfully.
...
[  844.602065] testsuite-04.sh[10930]: + journalctl --rotate
[  844.630414] testsuite-04.sh[10930]: + journalctl --sync
[  844.632005] systemd[1]: Stopping user@4711.service...
[  844.634179] systemd[10943]: Activating special unit exit.target...
[  844.635769] systemd[10943]: Stopped target default.target.
[  844.636136] systemd[10943]: Stopped target timers.target.
[  844.636479] systemd[10943]: Stopping user-sleep.service...
[  844.636998] systemd[10943]: Stopped user-sleep.service.
...
[  844.758893] testsuite-04.sh[10930]: + systemctl stop --user -M testuser@ user-sleep.service
[  845.213399] systemctl[11066]: Failed to stop user-sleep.service: Unit user-sleep.service not loaded.
2024-02-19 11:43:54 +01:00
Yu Watanabe b5b2510800 pam-util: include cache ID of bus connection in the log message
To make it easier to debug issues like #31375.
2024-02-19 10:15:33 +00:00
Frantisek Sumsal 78bbc7d5d4 test: make testcase_owneridmap() compatible with coverage runs
Follow-up for 614d09a.
2024-02-18 13:44:24 +00:00
Frantisek Sumsal 1b0cf03668 test: use btrfs' mkswapfile on btrfs
So it's created automagically with proper attributes.
2024-02-17 12:49:44 +01:00
Luca Boccassi 622efc544d core: add support for vpick for ExtensionDirectories= 2024-02-17 11:20:00 +00:00
Luca Boccassi 5e79dd96a8 core: add support for vpick for ExtensionImages= 2024-02-17 11:20:00 +00:00
Vishal Chillara Srinivas e1634bb832 resolve: provide service resolve over varlink
ported the d-bus implementation of service resolve to varlink
extended TEST-75-RESOLVED to cover this use-case
2024-02-16 16:24:08 +01:00
Luca Boccassi 92d1419eb8
Merge pull request #31218 from CodethinkLabs/vmspawn/journal_forwarding
vmspawn: support journal forwarding
2024-02-16 12:09:52 +00:00
Luca Boccassi 5ea0da03d4
Merge pull request #31311 from yuwata/journal-user-corruption
journal: fix user journal corruption on rotation
2024-02-16 12:07:50 +00:00
Lennart Poettering f03e8f19b7
Merge pull request #30263 from msizanoen1/fix-onboot-rotate-2
journal: Reset runtime seqnum data when flushing to system journal
2024-02-16 12:02:09 +01:00
Frantisek Sumsal 7bd41e63f7 test: properly preserve journal from sd-bsod tests
I (incorrectly) assumed that --relinquish-var does everything --flush
does, including moving already existing stuff from /var/log/journal/ to
/run/log/journal/, but that's not the case. To actually do that we need
to shuffle things manually, so let's do just that.

This should make issues like #31334 easier to debug, since with this
patch we now have a coredump in the test journal as well:

~# make -C test/TEST-04-JOURNAL/ clean setup run TEST_MATCH_SUBTEST=bsod BUILD_DIR=$PWD/build TEST_NO_NSPAWN=1
...
[   12.176089] testsuite-04.sh[712]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed'
[   12.176089] testsuite-04.sh[712]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-04.bsod.sh failed
[   12.176089] testsuite-04.sh[712]: + return 1
[   12.177347] systemd[1]: testsuite-04.service: Failed with result 'exit-code'.
[   12.220580] systemd[1]: Failed to start testsuite-04.service.
Spawning getter /home/mrc0mmand/repos/@systemd/systemd/build/journalctl -o export -D /var/tmp/systemd-tests/systemd-test.Qtqmmr/root/var/log/journal...
Finishing after writing 7649 entries
TEST-04-JOURNAL: (failed; see logs)
-rw-r----- 1 root root 16777216 Feb 15 21:13 /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal
...

~# coredumpctl --file /var/tmp/systemd-tests/systemd-test.Qtqmmr/system.journal
TIME                        PID UID GID SIG     COREFILE EXE                           SIZE
Thu 2024-02-15 21:13:38 CET 812   0   0 SIGABRT journal  /usr/lib/systemd/systemd-bsod    -
2024-02-16 10:37:37 +01:00
Frantisek Sumsal 8cc42169f1 test: add test cases for journal corruption on btrfs
For issue #24150 and #31222.
2024-02-16 03:48:18 +09:00
Sam Leonard f31cff849d
journald: implement socket forwarding
This commit adds a new way of forwarding journal messages - forwarding
over a socket.

The socket can be any of AF_INET, AF_INET6, AF_UNIUX or AF_VSOCK.

The address to connect to is retrieved from the "journald.forward_address" credential.

It can also be specified in systemd-journald's unit file with ForwardAddress=
2024-02-15 14:08:20 +00:00
Benjamin Franzke 614d09a37d nspawn: add support for owneridmap bind option
owneridmap bind option will map the target directory owner from inside the
container to the owner of the directory bound from the host filesystem.
This will ensure files and directories created in the container will be owned
by the directory owner of the host filesystem. All other users will remain
unmapped. Files to be written as other users in the container will not be
allowed.

Resolves: #27037
2024-02-15 11:49:54 +01:00
Yu Watanabe 7774a7ca79 test: fix cleanup function
Follow-up for 8349bbdfd8.
2024-02-15 09:37:10 +01:00
Luca Boccassi 76995e7dc4
Merge pull request #31286 from poettering/bootctl-varlink
bootctl: add simple varlink IPC interface
2024-02-14 18:59:33 +00:00
Luca Boccassi 32243272ff
Merge pull request #31317 from fbuihuu/update-tests-for-suse
Update tests for SUSE
2024-02-14 17:31:40 +00:00
Lennart Poettering 79ec39958d bootctl: add a Varlink interface
For now, just super basic functionality: return the list of boot menu
entries, and read/write the reboot to firmware flag
2024-02-14 16:15:19 +01:00
Lennart Poettering 8349bbdfd8 test: add test that ensures homed logins via SSH work 2024-02-14 15:09:47 +01:00
Yu Watanabe 604b200108 test: fix typo
Follow-up for d02018afdb.
2024-02-14 04:04:12 +09:00
Yu Watanabe 964756923b test: fix typo
Follow-up for 3456c89ac2.
2024-02-14 04:03:09 +09:00
Frantisek Sumsal 5b1aa0e19a core: escape spaces when serializing as well
Otherwise they might get stripped when reading the serialized data back.

Resolves: #31214
2024-02-14 02:22:58 +08:00
Franck Bui 26fff16b90 test: make sure that sd-boot is installed before testing bootctl
bootctl can be installed also non uefi systems so its sole presence doesn't
mean that we can test installation of sd-boot.
2024-02-13 18:16:23 +01:00
Lennart Poettering c9cdbaed17
Merge pull request #30380 from keszybz/tmpfiles-dry-run
Make tmpfiles/sysusers nicer with local files and implement tmpfiles --dry-run
2024-02-13 09:45:50 +01:00
Lennart Poettering a85daa97d9
Merge pull request #31233 from poettering/pcrlock-varlink
pcrlock: add simple Varlink API + some varlinkctl tweaks
2024-02-12 15:48:03 +01:00
Zbigniew Jędrzejewski-Szmek b214427752 TEST-22: add --dry-run calls
aCdDefLprRwxXz are tested with --dry-run.
I added a primitive test of bc.
There were no tests for AhHt, and I didn't add those either.
2024-02-12 13:34:32 +01:00
Lennart Poettering d02018afdb test: add brief test for prclock varlink interfaces and varlinkctl --collect 2024-02-12 12:04:18 +01:00
Lennart Poettering 24835e9933 varlinkctl: if "call" verb is used, imply "-j"
For the other verbs turning off JSON mode makes sense, but for "call"
not so much, after all the contents of a method call reply is JSON we
couldn't really show any other way.

Hence, when JSON output was not configured otherwise in "call", default
to the same as -j.
2024-02-12 12:04:18 +01:00
Lennart Poettering 3456c89ac2 test: add a simple test for MaxConnectionsPerSocket= 2024-02-12 11:57:31 +01:00
Mike Yuan 189a08e83d
core/service: allow RestartForceExitStatus= for oneshot services
I think this was just overlooked in #13754, which removed
the restriction of Restart= on Type=oneshot services.
There's no reason to prevent RestartForceExitStatus=
now that Restart= has been allowed.

Closes #31148
2024-02-10 21:19:36 +08:00
Frantisek Sumsal 76aa0d5db1 test: clean up the code a bit 2024-02-09 20:45:47 +01:00
Frantisek Sumsal 974fe6131f test: make the MemoryHigh= limit a bit more generous with sanitizers
When we're running with sanitizers, sd-executor might pull in a
significant chunk of shared libraries on startup, that can cause a lot
of memory pressure and put us in the front when sd-oomd decides to go on
a killing spree. This is exacerbated further on Arch Linux when built
with gcc, as Arch ships unstripped gcc-libs so sd-executor pulls in over
30M of additional shared libs on startup:

~# lddtree build-san/systemd-executor
build-san/systemd-executor (interpreter => /lib64/ld-linux-x86-64.so.2)
    libasan.so.8 => /usr/lib/libasan.so.8
        libstdc++.so.6 => /usr/lib/libstdc++.so.6
        libm.so.6 => /usr/lib/libm.so.6
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
    libsystemd-core-255.so => /root/systemd/build-san/src/core/libsystemd-core-255.so
        libaudit.so.1 => /usr/lib/libaudit.so.1
            libcap-ng.so.0 => /usr/lib/libcap-ng.so.0
...
    libseccomp.so.2 => /usr/lib/libseccomp.so.2
    libubsan.so.1 => /usr/lib/libubsan.so.1
    libc.so.6 => /usr/lib/libc.so.6

~# ls -Llh /usr/lib/libasan.so.8 /usr/lib/libstdc++.so.6 /usr/lib/libubsan.so.1
-rwxr-xr-x 1 root root 9.7M Feb  2 10:36 /usr/lib/libasan.so.8
-rwxr-xr-x 1 root root  21M Feb  2 10:36 /usr/lib/libstdc++.so.6
-rwxr-xr-x 1 root root 3.2M Feb  2 10:36 /usr/lib/libubsan.so.1

Sanitized libsystemd-core.so is also quite big:

~# ls -Llh /root/systemd/build-san/src/core/libsystemd-core-255.so /usr/lib/systemd/libsystemd-core-255.so
-rwxr-xr-x 1 root root  26M Feb  8 19:04 /root/systemd/build-san/src/core/libsystemd-core-255.so
-rwxr-xr-x 1 root root 5.9M Feb  7 12:03 /usr/lib/systemd/libsystemd-core-255.so
2024-02-09 20:45:39 +01:00
Zbigniew Jędrzejewski-Szmek b1935cc943 tmpfiles: use dir_cleanup() for R and D
... i.e. apply nested config (exclusions and such) when executing R and D.

This fixes a long-standing RFE. The existing logic seems to have been an
accident of implementation. After all, if somebody specifies a config with
'R /foo; x /tmp/bar', then probably the goal is to remove stuff from under /foo,
but keep /tmp/bar. If they just wanted to nuke everything, then would not specify
the second item.

This also makes R and D use O_NOATIME, i.e. the access times of the directories
that are accessed will not be changed by the cleanup.

Obviously, we'll have to add this to NEWS and such.
Looking at the whole tmpfiles.d config in Fedora, this change has no effect.

The test cases are adjusted as appropriate. I also added another test case for
'R'/'D' with a file, just to test this code path more.

Replaces #20641.
Fixes #1633.
2024-02-09 17:57:42 +01:00
Luca Boccassi c505275476
Merge pull request #31243 from YHNdnzj/systemctl-disable-now-template
systemctl: support disable/mask --now with unit template
2024-02-09 14:29:50 +00:00
Daan De Meyer 7bf52f5d1c Add systemd.default_debug_tty=
Let's allow configuring the debug tty independently of enabling/disabling
the debug shell. This allows mkosi to configure the correct tty while
leaving enabling/disabling the debug tty to the user.
2024-02-09 11:47:53 +01:00
Mike Yuan 1baa0415ae
systemctl: support disable/mask --now with unit template
Closes #15620
Replaces #28240
2024-02-09 16:18:44 +08:00
Yu Watanabe 4bc771d061 test: drop unnecessary sleep
Now, 'Reload' dbus method is synchronous. It is not necessary to wait
for link enter configuring state.
2024-02-09 14:25:54 +09:00
Luca Boccassi 82047a6aa7 portable: add --copy=mixed to copy images and link profiles
This new mode copies resources provided by the client, so that they
remain available for inspect/detach even if the original images are
deleted, but symlinks the profile as that is owned by the OS, so that
updates are automatically applied.
2024-02-08 21:11:26 +00:00
Lennart Poettering 9d99f1686a
Merge pull request #30766 from polarina/cryptenroll-tpm2-unlock
cryptenroll: Add support for unlocking through TPM2 enrollments
2024-02-08 17:41:03 +01:00
Luca Boccassi 9182658d3b
Merge pull request #31202 from YHNdnzj/creds-reuse
core: reuse credential dir across start and start-post if populated
2024-02-07 10:17:07 +00:00
Franck Bui e374109efb test: systemd-update-utmp is optional
It can be disabled with '-Dutmp=false'
2024-02-07 11:00:20 +01:00
Mike Yuan cfbf7538d8
core: reuse credential dir across start and start-post if populated,
fresh otherwise

Currently, exec_setup_credential() always rewrite all credentials
upon exec_invoke(), i.e. invocation of each ExecCommand, and within
a single tmpfs instance. This is problematic though:

* When writing each tmp cred file, we essentially double the size
  of the credential. Therefore, if one cred is bigger than half
  of CREDENTIALS_TOTAL_SIZE_MAX, confusing ENOSPC occurs (see also
  https://github.com/systemd/systemd/pull/24734#issuecomment-1925440546)

* Credential is a unit-wide thing and thus should not change
  during the whole lifetime of main process. However, if e.g.
  a on-disk credential or SetCredential= in unit file
  changes between ExecStart= and ExecStartPost=,
  the credentials are overwritten when the latter gets to run,
  and the already-running main process is suddenly seeing
  completely different creds.

So, let's try to reuse final cred dir if the main process has started
and the tmpfs has been populated, so that the creds used is stable
across all ExecStart= and ExecStartPost=-s. We still want to retain
the ability of updating creds through ExecStartPre= though, therefore
we forcibly use a fresh cred dir for those. 'Fresh' means to actually
unmount the old tmpfs first, so the first problem goes away, too.
2024-02-07 00:43:33 +08:00
Mike Yuan 54c3546188
TEST-54-CREDS: add test for ExecStartPost= (#31194) 2024-02-07 00:43:32 +08:00
Vladimir Stoiakin 85686b37b0 cryptenroll: allow to use a public key on a token
This patch allows systemd-cryptenroll to enroll directly with a public key if a certificate is missing on a token.

Fixes: #30675
2024-02-03 03:00:51 +09:00
Frantisek Sumsal ce45fe2a32 test: wait until the test binary starts the test aux scope
Otherwise we might continue too early on slower machines:

[   53.777485] testsuite-07.sh[675]: + systemd-run --unit test-aux-scope.service -p Slice=aux.slice -p Type=exec -p TasksMax=99 -p CPUWeight=199 -p IPAccounting=yes /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
[   55.399526] testsuite-07.sh[679]: Running as unit: test-aux-scope.service; invocation ID: 375dc3e2d12f4af1bedfe80a23709e37
[   55.512917] testsuite-07.sh[691]: ++ systemctl show --value --property MainPID test-aux-scope.service
[   56.947713] testsuite-07.sh[675]: + kill -s USR1 680
[   56.947713] testsuite-07.sh[675]: + sleep 1
[   58.058809] testsuite-07.sh[675]: + systemctl status test-aux-scope.service
[   58.902808] testsuite-07.sh[695]: ● test-aux-scope.service - /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
[   58.902808] testsuite-07.sh[695]:      Loaded: loaded (/run/systemd/transient/test-aux-scope.service; transient)
[   58.902808] testsuite-07.sh[695]:   Transient: yes
[   58.902808] testsuite-07.sh[695]:      Active: active (running) since Thu 2024-02-01 04:53:57 UTC; 3s ago
[   58.902808] testsuite-07.sh[695]:    Main PID: 680 (test-aux-scope)
[   58.902808] testsuite-07.sh[695]:          IP: 0B in, 0B out
[   58.902808] testsuite-07.sh[695]:       Tasks: 11 (limit: 99)
[   58.902808] testsuite-07.sh[695]:      Memory: 3.2M (peak: 3.5M)
[   58.902808] testsuite-07.sh[695]:         CPU: 235ms
[   58.902808] testsuite-07.sh[695]:      CGroup: /aux.slice/test-aux-scope.service
[   58.902808] testsuite-07.sh[695]:              ├─680 /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
[   58.902808] testsuite-07.sh[695]:              ├─681 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─682 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─683 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─684 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─685 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─686 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─687 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─688 "(worker)"
[   58.902808] testsuite-07.sh[695]:              ├─689 "(worker)"
[   58.902808] testsuite-07.sh[695]:              └─690 "(worker)"
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: Enqueued job test-aux-scope.service/start as 277
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: Will spawn child (service_enter_start): /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: Passing 0 fds to service
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: About to execute: /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: Forked /usr/lib/systemd/tests/unit-tests/manual/test-aux-scope as 680
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: test-aux-scope.service: Changed dead -> start
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd[1]: Starting test-aux-scope.service...
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H systemd-executor[680]: SELinux enabled state cached to: disabled
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H (ux-scope)[680]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
[   58.902808] testsuite-07.sh[695]: Feb 01 04:53:57 H (ux-scope)[680]: Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
[   58.979659] testsuite-07.sh[701]: ++ ps -eo pid,unit
[   59.014968] testsuite-07.sh[702]: ++ grep -c test-aux-scope.service
[   59.729453] systemd[1]: Cannot find unit for notify message of PID 691, ignoring.
[   60.321547] testsuite-07.sh[675]: + test 11 = 1
[   60.332496] testsuite-07.sh[669]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.aux-scope.sh failed'
2024-02-03 02:57:52 +09:00
Yu Watanabe 2933881ea5
Merge pull request #31032 from yuwata/pam-session-close
pam: fix warning "Attempted to close sd-bus after fork, this should not happen." on session close
2024-02-02 09:51:08 +09:00
Yu Watanabe 58125c1920 test: fix typo
Follow-up for fa8ff98ea4.
2024-02-02 09:27:52 +09:00
Gabríel Arthúr Pétursson 47ec2c8a8e cryptenroll: Support rotating PIN on an existing TPM2 enrollment 2024-02-01 13:55:17 +00:00
Gabríel Arthúr Pétursson 631cf7f004 cryptenroll: Add support for unlocking through TPM2 enrollments 2024-02-01 12:37:12 +00:00
Yu Watanabe 88b8d08276 test: check pam warning message 2024-02-01 18:00:54 +09:00
Lennart Poettering 3557f1a62a resolvectl: add JSON output support for "resolvectl query"
It's easy to add. Let's do so.

This only covers record lookups, i.e. with the --type= switch.

The higher level lookups are not covered, I opted instead to print a
message there to use --type= instead.

I am a bit reluctant to defining a new JSON format for the high-level
lookups, hence I figured for now a helpful error is good enough, that
points people to the right use.

Fixes: #29755
2024-01-31 16:13:16 +01:00
Lennart Poettering 116ce3f391
Merge pull request #31039 from AdrianVovk/slice-freeze-thaw
Rework slice recursive freeze/thaw
2024-01-31 09:48:05 +01:00
Adrian Vovk 4cb2e6af8d
core: Fail to start/stop/reload unit if frozen
Previously, unit_{start,stop,reload} would call the low-level cgroup
unfreeze function whenever a unit was started, stopped, or reloaded. It
did so with no error checking. This call would ultimately recurse up the
cgroup tree, and unfreeze all the parent cgroups of the unit, unless an
error occurred (in which case I have no idea what would happen...)

After the freeze/thaw rework in a previous commit, this can no longer
work. If we recursively thaw the parent cgroups of the unit, there may
be sibling units marked as PARENT_FROZEN which will no longer actually
have frozen parents. Fixing this is a lot more complicated than simply
disallowing start/stop/reload on a frozen unit

Fixes https://github.com/systemd/systemd/issues/15849
2024-01-30 11:18:16 -05:00
Adrian Vovk 16b6af6ade
core: Rework recursive freeze/thaw
This commit overhauls the way freeze/thaw works recursively:

First, it introduces new FreezerActions that are like the existing
FREEZE and THAW but indicate that the action was initiated by a parent
unit. We also refactored the code to pass these FreezerActions through
the whole call stack so that we can make use of them. FreezerState was
extended similarly, to be able to differentiate between a unit that's
frozen manually and a unit that's frozen because a parent is frozen.

Next, slices were changed to check recursively that all their child
units can be frozen before it attempts to freeze them. This is different
from the previous behavior, that would just check if the unit's type
supported freezing at all. This cleans up the code, and also ensures
that the behavior of slices corresponds to the unit's actual ability
to be frozen

Next, we make it so that if you FREEZE a slice, it'll PARENT_FREEZE
all of its children. Similarly, if you THAW a slice it will PARENT_THAW
its children.

Finally, we use the new states available to us to refactor the code
that actually does the cgroup freezing. The code now looks at the unit's
existing freezer state and the action being requested, and decides what
next state is most appropriate. Then it puts the unit in that state.
For instance, a RUNNING unit with a request to PARENT_FREEZE will
put the unit into the PARENT_FREEZING state. As another example, a
FROZEN unit who's parent is also FROZEN will transition to
PARENT_FROZEN in response to a request to THAW.

Fixes https://github.com/systemd/systemd/issues/30640
Fixes https://github.com/systemd/systemd/issues/15850
2024-01-30 11:18:15 -05:00
Lennart Poettering 6ab41e38e9 test: add integration test for per-user creds 2024-01-30 17:07:47 +01:00
Frantisek Sumsal d2e8dc780f test: clean up the code a bit 2024-01-26 18:09:09 +01:00
Frantisek Sumsal 8ee32f688f test: fix the container ID check
It never worked, but the fail was masked by missing set -e, see the
previous commit.

Also, throw env into the test container and dump the environment on
container start, to make potential failures easier to debug.
2024-01-26 15:44:39 +01:00
Frantisek Sumsal 7b1c292953 test: set -ex separately
We call the entrypoint.sh script using `bash entrypoint.sh`, so -ex from
the shebang won't be used in that case. Whoopsie.
2024-01-26 15:29:49 +01:00
Daan De Meyer 329288613c
Merge pull request #31048 from YHNdnzj/fstab-modernization
fstab-util/generator: a few cleanups/improvements
2024-01-26 09:01:19 +01:00
Lennart Poettering b68f4cade4 dissect: add --make-archive option to convert DDI to tarball 2024-01-25 18:47:39 +01:00
Mike Yuan 9f6c32ac96
fstab-generator: drop unapplicable options for /usr/ too
We already drop these for /sysroot/usr/ in parse_fstab
(1e9b2e4fdd). Let's make
things consistent, and do the same for /usr/ too (after
switch-root).
2024-01-26 01:06:41 +08:00
Lennart Poettering 8a9bf03bd7
Merge pull request #31003 from enr0n/skip-test-when-apparmor-restricts-userns
Skip more tests when apparmor restricts unprivileged user namespaces
2024-01-24 09:58:07 +01:00
Luca Boccassi f70daee8f2
Merge pull request #30130 from poettering/pcrlock-root
pcrlock: add support for unlocking a root fs with a pcrlock file
2024-01-23 21:41:02 +00:00
Yu Watanabe fc5edc91cb
Merge pull request #31015 from yuwata/local-addresses
local-addresses: several cleanups and fixes, add test cases
2024-01-23 10:25:35 +09:00
Luca Boccassi ad12e4be6d
Merge pull request #31044 from keszybz/uhttpd-alloca-print
Use macro wrapper instead of alloca in µhttp-utils
2024-01-22 22:03:08 +00:00
Lennart Poettering c048d1d28d test: add new credential-based pcrlock policy unlock 2024-01-22 15:20:22 +01:00
Adrian Vovk 720c618397 core: path: Re-enter waiting if target is deactivating
Previously, path units would remain in the running state while their
target unit is deactivating. This left a window of time where the target
unit is no longer operational (i.e. it is busy deactivating/cleaning
up/etc) but the path unit would continue to ignore inotify events. In
short: any inotify event that occurs while the target unit deactivates
would be completely lost.

With this commit, the path will go back into a waiting state when the
target unit starts deactivating. This means that any inotify event that
occurs while the target unit deactivates will queue a start job.
2024-01-21 10:34:45 +00:00
Yu Watanabe e90863f231 local-addresses: ignore tentative addresses
As tentative addresses may be dropped soon if DAD failed.
2024-01-20 16:07:19 +09:00
Lennart Poettering 9d2a292246 test: add integration test for Type=exec robustness
This tests for #30799, so that it does not return.
2024-01-19 16:51:55 +01:00
Nick Rosbrook 6327d30224 test: skip a systemd-run test if unprivileged userns is restricted
With newer versions of AppArmor, unprivileged user namespace creation
may be restricted by default, in which case user manager instances will
not be able to apply PrivateUsers=yes, which is implied by
PrivateTmp=yes in this systemd-run invocation.
2024-01-19 10:21:57 -05:00
Yu Watanabe e8736fb6c9 test-13-NSPAWN: add more test case for passing network interfaces
- test interface renaming that conflicts with the current alternative
  network interface name,
- test passing wlan interfaces.
2024-01-19 19:06:19 +09:00
Luca Boccassi 0a9735eac2
Merge pull request #30661 from rpigott/resolved-https-record
resolved: support RFC 9460 SVCB and HTTPS records
2024-01-17 16:20:35 +00:00
Mike Yuan a37928d34c
TEST-35-LOGIN: test changes to list-sessions 2024-01-17 11:30:05 +08:00
Ronan Pigott a9766d07b8 test-resolve: add basic test for SVCB/HTTPS RRs 2024-01-16 11:26:37 -07:00
Frantisek Sumsal fa8ff98ea4 test: cover a couple of error scenarios
To make sure we behave correctly even in error paths.
2024-01-15 18:04:31 +01:00
Luca Boccassi 0f6a6e2f2b test: create /run/sshd in TEST-74-AUX-UTILS
12264s [ 4819.948632] sshd[1365]: fatal: Missing privilege separation directory: /run/sshd
12264s [ 4819.952120] testsuite-74.sh[1362]: kex_exchange_identification: read: Connection reset by peer
12264s [ 4819.952120] testsuite-74.sh[1362]: Connection reset by /run/ssh-unix-local/socket port 0

https://autopkgtest.ubuntu.com/results/autopkgtest-jammy-upstream-systemd-ci-systemd-ci/jammy/amd64/s/systemd-upstream/20240113_093341_50fc7@/log.gz

We copy binaries manually so some setups are missing, create the directory
as needed
2024-01-15 10:28:05 +09:00
Nick Rosbrook fec0d508a2 test: skip TEST-43-PRIVATEUSER-UNPRIV if unprivileged userns is restricted
With newer versions of AppArmor, unprivileged user namespace creation
may be restricted by default, in which case user manager instances will
not be able to apply PrivateUsers=yes (or the settings which require it).

This can be tested with the kernel.apparmor_restrict_unprivileged_userns
sysctl.
2024-01-13 06:55:04 +09:00
Yu Watanabe 967cd1712c
Merge pull request #30867 from dtardon/udev-conf-dropins
Allow dropins for udev.conf
2024-01-12 06:37:23 +09:00
Lennart Poettering 28795e4dca
Merge pull request #30777 from poettering/ssh-generator
ssh-generator which makes VMs and containers accessible to ssh via AF_UNIX and AF_VSOCK
2024-01-11 21:31:28 +01:00
Lennart Poettering 25f8d3856a
Merge pull request #30884 from poettering/logind-background-light
logind: add "background-light" + "manager" session classes
2024-01-11 21:20:01 +01:00
David Tardon dddf640cab test: use dropin dir 2024-01-12 05:12:44 +09:00
Lennart Poettering a50666e376 id128: add --no-pager, --no-legend, --json=/-j switches to systemd-id128 tool 2024-01-11 17:54:19 +01:00
Lennart Poettering 3b52ef6f00 test: add integration test for new 'background-light' session class 2024-01-11 17:47:41 +01:00