Commit graph

1742 commits

Author SHA1 Message Date
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
Lennart Poettering 4cb4e6cf6d pam_systemd: register systemd user service manager as class='manager'
Now that we have thew new class, start making us of it in pam_systemd.so
when running for user@.service.
2024-01-11 17:23:47 +01:00
Lennart Poettering 52d863defc test: add testcase for ssh generator 2024-01-11 16:18:26 +01:00
Luca Boccassi dadd7d46d9
Merge pull request #30809 from yuwata/resolve-fix-EDE-handling
resolve: fix EDE handling
2024-01-10 19:21:55 +00:00
Frantisek Sumsal f1caa5d6e7 test: introduce a dummy DNS test server
Introduce a _very_ simple DNS server using our internal DNS-related
code, that responds to queries with specifically crafted packets, to
cover scenarios that are difficult to reproduce with well-behaving DNS
servers.

Also, hide the test DNS server behind Knot using the dnsproxy module, so
we don't have to switch DNS servers during tests.
2024-01-11 02:13:29 +09:00
Yu Watanabe d26319be92 test: add test for [Link] Property= and friends 2024-01-10 04:33:55 +09:00
Luca Boccassi b4a85f75b0
Merge pull request #30843 from keszybz/test-relative-paths
Use relative paths in test units
2024-01-09 12:23:35 +00:00
Zbigniew Jędrzejewski-Szmek 67953523d1 TEST-07: minor simplification 2024-01-09 11:18:11 +01:00
Zbigniew Jędrzejewski-Szmek 63403f07b0 tests: use relative paths in ExecStart= and friends
We want to retain *some* of the full paths in order to test more code paths.
But the default should be to use the command name only. This makes the tests
less visually cluttered.
2024-01-09 11:14:16 +01:00
Lennart Poettering 0a6598bb38 hostnamed: add simple Varlink API, too 2024-01-09 10:46:25 +01:00
Lennart Poettering 09c7bead29 testsuite-71: reset startlimit counter manually
The test cases will call quite a lot of "systemctl stop
systemd-hostnamed", hence let's make sure we reset the start limit
counter each time, to not make this eventually fail.

(At other places we disabled the start limit counter, but here I opted
for resetting it manually via 'systemctl reset-failed', to test another
facet of the mechanism)
2024-01-09 10:46:01 +01:00
Lennart Poettering a1bb30de7f varlink: add "ssh:" transport
This uses openssh 9.4's -W support for AF_UNIX. Unfortunately older versions
don't work with this, and I couldn#t figure a way that would work for
older versions too, would not be racy and where we'd still could keep
track of the forked off ssh process.

Unfortunately, on older versions -W will just hang (because it tries to
resolve the AF_UNIX path as regular host name), which sucks, but hopefully this
issue will go away sooner or later on its own, as distributions update.

Fedora is still stuck at 9.3 at the time of posting this (even on
Fedora), even though 9.4, 9.5, 9.6 have all already been released by
now.

Example:
        varlinkctl call -j ssh:root@somehost:/run/systemd/io.systemd.Credentials io.systemd.Credentials.Encrypt '{"text":"foobar"}'
2024-01-08 23:24:45 +01:00
Lennart Poettering 1a30285590 network-generator: pick up .netdev/.link/.network configuration via credentials
To me this is the last major basic functionality that couldn't be
configured via credentials: the network.

We do not invent any new format for this, but simply copy relevant creds
1:1 into /run/systemd/network/ to open up the full functionality of
networkd to VM hosts.
2024-01-08 12:59:08 +01:00
Frantisek Sumsal 5bd1122843 test: check how systemd-resolved deals with zone transfers
Even though systemd-resolved doesn't support zone transfers (AXFR/IXFR),
it should still just refuse such requests without choking on them.

See: https://github.com/systemd/systemd/pull/30809#issuecomment-1880102804
2024-01-07 22:22:52 +01:00
Frantisek Sumsal 45b2bf0efc test: zone-check with --force to fail on warnings 2024-01-07 22:02:48 +01:00
Frantisek Sumsal 7980c6316a test: sync the "foobaz" namespace as well
Otherwise we might be too fast, resulting in failed namespace check
later:

[    7.351453] testsuite-44.sh[401]: + journalctl --list-namespaces
[    7.351784] testsuite-44.sh[402]: + grep foobar
[    7.358851] testsuite-44.sh[402]: foobar
[    7.359598] testsuite-44.sh[403]: + journalctl --list-namespaces
[    7.359974] testsuite-44.sh[404]: + grep foobaz
[    7.369882] systemd[1]: testsuite-44.service: Failed with result 'exit-code'.

