1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-11 09:18:07 +03:00
Commit Graph

4084 Commits

Author SHA1 Message Date
Frantisek Sumsal
07268394d6 test: unify /testok & /failed handling
And drop it where not necessary.
2023-07-12 16:03:40 +02:00
Frantisek Sumsal
74711e7a09 test: fail if we find units/tests in failed state
Instead of relying on the post-test /failed file check.
2023-07-12 16:01:05 +02:00
Frantisek Sumsal
438fcfdf6c test: drop redundant 'function' keyword 2023-07-12 16:01:05 +02:00
Frantisek Sumsal
f3139ecd08 test: drop spurious whitespaces 2023-07-12 16:01:05 +02:00
Yu Watanabe
627cdcc785 tree-wide: fix typos reported by Fossies Codespell report 2023-07-12 10:14:50 +09:00
Frantisek Sumsal
fab73dad84 test: reorder the machinectl signal tests
So the multiple-machines tests run last to avoid a race where the
checked signal would get ignored while the stub init is still processing
the previous signals:

[   17.380417] testsuite-13.sh[376]: + machinectl reboot long-running long-running long-running
[   17.389888] systemd-nspawn[495]: ++ touch /reboot
[   17.390904] testsuite-13.sh[376]: + rm -f /var/lib/machines/long-running/trap
[   17.393937] testsuite-13.sh[376]: + machinectl kill --signal=SIGTRAP --kill-whom=leader long-running
[   17.408905] testsuite-13.sh[376]: + timeout 10 bash -c 'while ! test -e /var/lib/machines/long-running/trap; do sleep .5; done'
[   27.413210] testsuite-13.sh[376]: + at_exit
...
[   27.993376] testsuite-13.sh[373]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-13.machinectl.sh failed'
2023-07-10 15:26:32 +01:00
Dan Streetman
9071d6b1a3 test: Add DA lockout handling to TEST-70-TPM2
Since this test intentionally provides an incorrect PIN, the DA lockout counter
is incremented; the test needs to reset it so there is no DA lockout.
2023-07-08 01:13:29 +01:00
Yu Watanabe
9bf0fe3633
Merge pull request #28287 from yuwata/network-null-address
network: fix null address handling
2023-07-08 01:13:17 +09:00
Luca Boccassi
91c96f9b32 test: remove +x from some units 2023-07-07 12:31:28 +01:00
Luca Boccassi
544fc54d72 test: add +x to generator-utils.sh
It is marked and named as a script, so add +x otherwise Lintian complains:

 W: systemd-tests: script-not-executable [usr/lib/systemd/tests/testdata/units/generator-utils.sh]
2023-07-07 11:51:11 +01:00
Yu Watanabe
fc25920c94 test-network: add tests for null addresses
For issue #26113.
2023-07-07 19:11:37 +09:00
Yu Watanabe
14be337d04
Merge pull request #28233 from mrc0mmand/append-to-corrupted-journals
test: append to corrupted journals
2023-07-07 11:51:02 +09:00
Yu Watanabe
86f6760038 test-network: add one more testcase for DHCPv4 classless route
For issue #28280.
2023-07-07 06:57:08 +09:00
Frantisek Sumsal
29bdeb5cb3 test: append to corrupted journals
Introduce a manual test tool that creates a journal, corrupts it by
flipping bits at given offsets, and then attempts to write to the journal.
In ideal case we should handle this gracefully without any crash or
memory corruption.
2023-07-06 22:41:27 +02:00
Luca Boccassi
b2deaaf01b
Merge pull request #27584 from rphibel/add-restartquick-option
service: add new RestartMode option
2023-07-06 20:37:31 +01:00
Luca Boccassi
b9b0f338be
Merge pull request #28274 from DaanDeMeyer/dissect-root
dissect: Allow a few verbs to operate on directories as well as image files
2023-07-06 14:41:48 +01:00
Richard Phibel
e568fea9fc service: add new RestartMode option
When this option is set to direct, the service restarts without entering a failed
state. Dependent units are not notified of transitory failure.

This is useful for the following use case:

We have a target with Requires=my-service, After=my-service.
my-service.service is a oneshot service and has Restart=on-failure in
its definition.

my-service.service can get stuck for various reasons and time out, in
which case it is restarted. Currently, when it fails the first time, the
target fails, even though my-service is restarted.

The behavior we're looking for is that until my-service is not restarted
anymore, the target stays pending waiting for my-service.service to
start successfully or fail without being restarted anymore.
2023-07-06 14:33:52 +02:00
Daan De Meyer
12d58b6c74 dissect: Add --mtree-hash= option
Let's make including hashes in the mtree output configurable to allow
speeding up the --mtree command in cases where file hashes are not
required.
2023-07-06 12:11:45 +02:00
Daan De Meyer
2292fa1e31 dissect: Allow a few verbs to operate on directories as well as image files
--copy-to, --copy-from, --list and --mtree are useful for image directories
as well as image files, so for those verbs, let's check if we were passed
a directory and skip all the image file setup if that's the case.
2023-07-06 12:11:42 +02:00
Lennart Poettering
9103278ff7
Merge pull request #28265 from yuwata/network-captive-portal-follow-ups
network: several follow-ups for captive portal support
2023-07-06 11:39:24 +02:00
Yu Watanabe
62eaf8d039 test-network: drop ExecReload= in networkd.service and udevd.service
Follow-up for 0e07cdb0e7 and
f84331539d.
2023-07-06 14:55:58 +09:00
Mike Yuan
bf3dfa6202
TEST-03-JOBS: test indirect PropagatesStopTo= 2023-07-06 05:12:04 +08:00
Luca Boccassi
79be4b7da8
Merge pull request #28255 from yuwata/sd-device-fix-clone
sd-device: fix device_clone_with_db()
2023-07-05 21:38:52 +01:00
Frantisek Sumsal
ba4a1cd8a8 test: replace readfp() with read_file()
ConfigParser.readfp() has been deprecated since Python 3.2 and was
dropped completely in Python 3.11.
2023-07-05 21:38:24 +01:00
Yu Watanabe
beebaeeb3f test: change partition label to test if the outdated devlinks are removed
The change is intended to reproduce the issue #27983, though the
original issue is highly racy, and the test does not reproduce it
reliably. But, anyway, it is better to change the partition label to
test the devlink removal.
2023-07-05 23:46:01 +09:00
Lennart Poettering
529ba8a1a3
Merge pull request #26844 from YHNdnzj/propagate-stop-fixup
core: introduce UNIT_ATOM_PROPAGATE_STOP_GRACEFUL for PropagatesStopTo=
2023-07-05 15:56:21 +02:00
Luca Boccassi
11d797d3b9
Merge pull request #28207 from poettering/initrd-creds
various credential improvements (including initrd creds, creds in generators, fstab + getty creds)
2023-07-05 10:29:33 +01:00
Yu Watanabe
051c0f8926
Merge pull request #28228 from yuwata/repart-free-area
repart: fix free area calculation
2023-07-05 16:36:16 +09:00
Yu Watanabe
937625c7c7 test: update test for free area calculation in repart 2023-07-05 10:40:56 +09:00
Yu Watanabe
beba8f2e1e test: add reproducer for issue #28225 2023-07-05 10:40:53 +09:00
Mike Yuan
5db456d065
test: add test cases for issue #26839 in TEST-03-JOBS 2023-07-05 08:15:35 +08:00
Lennart Poettering
de70ecb328 import-creds: add support for binary credentials specified on the kernel cmdline 2023-07-04 23:19:48 +02:00
Lennart Poettering
53888c3393 test: verify that the getty generator with creds works 2023-07-04 23:14:21 +02:00
Lennart Poettering
51235f2fe6 test: add simple fstab credential test 2023-07-04 23:09:39 +02:00
Lennart Poettering
4a262d5677 test: add test for initrd credentials
This extends the test framework a bit, and allows adding additional
initrds to the qemu invocation, which we use here to place credentials
in the new /run/systemd/@initrd/ credentials dir which are then passed
to the host.
2023-07-04 23:05:23 +02:00
Frantisek Sumsal
6bbfa9c214 test: measure subtest runtime 2023-07-04 21:55:53 +02:00
Lennart Poettering
c86a95082b systemctl: implement a new "whoami" verb, that just returns unit of caller/PID 2023-07-04 01:05:02 +01:00
Frantisek Sumsal
f2492d39ba test: wait for the interface to become routable after reconfiguring
Since 6e8477edd3 TEST-75 started failing with:

[  571.468298] testsuite-75.sh[46]: + for addr in "${DNS_ADDRESSES[@]}"
[  571.468298] testsuite-75.sh[46]: + run delv @fd00:dead:beef:cafe::1 -t A mail.signed.test
[  571.468899] testsuite-75.sh[562]: + tee /tmp/tmp.qKlHPbCCJZ
[  571.469317] testsuite-75.sh[561]: + delv @fd00:dead:beef:cafe::1 -t A mail.signed.test
[  571.501381] testsuite-75.sh[562]: ;; network unreachable resolving 'mail.signed.test/A/IN': fd00:dead:beef:cafe::1#53
[  571.501564] testsuite-75.sh[562]: ;; resolution failed: SERVFAIL
[  571.515457] testsuite-75.sh[46]: + grep -qF '; fully validated' /tmp/tmp.qKlHPbCCJZ

Let's wait for the dns0 interface to become routable again after
re-enabling IPv6 to, hopefully, mitigate this.
2023-07-04 08:10:11 +09:00
Yu Watanabe
d979b39811
Merge pull request #28245 from rpigott/dhcp6-relax-assert
relax data assert in dchp6_option_parse_string
2023-07-04 08:06:13 +09:00
Ronan Pigott
1219391c9f test-network: add test for an invalid captive portal uri
This could probably be extended to include many more invalid uri
2023-07-03 13:47:12 -07:00
Lennart Poettering
f4b24db7c3 test: add test case for recent OnSuccess=/OnFailure= state machine changes 2023-07-03 17:31:25 +02:00
Yu Watanabe
e4948bb2cd test-network: add test for static route with preferred source
This adds possible reproducer for issue #28009 (though, the issue is
highly racy, hence this may not trigger the issue reliably).
2023-07-03 16:13:49 +09:00
Yu Watanabe
7e30527806 test-network: check route more strictly 2023-07-03 16:06:17 +09:00
Yu Watanabe
86c2a76e09
Merge pull request #28132 from rpigott/dhcp-captive-portal
Implement RFC8910: captive portal dhcp options
2023-07-03 14:51:56 +09:00
Ronan Pigott
dbe960f07f test-network: add tests for captive portal dhcp options 2023-07-02 01:13:43 -07:00
Frantisek Sumsal
a5e478b24c test: fix test_vxlan with the latest iproute2
Some options were renamed and some options with default values are not
shown unless -d(etails) is repeated.

See: https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=1215e9d3862387353d8672296cb4c6c16e8cbb72
2023-06-30 17:33:40 +00:00
Frantisek Sumsal
06afda6b38 core: reorder systemd arguments on reexec
When reexecuting system let's put our arguments carrying deserialization
info first followed by any existing arguments to make sure they get
parsed in case we get weird stuff from the kernel cmdline (like --).