Follow-up for 68f66a1713.
2024-01-07 05:27:14 +09:00
Frantisek Sumsal f569dc6af2 repart: don't crash when looping over dropped partitions
Properly skip over dropped partitions and make sure they don't affect
the final graphical output (for example by leaving empty "spaces" where
their definition file name would otherwise be).

Resolves: #30742
2024-01-07 05:26:38 +09:00
Frantisek Sumsal d7942fe5fc core: escape spaces in paths during serialization
Otherwise we split them incorrectly when deserializing them.

Resolves: #30747
2024-01-06 11:19:59 +09:00
Yu Watanabe 976309db6a
Merge pull request #30796 from mrc0mmand/journalctl-namespaces
journalctl: provide shell completion for --namespace=
2024-01-06 08:30:31 +09:00
Frantisek Sumsal 68f66a1713 journalctl: implement --list-namespaces
Apart from being useful on its own, this will be used in the following
commit for shell completions.
2024-01-05 19:21:51 +01:00
Yu Watanabe ff4240fc22 test: wait for verbose-success.service finished
Otherwise, the command 'echo' may not be invoked yet.

Follow-up for 25aa35d465.
2024-01-05 13:08:10 +01:00
Lennart Poettering 8ef31e1f13
Merge pull request #29692 from H5117/fix_pkcs11_uri
cryptenroll: change class in provided PKCS#11 URI if necessary
2024-01-05 12:14:26 +01:00
Yu Watanabe 115a09004e test: fix typo
Follow-up for 995bf013a1.
2024-01-05 19:08:12 +09:00
Vladimir Stoiakin 85828ef920 cryptenroll: change class in provided PKCS#11 URI if necessary
cryptenroll accepts only PKCS#11 URIs that match both a certificate and a private key in a token.
This patch allows users to provide a PKCS#11 URI that points to a certificate only, and makes possible to use output of some PKCS#11 tools directly.
Internally the patch changes 'type=cert' in the provided PKCS#11 URI to 'type=private' before storing in a LUKS2 header.

Fixes: #23479
2024-01-05 12:32:36 +03:00
Sergei Zhmylev 25aa35d465 journalctl: add --exclude-identifier option 2024-01-04 23:21:39 +01:00
Luca Boccassi 81a183800f tmpfiles: add --purge switch
Any file/directory created by a tmpfiles.d will be deleted. Useful for
purge/factory reset patterns.
2024-01-04 17:36:43 +01:00
Mike Yuan 5446a52b39
TEST-35-LOGIN: enable FileDescriptorStorePreserve= for coldplug test 2024-01-04 17:14:23 +08:00
Lennart Poettering 2a02a8db91
Merge pull request #26663 from poettering/vpick
add new "vpick" concept for automatically picking newest resource from .v/ dir containing versioned files
2024-01-03 22:17:32 +01:00
Yu Watanabe 82a1597778
Merge pull request #28797 from Werkov/eff_limits
Add MemoryMaxEffective=, MemoryHighEffective= and TasksMaxEff…  …ective= properties
2024-01-04 05:38:06 +09:00
Yu Watanabe 124c712692
Merge pull request #30532 from yuwata/udev-extend-timeout-kill-worker
udev: extend timeout to prevent kill worker
2024-01-04 05:21:50 +09:00
Yu Watanabe aea57b1415
Merge pull request #28836 from msekletar/aux-scope
core/manager: add dbus API to create auxiliary scope from running service
2024-01-04 04:52:39 +09:00
Lennart Poettering 0345366ac3 tests: add integration tests for vpick logic 2024-01-03 19:01:37 +01:00
Michal Sekletar fd7fd59b6d tests: add test for StartAuxiliaryScope() 2024-01-03 13:50:46 +01:00
Lennart Poettering 6018a27cb7 test-64: only look at plugged devices, not all of them 2024-01-03 13:47:57 +01:00
Michal Koutný ce35bb95c7 test: Add effective cgroup limits testing 2024-01-03 13:37:58 +01:00
Michal Koutný 834ca54624 test: Convert rlimit test to subtest of generic limit testing
No functional change intended. Preparation for new tests.
2024-01-03 13:37:58 +01:00
Frantisek Sumsal 995bf013a1 test: rewrite test-exec-deserialization.py
Rewrite the test in bash and make it part of our integration test suite,
so it's actually executed in all our upstream CI environments.

The original test is flaky in environments where daemon-reload might
occur during the test runtime (e.g. when running the test in parallel
with the systemd-networkd test suite). Also, it was run only in CentOS
CI in limited way (i.e. without sanitizers), since it tests the host's
systemd, instead of the just built one.

Resolves: #29943
2024-01-03 08:40:55 +09:00
Yu Watanabe 5592608bdc test: update test case for failed udev event 2024-01-03 04:23:26 +09:00
Yu Watanabe 2d0be462d6
Merge pull request #30656 from mrc0mmand/dfuzzer-shenanigans
test: avoid starting/stopping unwanted units during fuzzing
2023-12-31 04:52:15 +09:00
Yu Watanabe 13a30c6dc4 test: add simple coverage tests for 'udevadm lock' 2023-12-30 05:28:04 +09:00
Joakim Nohlgård ba340e2a75 udevadm: Propagate return code from verb result
udevadm lock did not propagate the return code from the child process
because all positive values were treated as success.

v2:
Now 'udevadm test-builtin' ignores all positive return values from the
builtin commands. Otherwise, as the hwdb builtin returns an positive value
when a matching entry found, 'udevadm test-builtin hwdb' will fail.

v3:
Initialize partition table before calling 'sfdisk --delete'.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2023-12-30 05:26:59 +09:00
Frantisek Sumsal a66031255f test: avoid starting/stopping unwanted units during fuzzing
Skip calling start and stop methods on unit objects, as doing that is
not only time consuming, but it also starts/stops units that interfere
with the machine state. The actual code paths should be covered (to some
degree) by the respective method counterparts on the manager object.
2023-12-29 21:26:49 +01:00
Frantisek Sumsal bcdb5d4c0b test: wrap adding a suppression in a method 2023-12-29 13:18:15 +01:00
Frantisek Sumsal 4ddf27c57b test: flush the socket once the triggered unit exits
Since the triggered unit intentionally fails without consuming any data
from the socket, we'd try to trigger it again and again, and we might
try to check the unit state in one of the "in-between" states, failing
the test:

[  165.271698] H testsuite-07.sh[1032]: + systemctl start badbin_assert.socket
[  165.977637] H testsuite-07.sh[1032]: + socat - ABSTRACT-CONNECT:badbin_assert.socket
[  165.983787] H systemd[1]: Cannot find unit for notify message of PID 1039, ignoring.
[  166.817187] H testsuite-07.sh[1032]: + timeout 10 sh -c 'while systemctl is-active badbin_assert.service; do sleep .5; done'
[  167.049218] H testsuite-07.sh[1065]: active
[  167.146854] H systemd[1]: Listening on badbin_assert.socket.
[  167.163473] H systemd[1]: badbin_assert.socket: Incoming traffic
[  167.542626] H systemd[1]: Cannot find unit for notify message of PID 1065, ignoring.
[  167.543437] H (badbin)[1062]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  167.548346] H systemd[1]: badbin_assert.service: Main process exited, code=exited, status=203/EXEC
[  167.549482] H systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  167.561537] H systemd[1]: badbin_assert.socket: Incoming traffic
[  167.933390] H systemd[1]: Started badbin_assert.service.
[  167.950489] H (badbin)[1070]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  167.956318] H systemd[1]: badbin_assert.service: Main process exited, code=exited, status=203/EXEC
[  167.957173] H systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  167.974609] H systemd[1]: badbin_assert.socket: Incoming traffic
[  168.042838] H testsuite-07.sh[1072]: failed
[  168.094431] H testsuite-07.sh[1075]: ++ systemctl show -P ExecMainStatus badbin_assert.service
[  168.704022] H systemd[1]: Started badbin_assert.service.
[  168.778680] H (badbin)[1074]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  168.826881] H systemd[1]: badbin_assert.service: Main process exited, code=exited, status=203/EXEC
[  168.833825] H systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  168.923931] H testsuite-07.sh[1032]: + [[ 0 == 203 ]]
[  168.951492] H systemd[1]: Cannot find unit for notify message of PID 1075, ignoring.
[  168.999862] H testsuite-07.sh[615]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.issue-30412.sh failed'
[  168.999862] H testsuite-07.sh[615]: Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.issue-30412.sh failed

Follow-up for 1eeaa93de3 and 28a2d27650.
2023-12-24 13:00:56 +01:00
Yu Watanabe d24d9a3786
Merge pull request #30604 from mrc0mmand/test-journal-shenanigans
test: redirect stdout/stderr of TEST-04-JOURNAL to console as well
2023-12-24 03:40:50 +09:00
Frantisek Sumsal addbe898a7 test: make the variable names slightly more descriptive
Follow-up for 5ca8d2474c.
2023-12-23 16:37:30 +01:00
Frantisek Sumsal 7de2118916 test: slightly extend uid0's coverage 2023-12-23 16:37:30 +01:00
Frantisek Sumsal a6fb61be77 test: make the test actually test
Follow-up for dd25a95763.
2023-12-23 16:37:30 +01:00
Frantisek Sumsal b3ed0808d1 test: redirect stdout/stderr of TEST-04-JOURNAL to console as well
This effectively reverts fa6f37c043 just for TEST-04, as we nuke the
journal repeatedly in this test which makes it particularly hard to
debug. Let's hope the issue behind fa6f37c043 won't bite us back in this
case.