See: https://github.com/systemd/systemd/issues/28184
2023-06-29 22:20:41 +01:00
Yu Watanabe
856a247e19 test-network: add test for global IPv6PrivacyExtensions= setting 2023-06-29 21:58:23 +09:00
Frantisek Sumsal
69eeb6f15e test: use correct path for systemd-battery-check
Follow-up to #28185.
2023-06-29 13:06:42 +01:00
Yuxiang Zhu
b67e8a4e3e
network: Add IgnoreDdontFragment= option for Fragmentation control (#28131)
From `ip-link(8)`:
> [no]ignore-df - enables/disables IPv4 DF
                      suppression on this tunnel.  Normally datagrams
                      that exceed the MTU will be fragmented; the
                      presence of the DF flag inhibits this, resulting
                      instead in an ICMP Unreachable (Fragmentation
                      Required) message.  Enabling this attribute causes
                      the DF flag to be ignored.

If this option is enabled for a GRE/GRETAP tunnel, the `DF` flag in the outer IP header
will not inherit the inner IP header's `DF` flag.

This is useful to transfer packets that exceed the MTU of the underlay
network.
2023-06-29 12:11:52 +02:00
Yu Watanabe
be994c2640 battery-check: several follow-ups
Follow-ups for e3d4148d50.

- add reference to initrd-battery-check.service in man page, and move
  its section from 1 to 8,
- add link to man page in help message,
- introduce ERRNO_IS_NO_PLYMOUTH(),
- propagate error in battery_check_send_plymouth_message(),
- rename battery_check_send_plymouth_message() -> plymouth_send_message(),
- return earlier when the first battery level check passed to reduce
  indentation,
- fix potential use of invalid fd on battery restored,
- do not use emoji for /dev/console,
- add simple test (mostly for coverity),

etc, etc...
2023-06-29 15:41:00 +09:00
Lennart Poettering
580a007bb6 test: add test for new XDG_STATE_HOME handling 2023-06-28 22:09:19 +02:00
Lennart Poettering
f9c91932b4 execute: add support for XDG_STATE_HOME for placing service state data in --user mode
This adds support for the new XDG_STATE_HOME env var that was added to
the xdg basedir spec. Previously, because the basedir spec didn't know
the concept we'd alias the backing dir for StateDirectory= to the one
for ConfigurationDirectory= when runnin in --user mode. With this change
we'll make separate. This brings us various benefits, such as proper
"systemctl clean" support, where we can clear service state separately
from service configuration, now in user mode too.

This does not come without complications: retaining compatibility with
older setups is difficult, because we cannot possibly identitfy which
files in existing populated config dirs are actually "state" and which
one are true" configuration.

Hence let's deal with this pragmatically: if we detect that a service
that has both dirs configured only has the configuration dir existing,
then symlink the state dir to the configuration dir to retain
compatibility.

This is not great, but it's the only somewhat reasonable way out I can
see.

Fixes: #25739
2023-06-28 22:01:55 +02:00
Luca Boccassi
1c53c3bab1
Merge pull request #28178 from mrc0mmand/nss-tests
test: add a couple of tests for nss-myhostname & nss-mymachines
2023-06-28 19:41:11 +01:00
Frantisek Sumsal
2b5e786005 test: enable LSan for certain wrapped binaries
So we're able to detect memory leaks in our NSS modules.

An example after introducing a memory leak in nss-myhostname.c:

testsuite-71.sh[2881]: =================================================================
testsuite-71.sh[2881]: ==2880==ERROR: LeakSanitizer: detected memory leaks
testsuite-71.sh[2881]: Direct leak of 2 byte(s) in 1 object(s) allocated from:
testsuite-71.sh[2881]:     #0 0x7fa28907243b in strdup (/usr/lib64/libasan.so.8.0.0+0x7243b)
testsuite-71.sh[2881]:     #1 0x7fa286a7bc10 in gethostname_full ../src/basic/hostname-util.c:67
testsuite-71.sh[2881]:     #2 0x7fa286a74af9 in gethostname_malloc ../src/basic/hostname-util.h:24
testsuite-71.sh[2881]:     #3 0x7fa286a756f4 in _nss_myhostname_gethostbyname4_r ../src/nss-myhostname/nss-myhostname.c:79
testsuite-71.sh[2881]:     #4 0x7fa288f17588 in getaddrinfo (/lib64/libc.so.6+0xf4588)
testsuite-71.sh[2881]:     #5 0x7fa2890a4d93 in __interceptor_getaddrinfo.part.0 (/usr/lib64/libasan.so.8.0.0+0xa4d93)
testsuite-71.sh[2881]:     #6 0x55a54b2b7159 in ahosts_keys_int.part.0 (/usr/bin/getent.orig+0x4159)
testsuite-71.sh[2881]: SUMMARY: AddressSanitizer: 2 byte(s) leaked in 1 allocation(s).
2023-06-28 17:04:31 +02:00
Frantisek Sumsal
0f90d4f0c3 test: add a couple of tests for nss-mymachines 2023-06-28 17:04:31 +02:00
Lennart Poettering
f70c90f5ca analyze: add new "pcrs" verb
It shows the PCRs we know about along with their name strings and
current values.
2023-06-28 16:50:50 +02:00
Frantisek Sumsal
1a36d2672f test: add a couple of tests for nss-myhostname 2023-06-28 11:07:46 +02:00
Yu Watanabe
16e1e4b3e7 meson: drop doubled empty line 2023-06-27 22:34:25 -06:00
Luca Boccassi
8da88af877
Merge pull request #28064 from bluca/test_oomd_swap
TEST-55-OOMD: use 'stress' to create high pressure, ensure swap is set up correctly on Ubuntu CI
2023-06-26 19:39:07 +01:00
Frantisek Sumsal
7f5f781cf4 test: fix test service unit description 2023-06-26 15:54:01 +02:00
Luca Boccassi
72a28bf8ef
Merge pull request #28149 from mrc0mmand/test-machinectl-bump-container-size
test: bump the test container size to 64 MiB
2023-06-25 12:01:30 +01:00
Frantisek Sumsal
256c1ac9a8 test: bump the test container size to 64 MiB
As 32 MiB appears to be on the edge of barely enough on C8S:

[  149.974689] testsuite-13.sh[601]: + dd if=/dev/zero of=/tmp/container.raw bs=1M count=32
[  150.388423] testsuite-13.sh[1096]: 32+0 records in
[  150.390721] testsuite-13.sh[1096]: 32+0 records out
[  150.392450] testsuite-13.sh[1096]: 33554432 bytes (34 MB, 32 MiB) copied, 0.354336 s, 94.7 MB/s
[  150.396422] testsuite-13.sh[601]: + mkfs.ext4 /tmp/container.raw
[  150.472209] testsuite-13.sh[1097]: mke2fs 1.45.6 (20-Mar-2020)
[  150.561303] testsuite-13.sh[1097]: Discarding device blocks: done
[  150.565438] testsuite-13.sh[1097]: Creating filesystem with 32768 1k blocks and 8192 inodes
[  150.568301] testsuite-13.sh[1097]: Filesystem UUID: d8e3c43b-0f1f-4e89-8c26-100e4a32b64f
[  150.569777] testsuite-13.sh[1097]: Superblock backups stored on blocks:
[  150.571135] testsuite-13.sh[1097]:   8193, 24577
[  150.572751] testsuite-13.sh[1097]: Allocating group tables: done
[  150.574294] testsuite-13.sh[1097]: Writing inode tables: done
[  150.598696] testsuite-13.sh[1097]: Creating journal (4096 blocks): done
[  150.604285] testsuite-13.sh[1097]: Writing superblocks and filesystem accounting information: done
[  150.612309] testsuite-13.sh[601]: + mount -o loop /tmp/container.raw /tmp/mnt
[  150.879736] testsuite-13.sh[601]: + cp -r /var/lib/machines/container1/bin ... /tmp/mnt
[  152.347545] testsuite-13.sh[1104]: cp: cannot create directory '/tmp/mnt/var/log': No space left on device
[  152.351739] testsuite-13.sh[1104]: cp: cannot create directory '/tmp/mnt/var/tmp': No space left on device
2023-06-24 20:51:27 +02:00
Frantisek Sumsal
4c88752ae5 test: show the subtest name together with the failing code
To make debugging slightly easier.
2023-06-24 20:44:33 +02:00
Luca Boccassi
f434f182cc TEST-55-OOMD: use swap file instead of partition
The partition seems not to work on Ubuntu for some reason, use a
swap file instead
2023-06-24 11:48:51 +01:00
Luca Boccassi
937e82cb7d TEST-55-OOMD: use 'stress' to create high pressure
The test fails on my machine, running Debian stable, because
testsuite-55-testbloat.service just swaps and never goes over the
limit, so it's not killed. Use 'stress' instead which seems to be
able to overwhelm the swap too.
2023-06-24 11:48:51 +01:00
Frantisek Sumsal
7eb9a4623d test: drop timeout when running portablectl
The deadlock should be resolved by #28123, so let's check if it's indeed
the case.
2023-06-24 10:35:12 +02:00
Frantisek Sumsal
f6b916d387 test: test the /boot endpoint under nspawn as well
Since #28144 should be now resolved by fb0e106.
2023-06-24 10:33:14 +02:00
Lennart Poettering
9e35e9779d
Merge pull request #28144 from poettering/procfs-submounts-move
pid1: when setting up a new procfs instance for a service, mount submounts from host into it
2023-06-23 22:53:25 +02:00
Lennart Poettering
5ca8d2474c test: ensure ProtectProc=invisible retains host submounts 2023-06-23 18:32:40 +02:00
Frantisek Sumsal
0651e71749 test: test transactions with cycles
Provides coverage for systemd/systemd#26872.

With systemd/systemd#26875 reverted:

[16444.287652] testsuite-03.sh[71]: + for i in {0..19}
[16444.287652] testsuite-03.sh[71]: + systemctl start transaction-cycle0.service
[16444.359503] systemd[1]: =================================================================
[16444.360321] systemd[1]: ==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6180002e578e at pc 0x7f73b25ec7a6 bp 0x7ffc5531c6f0 sp 0x7ffc5531be68
[16444.360798] systemd[1]:
[16444.361044] systemd[1]: READ of size 783 at 0x6180002e578e thread T0 (systemd)
[16444.391684] systemd[1]:     #0 0x7f73b25ec7a5  (/lib64/libasan.so.5+0x557a5)
[16444.392167] systemd[1]:     #1 0x7f73b260a1d5 in __interceptor_vasprintf (/lib64/libasan.so.5+0x731d5)
[16444.392442] systemd[1]:     #2 0x7f73afa1d1e1 in log_format_iovec ../src/basic/log.c:996
[16444.392750] systemd[1]:     #3 0x7f73afa1e7b6 in log_struct_internal ../src/basic/log.c:1058
[16444.393101] systemd[1]:     #4 0x7f73b1979136 in transaction_verify_order_one ../src/core/transaction.c:392
[16444.393540] systemd[1]:     #5 0x7f73b197ac82 in transaction_verify_order_one ../src/core/transaction.c:463
[16444.393946] systemd[1]:     #6 0x7f73b197ac82 in transaction_verify_order_one ../src/core/transaction.c:463
[16444.394262] systemd[1]:     #7 0x7f73b197ac82 in transaction_verify_order_one ../src/core/transaction.c:463
[16444.394532] systemd[1]:     #8 0x7f73b197ac82 in transaction_verify_order_one ../src/core/transaction.c:463
[16444.394812] systemd[1]:     #9 0x7f73b197ac82 in transaction_verify_order_one ../src/core/transaction.c:463
...
2023-06-23 14:37:07 +02:00
Frantisek Sumsal
88c98cb261 test: make sure we get PID1's stack trace on ASan/UBSan errors
As hitting an ASan/UBSan error in PID1 results in a crash (and a kernel
panic when running under qemu), we usually lose the stack trace which
makes debugging quite painful. Let's mitigate this by forwarding the
stack trace to multiple places - namely to a file and the syslog.
2023-06-23 14:37:07 +02:00
Luca Boccassi
0b1e55a616
Merge pull request #28109 from mrc0mmand/more-journal-shenanigans
test: cover a couple of missed code paths in journalctl/journald
2023-06-22 00:46:06 +01:00
Daan De Meyer
33885343cf
Merge pull request #27942 from DaanDeMeyer/root-ephemeral
core: Add RootEphemeral= setting
2023-06-21 17:24:39 +02:00
Frantisek Sumsal
51a05be9a2 test: cover a couple of missed code paths in journalctl/journald 2023-06-21 17:08:55 +02:00
Daan De Meyer
cdad1f1407 test: Add RootEphemeral= integration test 2023-06-21 12:48:48 +02:00
Daan De Meyer
d110169b65 test: Add touch into minimal verity test image 2023-06-21 12:48:48 +02:00
Daan De Meyer
9c0c670125 core: Add RootEphemeral= setting
This setting allows services to run in an ephemeral copy of the root
directory or root image. To make sure the ephemeral copies are always
cleaned up, we add a tmpfiles snippet to unconditionally clean up
/var/lib/systemd/ephemeral. To prevent in use ephemeral copies from
being cleaned up by tmpfiles, we use the newly added COPY_LOCK_BSD
and BTRFS_SNAPSHOT_LOCK_BSD flags to take a BSD lock on the ephemeral
copies which instruct tmpfiles to not touch those ephemeral copies as
long as the BSD lock is held.
2023-06-21 12:48:46 +02:00
Luca Boccassi
01a6510a62
Merge pull request #28082 from mrc0mmand/more-journal-remote-tests
test: add a couple of tests for systemd-journal-{remote,upload}
2023-06-20 23:38:24 +01:00
Frantisek Sumsal
e43e60992e test: add a couple of tests for systemd-journal-{remote,upload} 2023-06-20 15:31:22 +02:00
Lennart Poettering
7dad6de158 hostnamed: when parsing day/month of firmware date, force decimal parsing
safe_atou() by default determines the base from the prefix 0x, 0b, 0o
and for compat with just 0 for octal. This is not what we want here,
since the date components are padded with zeroes yet still decimal.
Hence force decimal parsing (and while we are at it, prohibit a couple
of unexpected decorations).

WIthout this we'd fail to parse any the 8th and 9th day of each months, as
well aus aug and september of every year, because these look like octal
numbers but cannot actually parsed as such.

Let's change the testcase to check for a date that exposes this
bheaviour.
2023-06-20 15:18:58 +02:00
Lennart Poettering
e7932afe1b hostnamed: don't read DMI data within a container
If we run in a container we should show info about the container, not
the host.
2023-06-20 15:04:31 +02:00
Frantisek Sumsal
3f38d582d5 test: cover systemd-journal-remote --url=... 2023-06-19 23:42:00 +02:00
Frantisek Sumsal
033601b79a test: wrap curl when running with ASan
Necessary (unfortunately) for curl on C8S.
2023-06-19 10:19:44 +02:00
Frantisek Sumsal
52db3601bd test: extend the DynamicUser=yes coverage workaround to a couple more services 2023-06-18 23:08:24 +02:00
Luca Boccassi
55e1ff26a5
Merge pull request #28060 from mrc0mmand/remote-journal-tests
test: add a couple of tests for systemd-journal-gatewayd
2023-06-17 11:34:50 +01:00
Luca Boccassi
6acbb3f2fb TEST-55-OOMD: improve ephemeral configuration readability 2023-06-17 00:08:09 +01:00
Luca Boccassi
565b13f8b2 TEST-55-OOMD: use /run/ for configuration instead of /etc/
Make sure configuration is ephemeral if the image is reused
2023-06-17 00:08:09 +01:00
Frantisek Sumsal
1d252ea2ae test: add a couple of tests for systemd-journal-gatewayd 2023-06-16 20:42:43 +02:00
Kiran Vemula
5ed91481ab resolved: added serve stale feature implementation of RFC 8767
serve stale feature to keep the DNS resource records beyond TTL to return them as stale records in case of upstream server is not reachable or returns negative response.
SD_RESOLVED_NO_STALE flag has been added to disable serving stale records via dbus.
added serve stale test cases to TEST-75-RESOLVED
Fixes: #21815
2023-06-16 10:20:15 +01:00
Luca Boccassi
f03b74cb53
Merge pull request #23391 from yuwata/meson-bump-required-version
meson: bump required version
2023-06-16 10:13:44 +01:00
Frantisek Sumsal
e46b313a62 test: clean up the new test case a bit
Follow-up to 61cecfa0d8.
2023-06-16 09:56:32 +02:00
zhmylove
61cecfa0d8 journalctl: add --truncate-newline option 2023-06-16 09:31:47 +02:00
Yu Watanabe
5063f027ef networkd-test.py: disable global DNS= setting
Otherwise, queries may be passed to unexpected DNS servers.
2023-06-16 10:57:51 +09:00
Yu Watanabe
55f9d72a5d networkd-test.py: do not query IPv6 address
From changelog of dnsmasq v2.87:
====
Note in manpage the change in behaviour of -address. This behaviour
actually changed in v2.86, but was undocumented there. From 2.86 on,
(eg) --address=/example.com/1.2.3.4 ONLY applies to A queries. All other
types of query will be sent upstream. Pre 2.86, that would catch the
whole example.com domain and queries for other types would get
a local NODATA answer. The pre-2.86 behaviour is still available,
by configuring --address=/example.com/1.2.3.4 --local=/example.com/
====
2023-06-16 10:44:16 +09:00
Yu Watanabe
77725adedd networkd-test.py: replace deprecated option IPv6AcceptRouterAdvertisements=
Also, use 'yes' or 'no' for boolean options.
2023-06-16 10:43:06 +09:00
Yu Watanabe
eeb88ea41d networkd-test.py: show more debugging logs on failure 2023-06-16 10:43:06 +09:00
Yu Watanabe
0b01cac59a meson: drop non-existent test directories 2023-06-16 10:43:06 +09:00
Frantisek Sumsal
9a27ef092e tree-wide: fix a couple of typos
As reported by Fossies.org.
2023-06-15 20:52:45 +02:00
Frantisek Sumsal
3bba91ef44 test: set $PATH to something predictable in the ASan wrapper
This is still necessary when running with clang's ASan, as it uses an
external binary to symbolize the stack traces.

Follow-up to ba79e8c2cc.
2023-06-15 14:53:32 +01:00
Henrik Holst
cf4dbd84ac
network: make degraded-carrier bond/bridge as routable (#27776)
This makes a bond or bridge interface in the degraded-carrier state but has a routable address
handled as routable operational state.

If the carrier is degraded but the address state is routable then the operational state should be
seen as routable and not degraded because that may be the case for bonds if some of the links are down,
but when that happens the bond as whole is still routable.

This also makes operational state to degraded if address state is degraded even if the link state is
degraded-carrier.

Fixes #22713.
2023-06-15 13:32:10 +09:00
Luca Boccassi
4dad6101fd
Merge pull request #28038 from mrc0mmand/cleanups
A couple of cleanups
2023-06-14 23:18:04 +01:00
Frantisek Sumsal
9457dd8bae test: split TEST-04 into smaller chunks 2023-06-14 20:28:20 +02:00
Frantisek Sumsal
0ea6e6a526 test: exit on first failing subtest
Let's take a step back and revert back to the original behavior where we
exit on a first failing subtest. The current behavior makes fishing out the
failing test details quite unpleasant, and in certain situations the
journal may even be rotated away so we end up with no actionable logs.
2023-06-14 20:28:20 +02:00
Jan Janssen
739a62bb40 meson: Use fs module in more places 2023-06-14 16:05:52 +02:00
Frantisek Sumsal
fb310ba9eb test: re-enable TEST-02 on ppc64le 2023-06-13 10:15:27 +02:00
Frantisek Sumsal
f087837c46 test: make sure ping works for unprivileged users 2023-06-13 10:15:27 +02:00
Frantisek Sumsal
a6695a431f test: copy file xattrs (if any) as well 2023-06-13 10:15:27 +02:00
Frantisek Sumsal
bdee55672a test: merge TEST-61-UNITTESTS-QEMU with TEST-02-UNITTESTS
The test was originally introduced for Ubuntu CI, as it uses
PREFER_NSPAWN=1, but it was subsequently disabled two years ago [0], so
it was pretty much useless. Let's merge it into TEST-02 and tweak it a
bit to run only certain tests under QEMU when $TEST_PREFER_NSPAWN is
set.

[0] b152adbfa9
2023-06-13 10:15:27 +02:00
Frantisek Sumsal
d5a937a62a proc-cmdline: parse the whole /proc/cmdline
The kernel command line may contain newlines which kernel happily
accepts, but we'd ignore everything past the first newline. Let's fix
that by replacing read_one_line_file() with read_full_file().
2023-06-13 09:54:02 +02:00
Frantisek Sumsal
581427bd65 test: make coverage runs happy again 2023-06-11 12:29:59 +01:00
Luca Boccassi
71588cb6ad test-execute: add unit tests for *DirectorySymlink= 2023-06-08 23:11:42 +01:00
Luca Boccassi
4021e9e3e9
Merge pull request #26059 from DaanDeMeyer/cred-glob
creds: Add ImportCredential=
2023-06-08 20:40:37 +01:00
Daan De Meyer
bbfb25f4b9 creds: Add ImportCredential=
ImportCredential= takes a credential name and searches for a matching
credential in all the credential stores we know about it. It supports
globs which are expanded so that all matching credentials are loaded.
2023-06-08 14:09:18 +02:00
Luca Boccassi
bd65ee34ae
Merge pull request #27958 from mrc0mmand/test-functions-tweaks
test: a couple of assorted test-functions tweaks
2023-06-07 21:54:01 +01:00
Frantisek Sumsal
8e81885531 test: wrap agetty & getfacl when running with sanitizers
The list is getting slightly ridiculous.
2023-06-07 16:26:21 +02:00
Frantisek Sumsal
93b896e90e test: drop $SKIP_INITRD
It's pointless nowadays, since we always need an initrd for the test VMs
as we require modules that are usually not compiled in the kernel.
2023-06-07 15:23:36 +02:00
Frantisek Sumsal
25bc469727 test: rebuild the ldconfig cache after changing its configuration
Follow-up to ba79e8c2cc.
2023-06-07 15:19:44 +02:00
Lennart Poettering
1775872679 units: change TimeoutSec=0 to TimeoutSec=infinity
Follow-up for #27936

Let's also update a bunch of static unit files, matching what we just
did for the generators.
2023-06-06 18:23:43 +01:00
Lennart Poettering
a9b837aa34 generators: change TimeoutSec=0 to TimeoutSec=infinity
With these settings we intend to turn off timeouts for possibly
interactive/slow commands. The officially documented way to turn off the
time-outs is to setting them to infinity. So far we set them to zero
here though.

This lead to some confusiong, for example #18224. Let's fix this by
uniformly spelling out TimeoutSec=infinity.

This doesn't change behaviour. It just makes our generated files match
what we document, without relying on historic compat support.

Fixes: #18224
2023-06-06 12:38:16 +01:00
Frantisek Sumsal
6f814d4f5d
Merge pull request #27933 from mrc0mmand/selinux
test: a couple of TEST-06-SELINUX tweaks
2023-06-06 11:18:50 +02:00
Luca Boccassi
6aea5ce814 tests: fix shellcheck warnings 2023-06-06 02:37:36 +01:00
Frantisek Sumsal
d5ab23aa54 test: a couple of assorted cleanups
- sort binaries
- send stdout/stderr of the autorelabel service to console as well
2023-06-05 23:30:01 +02:00
Frantisek Sumsal
fa5dee77c0 test: load the SELinux module outside of the VM
Turns out we can, apart from just building the module, "shove" it into
the SELinux database in a chroot as well. This brings quite significant
time savings, as the SELinux db rebuild takes 2 - 5 minutes in a VM
without acceleration (and takes currently ~half of the runtime of the test
in the C8S job).
2023-06-05 22:52:38 +02:00
Frantisek Sumsal
8c0ace5739 test: add a reasoning why we don't use the SELinux-provided units 2023-06-05 22:52:38 +02:00
Yu Watanabe
3db7f3c58c
Merge pull request #27912 from mrc0mmand/cryptsetup-tests
test: add a couple more tests for systemd-cryptsetup
2023-06-06 03:34:59 +09:00
Luca Boccassi
9bb4f9f2ff
Merge pull request #27926 from DaanDeMeyer/repart-offline
repart: Add --offline argument
2023-06-05 19:11:41 +01:00
Frantisek Sumsal
d7c1df84d9 test: make sure we unmount /var late during shutdown
To avoid the "mountpoint is busy" error.
2023-06-05 16:54:31 +02:00
Frantisek Sumsal
eb26f34a09 test: add a couple more tests for systemd-cryptsetup 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
71d7f02cc7 test: make check_result_*() set -e friendly 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
e6faf0ee22 test: use check_result_common()
The TEST-24 has been silently timing out for quite a while in the C8S
job, as the check_result_qemu() override lacked some error checks,
whoopsie.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
168ccb879f test: clean up the test cleanup a bit 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
00c2676972 test: minor cleanup
No functional change.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
b7e913841b test: make the data partition larger for the cryptsetup test
As we use it for /var and with the default 100 MiB there's not enough
space for the journal.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
0334afe4d0 test: make the root/data partition size configurable per test 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
70bdf6e661 test: introduce test_require_bin() and use it
No functional change.
2023-06-05 16:50:13 +02:00
Frantisek Sumsal
97d7af86b5 test: fix indentation 2023-06-05 16:50:13 +02:00
Frantisek Sumsal
18fa5c8283 test: move TPM2-related setup stuff into test-functions
And hide it all behind $TEST_SETUP_SWTPM.
2023-06-05 16:50:13 +02:00
Zbigniew Jędrzejewski-Szmek
1ab32e8aaf
Merge pull request #27871 from yuwata/udevadm-verify-downgrade-style-issues
udevadm-verify: downgrade log level about style issues
2023-06-05 16:07:19 +02:00
Frantisek Sumsal
0efa27bd4b test: allow running only specified subtests/testcases
Useful when debugging, e.g.:

make -C test/TEST-74-AUX-UTILS clean setup run TEST_MATCH_SUBTEST=run

Resolves: #27914
2023-06-05 15:58:37 +02:00
Daan De Meyer
94d74c9cd7 test: Test --offline= in TEST-58-REPART
Instead of using a privileged and unprivileged user to test the
offline and online logic of systemd-repart, let's always run repart
as root and use the --offline= argument to specify repart to use
either the offline or online logic.
2023-06-05 15:29:47 +02:00
Yu Watanabe
1bf3dd4153 udev: downgrade log level about style issues
And add --no-style switch that make style issues not critical.
2023-06-05 11:37:26 +09:00
Yu Watanabe
2ef0959fbe test: drop unnecessary copy of expected output 2023-06-05 11:21:28 +09:00
Yu Watanabe
4134614fc0 udev-rules: terminate log messages with period 2023-06-05 11:21:28 +09:00
Frantisek Sumsal
d99e099fb4 test: drop the --recursive=no test
As the outcome also depends on availability of the PID namespace, so
the test might (and does) unexpectedly pass in some environments.
2023-06-03 16:30:46 +02:00
Frantisek Sumsal
686da1c095 test: ignore missing coverage in TEST-82-SOFTREBOOT
As we temporarily mount rootfs read-only there.
2023-06-03 16:30:46 +02:00
Adrian Vovk
0470f91983 sysupdate.d: Add way to drop binaries into $BOOT
As described in the BLS, we should place binaries into the XBOOTLDR
directory if it is available, otherwise into the ESP. Thus, we might
need to put binaries into /boot or into /efi depending on the existence
of the XBOOTLDR partition.

With this change, we introduce a new PathRelativeTo= config option that
makes this functionality possible
2023-06-03 09:13:27 +02:00
Luca Boccassi
e1aacab7d5
Merge pull request #27903 from mrc0mmand/test-followups
test: a couple of systemd-{coredump,pstore,run} followups
2023-06-02 23:56:58 +01:00
Lennart Poettering
093d545658 test: add integration test for soft reboots incl. fdstore passing 2023-06-02 18:43:11 +02:00
Lennart Poettering
8af66251a1 test: disable SoftReboot() in dfuzzer test for now
As requested:

https://github.com/systemd/systemd/pull/27435#issuecomment-1527810336
2023-06-02 18:43:11 +02:00
Frantisek Sumsal
50fb26d237 test: probe a couple more paths in systemd-run 2023-06-02 16:59:58 +02:00
Frantisek Sumsal
1326d2dd05 test: sync with the fake binary before killing it
On faster machines we might be too fast and kill the fake binary during
fork() which then makes kernel report a "wrong" binary in the coredump,
e.g.:

[   31.408078] testsuite-74.sh[548]: + /tmp/make-dump /tmp/test-dump SIGTRAP
[   31.409720] testsuite-74.sh[560]: + bin=/tmp/test-dump
[   31.409720] testsuite-74.sh[560]: + sig=SIGTRAP
[   31.409720] testsuite-74.sh[560]: + ulimit -c unlimited
[   31.409720] testsuite-74.sh[560]: + pid=561
[   31.409720] testsuite-74.sh[560]: + sleep 1
[   31.409720] testsuite-74.sh[560]: + kill -s SIGTRAP 561
[   31.409720] testsuite-74.sh[560]: + wait 561
[   31.491757] systemd[1]: Created slice system-systemd\x2dcoredump.slice.
[   31.524488] systemd[1]: Started systemd-coredump@0-563-0.service.
[   31.616372] systemd-coredump[564]: [🡕] Process 561 (make-dump) of user 0 dumped core.

                                      Stack trace of thread 561:
                                      #0  0x00007ff86bb49af7 _Fork (libc.so.6 + 0xd4af7)
                                      #1  0x00007ff86bb4965f __libc_fork (libc.so.6 + 0xd465f)
                                      #2  0x000055e88011b0ad make_child (bash + 0x550ad)
                                      #3  0x000055e8800fd05f n/a (bash + 0x3705f)
                                      #4  0x000055e880100116 execute_command_internal (bash + 0x3a116)
                                      #5  0x000055e8801011f2 execute_command_internal (bash + 0x3b1f2)
                                      #6  0x000055e8801025b6 execute_command (bash + 0x3c5b6)
                                      #7  0x000055e8800f134b reader_loop (bash + 0x2b34b)
                                      #8  0x000055e8800e757d main (bash + 0x2157d)
                                      #9  0x00007ff86ba98850 n/a (libc.so.6 + 0x23850)
                                      #10 0x00007ff86ba9890a __libc_start_main (libc.so.6 + 0x2390a)
                                      #11 0x000055e8800e83b5 _start (bash + 0x223b5)
                                      ELF object binary architecture: AMD x86-64
[   31.666617] testsuite-74.sh[560]: /tmp/make-dump: line 12:   561 Trace/breakpoint trap   (core dumped) "$bin" infinity
...
$ coredumpctl list --file system.journal
TIME                         PID UID GID SIG     COREFILE EXE            SIZE
Fri 2023-06-02 10:42:10 CEST 561   0   0 SIGTRAP journal  /usr/bin/bash     -
Fri 2023-06-02 10:42:11 CEST 570   0   0 SIGABRT journal  /tmp/test-dump    -
Fri 2023-06-02 10:42:12 CEST 582   0   0 SIGTRAP missing  /tmp/test-dump    -
Fri 2023-06-02 10:42:13 CEST 593   0   0 SIGABRT missing  /tmp/test-dump    -
2023-06-02 13:24:32 +02:00
Frantisek Sumsal
e8ee168344 test: clean up our mess after the pstore test 2023-06-02 10:07:57 +02:00
Frantisek Sumsal
dee4a9923b test: add a couple of tests for systemd-run 2023-06-01 23:12:47 +02:00
Frantisek Sumsal
6178ced491 test: make the multiple-file test more thorough
Let's check if we keep the old records after multiple systemd-pstore
invocations (i.e. simulate a scenario where we get multiple crashes and
multiple machine reboots).
2023-06-01 20:06:40 +02:00
Frantisek Sumsal
57130ca01b test: make TEST-04 stable once again
Wait a bit if necessary for the cursor file to appear.

Follow-up fb35feae97.
2023-06-01 21:11:21 +09:00
Frantisek Sumsal
4c709f3908 test: skip the test early if we're built without systemd-homed
We check for homed stuff in the test itself, but this is way too late,
since we already started a unit that Requires=systemd-homed.service
(testsuite-46.service). For now this doesn't matter, but with #27852
the offending transaction is dropped from the job queue, making the test
fail.

Spotted in #27852 in Ubuntu CI.
2023-06-01 06:30:45 +09:00
Yu Watanabe
322bda8241
Merge pull request #27826 from yuwata/network-link-ready-without-ndisc-when-has-static-address
network: do not request dynamic addressing protocols finished when at…
2023-06-01 06:29:55 +09:00
Yu Watanabe
2f96a29c2c wait-online: request that at least one managed online interface exists
Fixes a regression caused by ab3aed4a03.

I thought the commit does not cause any severe regression. However,
drivers for network interfaces may be loaded later. So, we should wait
if no network interface is found.

Fixes #27822.
2023-05-31 22:12:03 +02:00
Daan De Meyer
edabe6fc11
Merge pull request #27806 from DaanDeMeyer/fix-mkosi-check
mkosi: Use proper check to detect whether we're in a VM
2023-05-31 15:26:05 +02:00
Daan De Meyer
2533fdd0fb
Merge pull request #27766 from rphibel/cleanup-cgroups-before-cleaning-units
Don't GC unit if it is in cgroup_empty_queue
2023-05-31 14:48:42 +02:00
Daan De Meyer
a0807bdc23 sysv-generator-test: Bump log level to info
Otherwise, non-fatal debug error logs might interfere with the test.
2023-05-31 14:19:25 +02:00
Luca Boccassi
1a7e5c51dc
Merge pull request #27853 from keszybz/various-bits-and-pieces-included-to-reuse-the-ci-run
Various bits and pieces included to reuse the ci run
2023-05-31 11:08:36 +01:00
Luca Boccassi
29084afd91
Merge pull request #27519 from yuwata/journalctl-fixes
journalctl: several fixes and cleanups for --follow
2023-05-31 11:05:54 +01:00
Luca Boccassi
23f315dc08
Merge pull request #27835 from keszybz/test-58-repart-modernization
Cleanup/simplifications for TEST-58-repart
2023-05-31 11:00:18 +01:00
Zbigniew Jędrzejewski-Szmek
088d8c99fe test-fstab-generator: fix test on systemd with systemd-boot
(… or other boot loaders implementing the Boot Loader Interface.)

Fixes #27857.
2023-05-31 10:59:50 +01:00
Zbigniew Jędrzejewski-Szmek
e80444729f tests: drop unnecessary redirection of stderr
command -v doesn't print anything to stderr, let's use the canonical
form with just >/dev/null.
2023-05-30 16:04:35 +02:00
Daan De Meyer
cc11107fd2 test-udev: Skip running in container
Containers generally don't have permission to mknod() which is
required by test-udev so let's skip the test as well if we detect
we're running in a container.
2023-05-30 14:48:38 +02:00
Daan De Meyer
600bf76c17 repart: Allow target directory excludes
Currently, ExcludeFiles= supports excluding directories on the host
from being copied. Let's extend this to also support preventing files
from being copied into specific directories in the partition by adding
a new option ExcludeFilesTarget=. An example where this is useful is
when setting up btrfs subvolumes in the top level that are intended to
be mounted into specific locations, so /usr would be stored in @usr,
/home in @home, .... To accomplish this, we need to copy /usr to @usr
and prevent any files from being copied into /usr in the partition,
which with this commit, we'd be able to do as follows:

```
[Partition]
CopyFiles=/usr:@usr
ExcludeFilesTarget=/usr
```
2023-05-30 13:45:49 +02:00
Yu Watanabe
9e7d91ed97 network: do not request dynamic addressing protocols finished when at least one static address is configured
The setting IPv6AcceptRA= is defaults to yes, hence, even if a .network
file for an interface has static IP address configuration, it may takes
few seconds for the interface being configured state, as NDisc for the
interface needs to be finished. That makes wait-online.service
needlessly slow. Typically, such delay is not necessary for statically
configured networks.

Let's make the required condition slightly relaxed; if a .network file
has static IP address configurations, then let's make the matching
interface enter the 'configured' state soon after the static addresses
configured on the interface.

Note, this does not change the default for IPv6AcceptRA=, hence, NDisc
still runs on interfaces by default. So, addresses, routes, DNS servers,
and so on based on RA will be assigned on interfaces later.

Strictly speaking, this breaks backward compatibility, but the previous
behavior is not clearly documented. If a user requested both static
IPv4 address and IPv6 SLAAC address configured before an interface being
entered to the 'configured' state, then '--ipv6' for wait-online can be
used. So, the behavior change should not cause severe regression.

Closes #27779.
2023-05-30 17:39:11 +09:00
Zbigniew Jędrzejewski-Szmek
730ab2cc23 TEST-58: remove whitespace between redirection operator and its argument 2023-05-30 09:46:20 +02:00
Zbigniew Jędrzejewski-Szmek
1b6f8915f0 TEST-58: add echo calls to print what is happening
This makes it easier to identify the relevant test in the logs when
something fails.
2023-05-30 09:46:20 +02:00
Zbigniew Jędrzejewski-Szmek
dfb3ebfd60 TEST-58: create config files as root
There is really no reason to go out of our way to create the config files as
the unprivileged user. And in the logs, the runas calls are quite verbose,
distracting from the interesting stuff. Also add .defs/.imgs/.root to the
temporary paths to make them easier to distinguish in the logs.
2023-05-30 09:46:20 +02:00
Zbigniew Jędrzejewski-Szmek
b13d59243b test/README: fix advice for testsuite debugging
KERNEL_APPEND="systemd.unit=multi-user.target" is not very useful, because the
machine will still shut down as soon as the tests succeeds or fails. But
INTERACTIVE_DEBUG=1 works great, so let's simplify the instructions and
recommend that.
2023-05-30 09:46:20 +02:00
Richard Phibel
8db998981a core: Don't GC unit if it is in cgroup_empty_queue
The gc_unit_queue is dispatched before the cgroup_empty_queue.  Because
of this, when we enter in on_cgroup_empty_event, the unit in
cgroup_empty_queue may already have been freed and we don't clean up the
corresponding cgroup. With this change, we prevent the unit from being
garbage collected if it is in the cgroup_empty_queue.
2023-05-29 13:26:15 +02:00
Yu Watanabe
80ec3db5c7 journalctl: fix --follow with non-matching filter
When there is no matching entry stored in journal, then initial call of
`sd_journal_previous()` following `sd_journal_seek_tail()` returns
zero, and does not move the read pointer.
In the main loop, on every journal event, we call `sd_journal_next()`,
even though the current location is tail, and it takes no effect.

In such a case, we need to call `sd_journal_previous()` instead of
`sd_journal_next()`.
2023-05-28 23:53:58 +09:00
Yu Watanabe
fb35feae97 test: add testcase for 'journalctl --follow --cursor-file='
Also, add a FIXME comment to illustrate the issue uncovered after by
7a4ee86161.
2023-05-28 14:52:32 +09:00
Frantisek Sumsal
837773add4 Revert "test: add test case for systemd-update-utmp vs daemon-reexec"
Temporarily revert the test case for #27167, as the additional
daemon-reexecs exacerbate #27287, making CIs fail quite often.
As the #27167 is also covered by TEST-01-BASIC itself, since we do
daemon-reexec there anyway, we shouldn't lose any coverage, but it
should make CIs more stable until #27287 is figured out.

Resolves (or more like works around): #27807

This reverts commit d689f70a2c.
2023-05-27 07:57:20 +09:00
Zbigniew Jędrzejewski-Szmek
5287b3a87a
Merge pull request #27746 from yuwata/unit-bidirectional-dep
core/unit: make unit dependency always bidirectional
2023-05-26 16:20:48 +02:00
Zbigniew Jędrzejewski-Szmek
c4f521a91b
Merge pull request #27554 from ElvishJerricco/tmpfiles-c-escapes
tmpfiles: Allow C escapes
2023-05-26 15:42:48 +02:00
Lennart Poettering
0706718c07
Merge pull request #27563 from yuwata/fstab-generator
fstab-generator: support defining mount units through kernel command line
2023-05-26 02:52:19 -07:00
Yu Watanabe
83123a4498 core/unit: search shared namespace in transitive relation of JoinsNamespaceOf=
Previously, dependency chain of JoinsNamespaceOf= did not work, e.g.
- a.service has JoinsNamespaceOf=b.service
- b.service has JoinsNamespaceOf=c.service
if, first c.service, next a.service, finally b.service is started,
then a.service is not joined to the namespace of c.service. And, as
mentioned in the document, the namespace used by b.service is not
deterministic.

This makes when searching exsiting namespace to be joined, all units in
the transitive dependency of JoinsNamespaceOf= are checked.
2023-05-26 15:23:57 +09:00
Will Fancher
4b6621fef3 tmpfiles: Allow C escapes
Fixes #26955
2023-05-26 00:45:54 -04:00
Will Fancher
5f0ee1b635 tmpfiles: Test C-style escape sequences 2023-05-26 00:45:15 -04:00
Frantisek Sumsal
ba79e8c2cc test: split the ASan wrapper into smaller blocks and tidy it up a bit
No functional change (hopefully), just making it easier on the eyes.
2023-05-26 13:43:07 +09:00
Yu Watanabe
a60f96fcf5 core/unit: make JoinsNamespaceOf= implies the inverse dependency
Previously, even if a.service has JoinsNamespaceOf=b.service, the
inverse direction of reference was not introduced.
Hence, a.service is started earlier than b.service, the namespace will
not shared with b.service.
Also, even if a.service had the reference to b.service, b.service did not.
If b.service is freed earlier, then unit_clear_dependencies() does not clear
the reference from a to b, and will cause use-after-free on unit_free() for
a.service.

Let's make JoinsNamespaceOf=b.service in a.service implies the inverse
dependency, i.e. JoinsNamespaceOf=a.service for b.service. Then, we can safely
free b.service.
2023-05-26 11:50:08 +09:00
Yu Watanabe
8493a82d0b test: add tests for JoinsNamespaceOf=
To illustrate the current behavior of the dependency.
2023-05-26 11:50:05 +09:00
Yu Watanabe
d689f70a2c test: add test case for systemd-update-utmp vs daemon-reexec 2023-05-24 20:06:10 +09:00
Yu Watanabe
08bc702b12 test: drop a workaround
Follow-up for 61961e693d.
2023-05-24 20:06:10 +09:00
Yu Watanabe
5f1f05b961
Merge pull request #27740 from dtardon/list-sessions-idle
Show idle status in `loginctl list-sessions`
2023-05-24 20:03:39 +09:00
Luca Boccassi
fe830b84d4
Merge pull request #27761 from yuwata/network-vlan-qos-mapping
network: fix vlan qos mapping
2023-05-24 09:59:41 +01:00
David Tardon
556723e738 loginctl: show session idle status in list-sessions 2023-05-24 10:04:45 +02:00
Yu Watanabe
5c4e96c28c test: rotate journal before storing coredumps
Hopefully fixes the failure like
https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux-sanitizers/2558/
---
[   66.708894] testsuite-74.sh[728]: + coredumpctl --json=off
[   66.709344] testsuite-74.sh[826]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.709773] testsuite-74.sh[826]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.711134] testsuite-74.sh[826]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.711789] testsuite-74.sh[826]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.712460] testsuite-74.sh[826]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.713505] testsuite-74.sh[728]: + coredumpctl --root=/
[   66.714144] testsuite-74.sh[828]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.714535] testsuite-74.sh[828]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.715208] testsuite-74.sh[828]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.715907] testsuite-74.sh[828]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.716565] testsuite-74.sh[828]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.717494] testsuite-74.sh[728]: + coredumpctl --directory=/var/log/journal
[   66.718188] testsuite-74.sh[830]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.882072] testsuite-74.sh[830]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.882642] testsuite-74.sh[830]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.883450] testsuite-74.sh[830]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.883944] testsuite-74.sh[830]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.885448] testsuite-74.sh[728]: + coredumpctl --file=/var/log/journal/2e1ed84be19a4e22adfc99ad849be1f6/system.journal
[   66.885989] testsuite-74.sh[728]: + at_exit
[   66.894162] coredumpctl[833]: No coredumps found.
---
2023-05-24 09:22:13 +02:00
Yu Watanabe
73d24e45f8 test-network: add tests for vlan QoS mapping 2023-05-24 11:15:44 +09:00
Yu Watanabe
93ec924c41 test: add test cases for defining mount and swap units from kernel cmdline 2023-05-24 08:23:22 +09:00
Yu Watanabe
82c29dbee0 test-fstab-generator: add tests for mount options 2023-05-24 08:23:22 +09:00
Yu Watanabe
70bf9f62b9 test-fstab-generator: also check file contents
Since e683878c0f, only filenames are
checked. Let's check contents of generated unit files.
2023-05-24 08:23:22 +09:00
Frantisek Sumsal
909eb4c01d json: correctly handle magic strings when parsing variant strv
We can't dereference the variant object directly, as it might be
a magic object (which has an address on a faulting page); use
json_variant_is_sensitive() instead that handles this case.