Follow-up for: fa6f37c043
Reverts: 8f7c876bdc
2023-12-23 15:54:51 +01:00
Frantisek Sumsal eb3cdf49b1 test: don't truncate the final journal
This is no longer necessary, as the test for which this was introduced
in the first place has this handled explicitly (testsuite-04.journal.sh).

Follow-up to 9457dd8bae.
2023-12-23 15:35:08 +01:00
Frantisek Sumsal 4e5984f027 test: make sure the dummy CA certificate is marked as such
With OpenSSL 3.2.0+ this is necessary, otherwise the verification
of such CA certificate fails badly:

$ openssl s_client -CAfile /run/systemd/remote-pki/ca.crt -connect localhost:19532
...
Connecting to ::1
CONNECTED(00000003)
Can't use SSL_get_servername
depth=1 C=CZ, L=Brno, O=Foo, OU=Bar, CN=Test CA
verify error:num=79:invalid CA certificate
verify return:1
depth=1 C=CZ, L=Brno, O=Foo, OU=Bar, CN=Test CA
verify error:num=26:unsuitable certificate purpose
verify return:1
...
---
SSL handshake has read 1566 bytes and written 409 bytes
Verification error: unsuitable certificate purpose
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
This TLS version forbids renegotiation.
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 26 (unsuitable certificate purpose)
2023-12-23 13:42:09 +01:00
Lennart Poettering dc6522b18f
Merge pull request #28658 from H5117/enroll_with_ec
cryptsetup: Add support for EC keys in PKCS#11 tokens
2023-12-21 22:45:40 +01:00
Lennart Poettering aafd495af8
Merge pull request #30547 from poettering/uid0
add new "uid0" command as alternative multi-call interface for systemd-run, as sudo replacement
2023-12-21 22:45:15 +01:00
Lennart Poettering 1760716959 test: add simple creds/varlink integration test 2023-12-21 19:19:12 +01:00
Lennart Poettering dd25a95763 test: add minimal integration test coverage for uid0 tool 2023-12-21 19:15:01 +01:00
Yu Watanabe abf0ccc1c6 analyze-verify: verify all executables
ExecStart= and friends for .service and .socket can be specified
multiple times.
This also checks all commands for .mount and .swap, not only for the
current control command.
2023-12-20 23:56:16 +09:00
Yu Watanabe 5183976cea TEST-65-ANALYZE: only mount /usr if necessary
Follow-up for 8f764b32ea.

Otherwise, we fail to umount several directories on shutdown.
---
[   15.684430] systemd[1]: Failed unmounting tmp-root-proc.mount.
[   15.689379] systemd[1]: Failed unmounting tmp-root-run.mount.
[   15.710572] systemd[1]: Failed unmounting tmp-root-sys-fs-cgroup.mount.
[   15.913953] systemd[1]: Failed unmounting tmp-root-dev.mount.
[   15.924603] systemd[1]: Failed unmounting tmp-root-sys.mount.
[   15.938207] systemd[1]: Failed unmounting tmp-root.mount.
[   15.952395] systemd[1]: Failed unmounting tmp.mount.
2023-12-20 23:56:16 +09:00
Yu Watanabe 8f876e8d98
Merge pull request #30525 from YHNdnzj/networkctl-mask
networkctl: introduce verb mask and unmask
2023-12-20 21:00:36 +09:00
Frantisek Sumsal 92ee875a31 test: trigger /boot mount if it's an automount
If the target mount point is an automount, checking it for writeability
without triggering it first is iffy and yields different results based
on kernel version:

~# systemd-run --wait --pipe -p ProtectSystem=yes bash -xec 'uname -r; mount -l | grep boot; test ! -w /boot'
Running as unit: run-u36.service; invocation ID: f948ff4f3c8e4bcfba364ead94bd0ad9
+ uname -r
4.18.0-529.el8.x86_64
+ mount -l
+ grep boot
systemd-1 on /boot type autofs (rw,relatime,fd=43,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=356096)
+ test '!' -w /boot
Finished with result: exit-code
Main processes terminated with: code=exited/status=1