For example, with an empty array:

==1547789==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000023 (pc 0x7fd616ca9a18 bp 0x7ffcba1dc7c0 sp 0x7ffcba1dc6d0 T0)
==1547789==The signal is caused by a READ memory access.
==1547789==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x7fd616ca9a18 in json_variant_strv ../src/shared/json.c:2190
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7fd61564a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7fd61564a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

DEDUP_TOKEN: json_variant_strv--oci_args--json_dispatch
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../src/shared/json.c:2190 in json_variant_strv
==1547789==ABORTING

Or with an empty string in an array:

../src/shared/json.c:2202:39: runtime error: member access within misaligned address 0x000000000007 for type 'struct JsonVariant', which requires 8 byte alignment
0x000000000007: note: pointer points here
<memory cannot be printed>
    #0 0x7f35f4ca9bcf in json_variant_strv ../src/shared/json.c:2202
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7f35f364a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7f35f364a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/shared/json.c:2202:39 in

Note: this happens only if json_variant_copy() in json_variant_set_source() fails.

Found by Nallocfuzz.
2023-05-23 20:18:21 +02:00
David Tardon
98a155962d test: extend test for loginctl list-* 2023-05-23 09:29:21 +02:00
Luca Boccassi
b1f17f78e3
Merge pull request #27739 from dtardon/test-session-properties
Add a test for org.freedesktop.logind1.Session SetIdleHint
2023-05-22 23:55:25 +01:00