~# systemd-run --wait --pipe -p ProtectSystem=yes bash -xec 'uname -r; mount -l | grep boot; test ! -w /boot'
Running as unit: run-u274.service; invocation ID: ccc53ed63c3249348cf714f97a3a7026
+ uname -r
6.6.7-arch1-1
+ mount -l
+ grep boot
systemd-1 on /boot type autofs (rw,relatime,fd=95,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=730583)
+ test '!' -w /boot
Finished with result: success
Main processes terminated with: code=exited/status=0

One solution would be to use /boot/ instead of just /boot, which triggers
the automount during the check, but in that case the mount would happen
_after_ we apply the ProtectSystem= stuff, so the mount point would
be unexpectedly writable:

~# systemd-run --wait --pipe -p ProtectSystem=yes bash -xec 'uname -r; mount -l | grep boot; test ! -w /boot/ || mount -l | grep boot'
Running as unit: run-u282.service; invocation ID: 2154f6b4cbd34ddeb3e246cb7c991918
+ uname -r
6.6.7-arch1-1
+ mount -l
+ grep boot
systemd-1 on /boot type autofs (rw,relatime,fd=95,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=730583)
+ test '!' -w /boot/
+ mount -l
+ grep boot
systemd-1 on /boot type autofs (rw,relatime,fd=95,pgrp=1,timeout=120,minproto=5,maxproto=5,direct,pipe_ino=730583)
/dev/vda2 on /boot type vfat (rw,nosuid,nodev,noexec,relatime,nosymfollow,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

Let's just trigger the (possible) automounts explicitly before we do any
checks to avoid all this stuff.

Also, when at it, check that ProtectSystem=yes|full correctly protects
the ESP mount as well.

Follow-up for 97bbb9cfbd.
2023-12-20 18:15:35 +09:00
Vladimir Stoiakin a3c1b0d74c TEST-24-CRYPTSETUP: add test for PKCS#11 tokens
Introduces new dependencies on SoftHSM, OpenSC and GnuTLS for the test.
2023-12-20 11:52:18 +03:00
Mike Yuan 28bb29cbb4
networkctl: introduce verb mask and unmask
Suggested in https://github.com/systemd/systemd/pull/29928#discussion_r1386626565
2023-12-20 12:46:46 +08:00
Frantisek Sumsal 68785c7d6a test: reset systemd-resolved.service's restart counter
Otherwise we might occasionally hit the start rate limit, as we restart
the service a bunch of times:

[ 3702.280886] testsuite-75.sh[1135]: + tee /tmp/tmp.wUL8bkJwrt
[ 3702.283684] testsuite-75.sh[1135]: {}
[ 3702.284254] testsuite-75.sh[46]: + restart_resolved
[ 3702.284302] testsuite-75.sh[46]: + systemctl stop systemd-resolved.service
[ 3702.310678] testsuite-75.sh[1140]: + systemctl is-failed systemd-resolved.service
[ 3702.316766] testsuite-75.sh[1141]: inactive
[ 3702.316998] testsuite-75.sh[46]: + systemctl start systemd-resolved.service
[ 3702.322315] systemd[1]: systemd-resolved.service: Start request repeated too quickly.
[ 3702.322343] systemd[1]: systemd-resolved.service: Failed with result 'start-limit-hit'.
[ 3702.322609] systemd[1]: Failed to start systemd-resolved.service - Network Name Resolution.
[ 3702.323619] systemctl[1142]: Job for systemd-resolved.service failed.
[ 3702.323839] systemctl[1142]: See "systemctl status systemd-resolved.service" and "journalctl -xeu systemd-resolved.service" for details.
[ 3702.325035] systemd[1]: testsuite-75.service: Failed with result 'exit-code'.
[ 3702.325391] systemd[1]: Failed to start testsuite-75.service - Tests for systemd-resolved.

Follow-up for b1384db11b and 6ef512c0bb.
2023-12-20 13:42:08 +09:00
Frantisek Sumsal 32c376a46c test: add missing operators
Without them only the last expression's return value is honored, causing
unexpected CI fails:

[   26.006721] testsuite-04.sh[1191]: + for _ in {0..9}
[   26.007672] testsuite-04.sh[1191]: + setterm --term linux --dump --file /tmp/console.dump
[   26.008871] testsuite-04.sh[1233]: + SYSTEMD_COLORS=256
[   26.009606] testsuite-04.sh[1233]: + /usr/lib/systemd/systemd-bsod
[   26.063296] systemd[1]: session-1.scope: Deactivated successfully.
[   26.124789] testsuite-04.sh[1191]: + grep -aq 'Press any key to exit' /tmp/console.dump
[   26.131509] testsuite-04.sh[1191]: + grep -aq 'Root emergency message' /tmp/console.dump
[   26.137882] testsuite-04.sh[1191]: + grep -aq 'The current boot has failed' /tmp/console.dump
[   26.141650] testsuite-04.sh[1191]: + return 0
[   26.144816] testsuite-04.sh[1191]: + grep -aq 'Scan the QR code' /tmp/console.dump
[   26.153591] testsuite-04.sh[1191]: + at_exit
[   26.154744] testsuite-04.sh[1191]: + local EC=1
[   26.155697] testsuite-04.sh[1191]: + [[ 1 -ne 0 ]]
[   26.156787] testsuite-04.sh[1191]: + [[ -e /tmp/console.dump ]]
[   26.157799] testsuite-04.sh[1191]: + cat /tmp/console.dump
[   26.158858] testsuite-04.sh[1244]:    The current boot has failed!
[   26.159858] testsuite-04.sh[1244]:    Root emergency message

I'm genuinely impressed that this worked at all.
2023-12-19 11:47:17 +09:00
Luca Boccassi c2d5d8c401
Merge pull request #30464 from CodethinkLabs/misc-integration-test-fixes
Misc integration test fixes
2023-12-18 16:11:16 +01:00
Luca Boccassi e7bfce0d0a
Merge pull request #30492 from mrc0mmand/skip-TEST-08-without-systemd-in-initrd
test: skip TEST-08-INITRD if systemd didn't run in the initrd
2023-12-18 16:10:33 +01:00
networkException 4e0db87e4c core: allow interface altnames in RestrictNetworkInterfaces=
This patch enables IFNAME_VALID_ALTERNATIVE for checks guarding the
parsing of RestrictNetworkInterfaces=.

The underlying implementation for this option already supports
altnames.
2023-12-18 15:12:10 +01:00
Lennart Poettering a19e7f3101
Merge pull request #30321 from yuwata/find-esp
find-esp: gracefully handle btrfs RAID
2023-12-18 15:11:54 +01:00
Frantisek Sumsal 57d61ff319 test: skip TEST-08-INITRD if systemd didn't run in the initrd
This test requires systemd in the initrd, which is not the case in
mkinitrd-based initrds (Ubuntu/Debian).

Resolves: #30481
2023-12-15 16:51:25 +01:00
Frantisek Sumsal 438c7cb20e test: tell delv to load anchors from /etc/bind.keys explicitly
Since [0] delv no longer does that automagically, so we have to that
explicitly with each delv invocation.

Resolves: #30477

[0] c144fd2871
2023-12-14 23:11:12 +01:00
Frantisek Sumsal 8f7c876bdc test: forward journal messages to console during sd-bsod tests
Since we nuke the journal multiple times during that, which makes
potential fails undebugable.
2023-12-14 23:08:44 +01:00
Richard Maw 8799346862 test: mount overlayfs over /usr in some tests
Most of the integration tests have been made to not write to /usr
but some genuinely need to do so.

Because mkosi creates images with a read-only /usr
it is not normally writeable.

By mounting an overlayfs with /usr as the lower dir
and upper and working dirs in /var tests may write to /usr.
2023-12-13 17:55:45 +00:00
Richard Maw 0129395173 test: slacken plugged -> dead test
This test is for if devices transition from plugged -> dead -> plugged
on boot, but it is normal to see loop devices transition plugged -> dead
on first boot when systemd-repart adds the root partition.
2023-12-13 13:35:04 +00:00
Richard Maw 8f764b32ea test: Create analyze chroot with --rbind
The systemd-analyze integration test also tests chroots.
It builds its chroot by bind-mounting /,
but since /usr might be a separate mountpoint
it should create the chroot with --rbind.
2023-12-13 13:35:04 +00:00
Lennart Poettering 113defc76b test: test that delegation of some newer attrs that shall be delegated work 2023-12-13 10:10:56 +01:00
Yu Watanabe ee07fff03b test: add basic coverity tests for bootctl 2023-12-13 14:29:09 +09:00
Yu Watanabe 0f236e8cd6 test: mask mdmonitor when building image
Follow-up for 22e31655f3.
2023-12-13 14:28:03 +09:00
Frantisek Sumsal 22e31655f3 test: mask the mdmonitor.service
It's pulled in by one of the udev rules (63-md-raid-arrays.rules) and it
fails every time, because there's no valid email address in
/etc/mdadm.conf:

[    5.778153] testsuite-64.sh[403]: mdadm: array /dev/md/mdmirror started.
[    5.819137] kernel: md/raid1:md127: not clean -- starting background reconstruction
[    5.819141] kernel: md/raid1:md127: active with 2 out of 2 mirrors
[    5.819159] kernel: md127: detected capacity change from 0 to 129024
[    5.821950] kernel: md: resync of RAID array md127
...
[    5.887192] mdadm[424]: mdadm: No mail address or alert command - not monitoring.
[    5.890772] systemd[1]: Starting mdmonitor.service...
[    5.891718] systemd[1]: Started mdmonitor.service.
[    5.892570] systemd[1]: mdmonitor.service: Main process exited, code=exited, status=1/FAILURE
[    5.892618] systemd[1]: mdmonitor.service: Failed with result 'exit-code'.

And as we (re)assemble the MD devices multiple times, this gets quite
noisy, especially since we later start hitting the service start rate
limit.

Fedora has the mdmonitor.service patched, so it won't start without
/etc/mdadm.conf being present, but Arch uses the upstream unit which
doesn't have such guard.

Let's just mask the service completely, which replaces all that noise
with one warning:

[    6.553583] testsuite-64.sh[294]: + udevadm wait --settle ...
[    6.580700] systemd[1]: sys-devices-virtual-block-md127.device: Failed to enqueue SYSTEMD_WANTS job, ignoring: Unit mdmonitor.service is masked.
2023-12-13 00:59:20 +00:00
Frantisek Sumsal 28a2d27650 test: "never" is not a valid value for Restart=
[  154.140565] testsuite-07.sh[1014]: + systemctl start badbin_assert.socket
[  154.738606] testsuite-07.sh[1014]: + socat - ABSTRACT-CONNECT:badbin_assert.socket
[  154.768418] systemd[1]: Cannot find unit for notify message of PID 1021, ignoring.
[  154.812357] systemd[1]: /run/systemd/system/badbin_assert.service:3: Failed to parse service restart specifier, ignoring: never
[  155.347350] testsuite-07.sh[1014]: + timeout 10 sh -c 'while systemctl is-active badbin_assert.service; do sleep .5; done'
[  155.669695] (badbin)[1045]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  155.676596] systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  156.081953] testsuite-07.sh[1051]: failed
[  156.132018] testsuite-07.sh[1054]: ++ systemctl show -P ExecMainStatus badbin_assert.service
[  156.326583] (badbin)[1050]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  156.343566] systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  156.904658] (badbin)[1055]: badbin_assert.service: Failed to execute /tmp/badbin: Exec format error
[  156.913709] systemd[1]: badbin_assert.service: Failed with result 'exit-code'.
[  157.066900] testsuite-07.sh[1014]: + [[ 0 == 203 ]]
[  157.081588] testsuite-07.sh[618]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.issue-30412.sh failed'

Follow-up for 1eeaa93de3.
2023-12-12 13:36:28 +00:00
Luca Boccassi bf8726d1ee
Merge pull request #30363 from yuwata/analyze-find-template
analyze: also find template unit when an instance is specified
2023-12-11 15:56:21 +00:00
Luca Boccassi 1eeaa93de3 executor: don't duplicate FD array to avoid double closing
Just use ExecParam directly, as these are all internal to sd-exec now
anyway. Avoids double close when execution fails after FDs are set up
for inheritance and were already re-arranged.

Fixes https://github.com/systemd/systemd/issues/30412
2023-12-11 15:55:50 +00:00
Yu Watanabe 9d51ab7830 test: add test cases for issue #30357 2023-12-11 15:12:42 +09:00
Yu Watanabe b1384db11b test: check if resolved exits cleanly 2023-12-10 14:38:56 +09:00
Frantisek Sumsal e23fc070e2 test: backup /etc/udev/udev.conf only if it exists
On Fedora systemd recently moved all of its configuration files to
/usr/lib/ [0], so make sure we account for this case as well.

[   42.450325] testsuite-17.sh[800]: + mkdir -p /run/udev/rules.d
[   42.466504] testsuite-17.sh[800]: + cp -f /etc/udev/udev.conf /etc/udev/udev.conf.bckp
[   42.503348] testsuite-17.sh[802]: cp: cannot stat '/etc/udev/udev.conf': No such file or directory

[0] 29eb35530b?branch=rawhide
2023-12-08 18:38:41 +01:00
Frantisek Sumsal ad23ff13de test: reset systemd-udevd.service restart counter
Since we restart systemd-udevd here a couple of times, we might hit the
rate limit in later tests:

[   26.028355] testsuite-17.sh[2074]: + udevadm control -e
[   26.028355] testsuite-17.sh[2074]: + udevadm control -l emerg
[   26.126160] systemd[1]: systemd-udevd.service: Start request repeated too quickly.
[   26.126213] systemd[1]: systemd-udevd.service: Failed with result 'start-limit-hit'.
[   26.140310] systemd[1]: Failed to start systemd-udevd.service.
[   26.140897] systemd[1]: systemd-udevd-control.socket: Failed with result 'service-start-limit-hit'.
[   26.141286] systemd[1]: systemd-udevd-kernel.socket: Failed with result 'service-start-limit-hit'.
[   26.142225] testsuite-17.sh[2074]: + udevadm control -l alert
[   26.149206] udevadm[2088]: Failed to send request to set log level: No such file or directory

Follow-up to: 6ef512c0bb
2023-12-08 18:14:05 +01:00
Luca Boccassi 6c75eff6af core: create workdir/upperdir when mounting a Type=overlay mount unit
So far we created the target directory, and the source for bind mounts,
but not workdir/upperdir for overlays, so it has to be done separately
and strictly before the unit is started, which is annoying. Check the
options when creating directories, and if upper/work directories are
specified, create them.
2023-12-08 11:22:14 +09:00
Luca Boccassi ebc7510380 core: relax dependency on RootImage= storage from Requires= to Wants=
If a unit is running in an image and wants to survive a soft-reboot,
then it can't be deactivated by the storage of the image going away.
Relax the dependency to a Wants=. Access to the image is not needed
when the unit is running anyway, so downgrade to Wants=.
2023-12-08 11:16:31 +09:00
Yu Watanabe 786a337817
Merge pull request #30060 from poettering/analyze-archs
analyze: add "archs" verb that lists all known architectures
2023-12-07 15:47:30 +09:00
Frantisek Sumsal 4207a5577a journalctl: don't skip over messages not matching the cursor
When --after-cursor=/--cursor-file= is used together with a journal
filter, we still skipped over the first matching entry even if it wasn't
the entry the cursor points at, thus missing one "valid" entry
completely. Let's fix this by checking if the entry cursor after seeking
matches the user provided cursor, and skip to the next entry only when
the cursors match.

Resolves: #30288
2023-12-07 13:31:25 +09:00
Zbigniew Jędrzejewski-Szmek 0d08149801
Merge pull request #30316 from mrc0mmand/revert-journal-upload-user
Revert "sysusers.d: create the user for systemd-journal-upload.service"
2023-12-06 22:28:34 +01:00
Zbigniew Jędrzejewski-Szmek 34f4fcb59f
Merge pull request #30302 from keszybz/systemd-edit-stdin
systemctl edit --stdin
2023-12-06 22:28:02 +01:00
Zbigniew Jędrzejewski-Szmek fd72d1e794
Merge pull request #30085 from YHNdnzj/networkctl-edit-runtime
networkctl: introduce --runtime for editing network config under /run/
2023-12-06 22:27:01 +01:00
Zbigniew Jędrzejewski-Szmek d1f9a39ef4
Merge pull request #29853 from YHNdnzj/sleep-automated
logind: support Sleep() that automatically choose a sleep operation
2023-12-06 22:25:13 +01:00
Samuel BF 435c372ce5 journal-gatewayd: add since/until parameters for /entries
Request with Range header like 'entries=<cursor>:' (with a colon at the end,
invalid syntax per the doc), is now rejected with error 400 Bad Request.

fix #4883
2023-12-06 22:22:27 +01:00
Lennart Poettering fb8cc599ed analyze: add "architectures" verb that lists all known architectures 2023-12-06 22:18:14 +01:00
Luca Boccassi f9a284f02d
Merge pull request #30214 from bluca/wants_mounts_for
Add WantsMountsFor= and use it in the cryptsetup generator
2023-12-06 21:00:37 +00:00
Daan De Meyer 1500fe38b2 test: Add test case for --make-ddi=sysext
Also make sure that the sysext is big enough to not fit in the
minimum partition size so we know Minimize= is being used.
2023-12-06 12:18:32 +01:00
Frantisek Sumsal 1ea27bd79e test: load the io controller before checking if io.latency exists
Otherwise the following test gets always skipped.
2023-12-05 19:58:48 +00:00
Zbigniew Jędrzejewski-Szmek dd0630277b TEST-26: add test for systemctl edit --stdin 2023-12-05 18:47:19 +01:00
Mike Yuan cd4dd90b99
logind: introduce Sleep() call and action that automatically choose a sleep operation 2023-12-05 22:18:32 +08:00
Frantisek Sumsal 52c1fb6885 test: set correct group for systemd-journal-upload tests
We can't use the systemd-journal-upload user here, since it's created
dynamically by DynamicUser=yes. However, we can use the group specified
in SupplementaryGroups=, so do exactly that.
2023-12-05 09:07:14 +01:00
Yu Watanabe 0cf392c4e7 test: add test for seqnum and seqnum ID 2023-12-04 15:14:25 +09:00