1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00
Commit Graph

2778 Commits

Author SHA1 Message Date
Frantisek Sumsal
3fe2885cc5 test: run test-shutdown.py in verbose mode
To make the debugging of spurious fails a bit easier.
2022-03-21 16:13:09 +01:00
Frantisek Sumsal
c3d83ff940 test: don't try to execute a non-existing script 2022-03-21 15:55:49 +01:00
Luca Boccassi
7659e52397
Merge pull request #22798 from keszybz/test-output-narrow-and-timeouts
Increase timeout for a flaky test and make test names shorter to avoid line wrapping in output
2022-03-21 14:13:22 +00:00
Zbigniew Jędrzejewski-Szmek
8e1fc5d939 fuzz: rename fuzz-dhcp-server-relay-message to fuzz-dhcp-server-relay
We can only relay messages, so we can make the name shorter without
losing informational value. This makes meson test output look better.
2022-03-21 11:43:47 +01:00
Zbigniew Jędrzejewski-Szmek
8e2131bfae fuzz: rename the longest test samples
"meson test" uses a test name generated from the file name and those long names
cause the test log output to exceed terminal width which looks bad. Let's replace
some long names with more-meaningful names that actually say something about
the tests.
2022-03-21 11:42:35 +01:00
Lennart Poettering
7910ec3bcd test: add integration test for sysupdate 2022-03-19 00:13:55 +01:00
Luca Boccassi
1219bd4306 Add tests and documentation for all remaining sandboxing in user manager 2022-03-18 10:09:56 +01:00
Lennart Poettering
55c8f9ecb0
Merge pull request #22754 from mrc0mmand/creds_dir_specifier
core: add %d specifier for the $CREDENTIALS_DIRECTORY
2022-03-18 09:23:01 +01:00
Michael Biebl
ad337e55a3 tree-wide: fix duplicated words
the the
in in
not not
we we
2022-03-18 08:14:01 +09:00
Frantisek Sumsal
43b9b2053c core: add %d specifier for the $CREDENTIALS_DIRECTORY
Resolves: #22549
2022-03-17 17:45:01 +01:00
Grigori Goronzy
fd8b924820 cryptenroll: add tests for TPM2 unlocking
Add tests for enrolling and unlocking. Various cases are tested:

- Default PCR 7 policy w/o PIN, good and bad cases (wrong PCR)
- PCR 7 + PIN policy, good and bad cases (wrong PCR, wrong PIN)
- Non-default PCR 0+7 policy w/o PIN, good and bad cases (wrong PCR 0)

v2: rename test, fix tss2 library installation, fix CI failures
v3: fix ppc64, load module
2022-03-15 21:17:00 +01:00
Yu Watanabe
6626ea08f6 test: wait for loopback device being actually created
It seems there exists a short time period that we cannot see the
loopback device after `losetup` is finished:
```
testsuite-58.sh[367]: ++ losetup -b 1024 -P --show -f /tmp/testsuite-58-sector-1024.img
kernel: loop1: detected capacity change from 0 to 204800
testsuite-58.sh[285]: + LOOP=/dev/loop1
testsuite-58.sh[285]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
testsuite-58.sh[368]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
testsuite-58.sh[368]: Failed to determine canonical path for '/dev/loop1': No such file or directory
testsuite-58.sh[368]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
```
2022-03-15 12:35:50 +09:00
Yu Watanabe
8c166c962d test: format disk image through loopback device
It seems that the change on the image file sometimes not propagated on
the loopback device immediately.
2022-03-15 12:35:50 +09:00
Yu Watanabe
cc75e1f7c9 test: use /var/tmp for storing disk images
The Ubuntu CI on ppc64el seems to have a issue on tmpfs, and files
may not be fsynced. See c10caebb98.
For safety, let's use /var/tmp to store disk images.
2022-03-15 12:35:50 +09:00
Luca Boccassi
9c9a6123d7
Merge pull request #22714 from mrc0mmand/codeql-docs
A couple of doc updates
2022-03-11 19:03:38 +00:00
Frantisek Sumsal
42734a21eb test: document how to run CodeQL/LGTM stuff manually
Let's have this documented somewhere so I don't have to relearn all this
stuff every time I need it.
2022-03-11 16:51:53 +01:00
Lennart Poettering
15e152acd1
Merge pull request #22618 from yuwata/network-safe-string
network: dhcp-server: refuse unsafe filename
2022-03-11 11:33:07 +01:00
Yu Watanabe
6278e42878 network: dhcp: rename NextServer= and Filename= settings
And make the settings configures DHCP option 66 and 67.

Follow-ups for #22615.
Fixes #22661.
2022-03-11 10:14:57 +09:00
Luca Boccassi
24759d8f08 core: support ExtensionDirectories in user manager
Unprivileged overlayfs is supported since Linux 5.11. The only
change needed to get ExtensionDirectories to work is to avoid
hard-coding the staging directory to the system manager runtime
directory, everything else just works (TM).
2022-03-10 20:38:10 +00:00
Zbigniew Jędrzejewski-Szmek
a257c941ad manager: pass monitor metadata in more cases
The first ExecStartPre or the first ExecStart commands would get the metadata,
but not the subsequent ones. Also check that we do not pass it in
ExecStartPost.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
f086cca248 TEST-68: enhance testing of chained commands
The test would fail when the the same handler was used for multiple
*failing* units. We need to call 'reset-failed' to let the manager forget
about the earlier ones.

systemd-analyze log-target console is removed, because it's easier to follow
the logs if logging it to the journal.
2022-03-10 14:51:28 +00:00
Zbigniew Jędrzejewski-Szmek
ff7b9a2693 TEST-68-PROPAGATE-EXIT-STATUS: deobfuscate shell code and fix typo
After the cleanup, it was fairly easy to see the wrong variable name ;)
2022-03-10 14:43:14 +00:00
Luca Boccassi
c19c4ab148 test: cover template OnFailure/OnSuccess handlers in TEST-68-PROPAGATE-EXIT-STATUS 2022-03-10 14:43:14 +00:00
Luca Boccassi
95c81c55b2 core: split $MONITOR_METADATA and return it only if a single unit triggers OnFailure/OnSuccess
Remove the list logic, and simply skip passing metadata if more than one
unit triggered an OnFailure/OnSuccess handler.
Instead of a single env var to loop over, provide each separate item
as its own variable.

Fixes https://github.com/systemd/systemd/issues/22370
2022-03-10 14:43:14 +00:00
Luca Boccassi
ea63a260d4 core: support MountAPIVFS and RootDirectory in user manager
The only piece missing was to somehow make /proc appear in the
new user+mount namespace. It is not possible to mount a new
/proc instance, not even with hidepid=invisible,subset=pid, in
a user namespace unless a PID namespace is created too (and also
at the same time as the other namespaces, it is not possible to
mount a new /proc in a child process that creates a PID namespace
forked from a parent that created a user+mount namespace, it has
to happen at the same time).

Use the host's /proc with a bind-mount as a fallback for this
case. User session services would already run with it, so
nothing is lost.
2022-03-10 10:21:03 +00:00
Luca Boccassi
4c0ab40ab8 test: set log level of user manager in TEST-43 to debug 2022-03-09 02:08:25 +00:00
Yu Watanabe
c10caebb98 test: skip TEST-17 on ubuntu ppc64el
On Ubuntu CI on ppc64el, the test randomly fails when /run/udev is not
synced before checking its contents (see #22357). But /run/udev is a
tmpfs and fsync on tmpfs is noop (see `struct shmem_file_operations` in
mm/shmem.c of the kernel), hence, it is not necessary to call fsync on
/run/udev in general. This should be a testing emvironment issue (I
guess it is an issue on nested KVM on ppc64el), instead of an issue on
udev.

C.f. #22357.

Fixes #21603.
2022-03-08 17:03:11 +00:00
Luca Boccassi
4f2dba98ad TEST-29: do not pass -q to mk/unsquashfs, not supported on CentOS 8 2022-03-08 18:02:09 +09:00
Bastien Nocera
d48bf01636 memory-id: Work-around incorrect "Number of slots"
In some BIOSes, the "Number of slots or sockets available for Memory
Devices in this array" is incorrectly set to the number of memory array
that's populated.

Work-around this problem by outputting the number of sockets after
having parsed them so that consumers of this data can carry on expecting
an accurate number in this property.

This fixes the number of memory slots advertised for the HP Z600.

See https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1686
2022-03-07 15:33:26 +00:00
Zbigniew Jędrzejewski-Szmek
13391986b5 TEST-29: trim output a bit
IIUC, pipefail doesn't matter for a sequence of commands joined with &&, and we
don't have any pipes. And such a failing expression also does not trigger an
exit, so the set +e/set -e were noops.
2022-03-07 14:31:36 +01:00
Frantisek Sumsal
55c09511e1 test: check systemd RPM macros
Make sure our RPM macros work as intended. Based on the original PR
(#16464) by Mikhail Novosyolov.

Co-authored-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2022-03-06 13:07:20 +09:00
Yu Watanabe
0c91c7a241 network: l2tp: change create type to independent
L2TP tunnel does not have underlying interface. Let's change its type to
independent.
2022-02-27 09:36:48 +09:00
Yu Watanabe
8b49ee2dcd network: l2tp: make Local= optionally take interface name 2022-02-27 09:36:48 +09:00
Frantisek Sumsal
d490188b8f test: accept both unpadded and padded partition sizes
Since util-linux/util-linux@921c7da55e
libfdisk aligns the last partition (on GPT) for optimal I/O. Let's
account for that.

Fixes: #22606
2022-02-25 18:25:04 +00:00
Luca Boccassi
6b3211c15e
Merge pull request #22611 from yuwata/network-activation-policy-stacked-netdevs
network: make activation policy also work for stacked netdevs
2022-02-24 22:57:35 +00:00
Yu Watanabe
369ac19243 network: add NextServer= and Filename= setting to [DHCPServer] section
Closes #4403.
2022-02-25 02:45:47 +09:00
Yu Watanabe
ee9918ae46 test-network: add test case for activation policy for stacked netdevs
For issue #22593.
2022-02-24 16:25:05 +09:00
Yu Watanabe
459c35d4c5 test-network: check existence before calling networkctl or ip command 2022-02-24 16:25:05 +09:00
Yu Watanabe
3c39b9cf37 test-network: remove unused configs 2022-02-24 08:37:30 +09:00
Yu Watanabe
6dcc087cb6 test-network: add testcases for address property change
This adds a testcase for issue #22515.
2022-02-24 07:37:50 +09:00
Frantisek Sumsal
80ff956704
Merge pull request #22591 from evverx/no-deps
ci: build systemd without optional dependencies
2022-02-23 09:27:41 +00:00
Evgeny Vereshchagin
fb53316fde meson: pass skip-deps on to the fuzzers as well
they should be tested without optional dependecines as well. CIFuzz
kind of covers that but let's just make sure local builds are fine as
well.
2022-02-22 17:50:14 +00:00
Luca Boccassi
aff3a9e1fa watchdog: add setting to configure pretimeout governor 2022-02-22 17:19:54 +00:00
Curtis Klein
5717062e93 watchdog: Add watchdog pretimeout support
Add support for managing and configuring watchdog pretimeout values if
the watchdog hardware supports it. The ping interval is adjusted to
account for a pretimeout so that it will still ping at half the timeout
interval before a pretimeout event would be triggered. By default the
pretimeout defaults to 0s or disabled.

The RuntimeWatchdogPreSec config option is added to allow the pretimeout
to be specified (similar to RuntimeWatchdogSec). The
RuntimeWatchdogPreUSec dbus property is added to override the pretimeout
value at runtime (similar to RuntimeWatchdogUSec). Setting the
pretimeout to 0s will disable the pretimeout.
2022-02-22 17:19:54 +00:00
Yu Watanabe
07b7337aff network: dhcp-pd: allow to assign the same subnet prefix to multiple interfaces
There is no reason networkd refuses that. Especially, when multiple
downstream interfaces are connected to the same network, it is natural to
assign the same subnet prefix to them.

Prompted by #22571.
2022-02-22 20:39:32 +09:00
Yu Watanabe
38488babe7 network: dhcp-pd: fix prefix length of address assigned to upstream interface
This effectively revert ab0c82d9f7.

I have no idea why I did that...

Fixes #22559.
2022-02-22 20:39:28 +09:00
Yu Watanabe
63b5e05ff9
Merge pull request #22545 from yuwata/network-match-kind
network, udev: introduce Kind= setting in [Match] section
2022-02-18 01:20:18 +09:00
Frantisek Sumsal
93c3b6989b test: set ReadWritePaths= only for units from TEST-20
as setting it system-wide has some undesirable side-effects.

Follow-up to b6fc524.
2022-02-17 14:45:21 +00:00
Yu Watanabe
65022cd7ab network,udev/net: add Kind= settings in [Match] section
This may be useful for writing .network or .link files matching with
virtual interfaces.

Closes #22541.
2022-02-17 23:10:26 +09:00
Yu Watanabe
cc46d3be68
Merge pull request #22502 from yuwata/udev-net-virtual-wlan-interface
network: add virtual wlan interface support
2022-02-16 23:03:52 +09:00
Yu Watanabe
e43a418f86
Merge pull request #22271 from keszybz/manager-reexec-freeze
Freeze manager if reexec fails
2022-02-16 23:02:21 +09:00
Zbigniew Jędrzejewski-Szmek
6b1fa53997 manager: add few ", ignoring" and adjust level in one message 2022-02-16 08:07:20 +01:00
Yu Watanabe
1147ce3a46
Merge pull request #22523 from DaanDeMeyer/systemd-networkd-tests-fixes
mkosi: Support running systemd-networkd-tests.py in QEMU
2022-02-16 16:04:14 +09:00
Evgeny Vereshchagin
bf6ef6b6a9 tests: allow running all the services with SYSTEMD_LOG_LEVEL
It should make it easier to figure out what exactly services do there.
For example, with SYSTEMD_LOG_LEVEL=debug userdbd (v249) prints
```
varlink-5: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{}}
```
before it crashes and systemd-resolved prints
```
varlink-21: New incoming message: {"method":"io.systemd.Resolve.ResolveAddress","parameters":{"address":[127,0,0,1],"flags":0,"ifindex":1000000,"family":0}}
```
and those messages are helpful (especially when scripts causing them
aren't clever enough to keep track of random stuff they send to systemd
:-))
2022-02-16 07:50:51 +03:00
Daan De Meyer
1e86c83308 test: Prefix all network/netdev config files used by systemd-networkd-tests.py
Let's make sure these take preference over any generic network config files shipped
by the OS (in this case specifically, mkosi).
2022-02-15 22:53:43 +00:00
Daan De Meyer
e2bf0a72ea test: Skip test_macsec() until kernel panic is fixed 2022-02-15 22:53:40 +00:00
Daan De Meyer
0f1853e230 mkosi: Support running systemd-networkd-tests.py in QEMU
This commit adds the necessary packages for Fedora and Arch.
2022-02-15 22:11:39 +00:00
Daan De Meyer
0765763e51 test: Stop using TextTestRunner in systemd-networkd-tests.py
If we assign our own test runner, passing arguments stops working
as unittest won't instantiate its own test runner after it parses
the arguments from sys.argv.

Consequence is that the tests will write to stderr now instead of
stdout since it doesn't seem possible to configure the stream that
unittest.main() will instantiate its test runner with so it'll
default to sys.stderr.
2022-02-15 23:32:06 +09:00
Yu Watanabe
dedf2d0054 network: add support to create wlan virtual interface
Closes #18977.
2022-02-15 23:24:55 +09:00
Lennart Poettering
ec00453b1c
Merge pull request #22412 from yuwata/sd-dhcp6-client-cleanups
sd-dhcp6-client: several fixes and cleanups
2022-02-15 14:18:55 +01:00
Frantisek Sumsal
b6fc52408a test: set ReadWritePaths=$BUILD_DIR when running w/ coverage
otherwise units using `DynamicUser=yes` won't be able to write the
coverage stats (currently affecting TEST-20-MAINPIDGAMES).

`DynamicUser=yes` implies `ProtectSystem=strict` and
`ProtectHome=read-only` and can't be overridden hence we need to
utilize `ReadWritePaths=` to work around that.
2022-02-14 21:59:33 +00:00
Frantisek Sumsal
d282e57e2a test: check for (possibly) missing test coverage
If the test logs contain lines like:

```
...systemd-resolved[735885]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-250.a.p/base-filesystem.c.gcda:Cannot open
```

it means we're possibly missing some coverage since gcov can't write the stats,
usually due to the sandbox being too restrictive (e.g. ProtectSystem=yes,
ProtectHome=yes) or the $BUILD_DIR being inaccessible to non-root users.
2022-02-14 12:20:02 +01:00
Frantisek Sumsal
e4c822e9ac test: set ACLs for the build dir when built with coverage
Otherwise unprivileged processes (like systemd-resolved) can't write
coverage data.
2022-02-14 11:58:54 +01:00
Yu Watanabe
7b53d3ead3 fuzz-dhcp6-client: merge with fuzz-dhcp6-client-send 2022-02-14 15:02:33 +09:00
Frantisek Sumsal
4ba5594390 test: document how to manually run Ubuntu CI stuff
Every time I need it I have to first relearn autopkgtest and find where
all the necessary stuff lives, so let's document it somewhere close to
systemd for (at least) future me.
2022-02-10 13:53:10 +00:00
Frantisek Sumsal
b034f02c62 test: accept GC'ed units in newer LVM
Since lvm 2.03.15 the transient units are started without `-r`, thus
disappearing once they finish and breaking the test (which expects them
to remain loaded after finishing). Let's accept `LoadState=not-found` as
a valid result as well to fix this.

Follow-up to: d10d562bd4
See: https://sourceware.org/git/?p=lvm2.git;a=commit;h=fbd8b0cf43dc67f51f86f060dce748f446985855
2022-02-10 13:26:11 +00:00
Yu Watanabe
2d88df457a
Merge pull request #22471 from yuwata/network-bridge-vlan-protocol
network: bridge: fix vlan protocol
2022-02-10 20:40:04 +09:00
Yu Watanabe
ac7e18be76
Merge pull request #22452 from yuwata/network-ipv6ll
network: use sysctl to set IPv6LL address generation mode when the interface is already up
2022-02-10 20:38:56 +09:00
Yu Watanabe
b6d5dab7bb test-network: add missing tests for bridge properties 2022-02-10 18:04:34 +09:00
Yu Watanabe
2becdbccd1 test-network: add testcase for re-generating IPv6LL address 2022-02-10 17:35:48 +09:00
Alvin Šipraga
19ff06b3a4
udev/net: support Match.Firmware= in .link files (#22462)
In cbcdcaaa0e ("Add support for conditions on the machines firmware")
a new Firmware= directive was added for .netdev and .network files.
While it was also documented to work on .link files, in actual fact the
support was missing. Add that one extra line to make it work, and also
update the fuzzer directives.
2022-02-10 16:19:28 +09:00
Frantisek Sumsal
d10d562bd4 test: lvm 2.03.15 dropped the static autoactivation
so install the respective generator only if we're running with older
lvm versions.

See: https://sourceware.org/git/?p=lvm2.git;a=commit;h=ee8fb0310c53ed003a43b324c99cdfd891dd1a7c
2022-02-09 22:36:25 +01:00
Santa Wiryaman
97f27f8a16 Add support for isolated parameter
Add the "Isolated" parameter in the *.network file, e.g.,

[Bridge]
Isolated=true|false

When the Isolated parameter is true, traffic coming out of this port
will only be forward to other ports whose Isolated parameter is false.

When Isolated is not specified, the port uses the kernel default
setting (false).

The "Isolated" parameter was introduced in Linux 4.19.
See man bridge(8) for more details.
But even though the kernel and bridge/iproute2 recognize the "Isolated"
parameter, systemd-networkd did not have a way to set it.
2022-02-09 17:37:37 +09:00
Yu Watanabe
18f84f8aba udev/net: support to set MDI-X mode
Closes #22386.
2022-02-08 15:47:46 +00:00
Lennart Poettering
2cd341afb9 tests: add repart tests for block devices with 1024, 2048, 4096 byte sector sizes
let's make sure repart works with 4K drives and exotic sector sizes.
2022-02-08 10:52:05 +01:00
Luca Boccassi
75844b44ee
Merge pull request #22408 from mrc0mmand/test-network-cleanup
test-network: code cleanup
2022-02-03 22:50:38 +00:00
Anita Zhang
d83923bdb7
Merge pull request #22355 from yuwata/network-tunnel-external
network: tunnel: support external mode
2022-02-03 14:20:43 -08:00
Frantisek Sumsal
87bf983c55 test-network: disable irrelevant or one-time pylint checks 2022-02-03 19:31:15 +01:00
Frantisek Sumsal
54e2f32f50 test-network: use specific exceptions instead of the Exception class 2022-02-03 19:30:11 +01:00
Frantisek Sumsal
a561bceeaa test-network: avoid name clashing/redefinition 2022-02-03 19:20:42 +01:00
Frantisek Sumsal
524cc9d1d8 test-network: disable 'no-member' warning for the Utilities class
The warning is correct, since we don't inherit the necessary
unittest.TestCase class, but that's on purpose, since the Utilities
class is not supposed to be instantiated on its own, but should
complement other classes' definitions which do inherit from the
unittest.TestCase class.
2022-02-03 19:13:06 +01:00
Frantisek Sumsal
283863a116 test-network: use raw strings for regexes with backslashes
It currently works because `\(` and `\)` are not valid escape sequences,
so they're not treated differently. Using raw strings (or double
backslashes) is a more correct solution.
2022-02-03 18:55:12 +01:00
Frantisek Sumsal
535e8107ee test-network: explicitly set check=False for subprocess.run()
since we're checking the returned error code explicitly via the
`returncode` member.
2022-02-03 18:49:35 +01:00
Frantisek Sumsal
f7805a6c79 test-network: convert certain multiline strings to comments
Multiline comments are converted to docstrings only when they're the
first statement in a function/method. Even though they're still a no-op
otherwise, let's use "true" comments to make pylint happy.
2022-02-03 18:42:41 +01:00
Frantisek Sumsal
45dbd0b945 test-network: drop unused variables 2022-02-03 18:18:29 +01:00
Frantisek Sumsal
19aa7f99c7 test-network: drop unnecessary else statements 2022-02-03 18:18:29 +01:00
Frantisek Sumsal
6983bb0e5e test-network: drop unnecessary semicolons 2022-02-03 18:18:27 +01:00
Frantisek Sumsal
83bceef027 test-network: drop superfluous parens 2022-02-03 18:10:06 +01:00
Evgeny Vereshchagin
be496d6a9b tests: pass FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to fuzzers
to let them use reproducible identifiers, which should make it possible
to really use files copied from OSS-Fuzz to reproduce issues on
GHActions and locally. Prompted by https://github.com/systemd/systemd/pull/22365
2022-02-03 08:56:00 +00:00
Evgeny Vereshchagin
697bb76589 tests: fuzz client_send_message
to make sure outgoing packets based on incoming packets are fine.
It's just another follow-up to
https://github.com/systemd/systemd/pull/10200.
Better late than never :-)
2022-02-03 13:43:49 +09:00
Yu Watanabe
7809cab717 test-network: add testcase for external tunnel 2022-02-03 11:12:34 +09:00
Yu Watanabe
1ae308abb5 network: tunnel: support external mode
Closes #22352.
2022-02-03 11:12:01 +09:00
Yu Watanabe
64a6b5ed21
Merge pull request #22351 from mrc0mmand/TEST-56-cgroupsv1
test: require unified cgroup hierarchy for TEST-56
2022-02-02 10:02:26 +09:00
Yu Watanabe
6a8ab6dd1e
Merge pull request #22332 from yuwata/network-dhcp-server-dns-server-address
network: dhcp-server: allow to specify server address for DNS= or friends
2022-02-02 07:07:22 +09:00
Frantisek Sumsal
e262082018 test: require unified cgroup hierarchy for TEST-56
since cgroup empty notifications are unreliable in legacy cgroups.

See: systemd/systemd#22320
Complements: systemd/systemd#22344
2022-02-01 22:13:48 +01:00
Frantisek Sumsal
f723740871 test: introduce `get_cgroup_hierarchy() helper
which returns the host's cgroup hierarchy (unified, hybrid, or legacy).
2022-02-01 22:13:45 +01:00
Yu Watanabe
c5f7a08739 test-network: add tests for DNS=_server_address in [DHCPServer] 2022-02-02 05:01:59 +09:00
Luca Boccassi
98fd285c28
Merge pull request #22331 from yuwata/network-xfrm-interface-id
network: xfrm: refuse zero interface ID
2022-02-01 13:25:38 +00:00
Yu Watanabe
020483b248 test-network: set xfrm interface ID
This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.
2022-02-01 13:26:43 +09:00
Yu Watanabe
a0e99a377a network: remove only managed configs on reconfigure or carrier lost
Otherwise, if the carrir of the non-managed interface is lost, the
configs such as addresses or routes on the interface will be removed by
networkd.
2022-02-01 11:30:37 +09:00
Frantisek Sumsal
caeaca1b8f
Merge pull request #22323 from mrc0mmand/fix-TEST-69-on-C8S
test: use ~/.bashrc instead of /etc/bash.bashrc
2022-01-31 19:04:02 +00:00
Frantisek Sumsal
6f73ef8b30 test: copy portable profiles into the image if they don't exist there
If we're built with `-Dportable=false`, the portable profiles won't get
installed into the image. Since we need only the profile files and
nothing else, let's copy them into the image explicitly in such case.
2022-01-31 17:09:30 +00:00
Frantisek Sumsal
1f450a680f test: use ~/.bashrc instead of /etc/bash.bashrc
/etc/bash.bashrc appears to be Debian-specific[0] (or specific to bash
versions compiled with -DSYS_BASHRC), which doesn't seem to be the case
for C8S. Let's use ~/.bashrc instead to make the CIs happy again.

[0] https://sources.debian.org/src/bash/5.1-6/debian/README/#L50-L56
2022-01-31 17:47:01 +01:00
Frantisek Sumsal
db357e9a89 test: make the code less error-prone 2022-01-31 16:49:09 +01:00
Yu Watanabe
256ce2e889
Merge pull request #21838 from lnussel/logind-refactor
Logind shutdown refactor
2022-01-31 19:45:33 +09:00
Evgeny Vereshchagin
998ec39b1d tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains 2022-01-29 03:19:53 +00:00
Evgeny Vereshchagin
4158af3651 tests: fuzz client_handle_offer
Turns out that part of systemd isn't covered by any fuzz targets and
that's not ideal considering that it parses data sent remotely. The
fuzzer triggers an infinite loop in lease_parse_routes as soon as it
starts so it seems to be working :-)
```
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 23620602
INFO: Loaded 2 modules   (182073 inline 8-bit counters): 176548 [0x7fdf511fc8d0, 0x7fdf51227a74), 5525 [0x5f6ef0, 0x5f8485),
INFO: Loaded 2 PC tables (182073 PCs): 176548 [0x7fdf51227a78,0x7fdf514d94b8), 5525 [0x5f8488,0x60ddd8),
./build/fuzz-dhcp-client: Running 1 inputs 1 time(s) each.
Running: test/fuzz/fuzz-dhcp-client/timeout-ed34161922c7075c4773f2ada3dee8685d220980
ALARM: working on the last Unit for 31 seconds
       and the timeout value is 30 (use -timeout=N to change)
==80731== ERROR: libFuzzer: timeout after 31 seconds
    #0 0x51b32e in __sanitizer_print_stack_trace (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51b32e)
    #1 0x4689e9 in fuzzer::PrintStackTrace() (/home/vagrant/systemd/build/fuzz-dhcp-client+0x4689e9)
    #2 0x44a0f4 in fuzzer::Fuzzer::StaticAlarmCallback() (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a0f4)
    #3 0x7fdf4f8b474f  (/lib64/libc.so.6+0x4274f)
    #4 0x465fee in __sanitizer_cov_trace_const_cmp4 (/home/vagrant/systemd/build/fuzz-dhcp-client+0x465fee)
    #5 0x57eee5 in lease_parse_routes /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:495:23
    #6 0x57baf3 in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:701:21
    #7 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #8 0x571cea in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:381:21
    #9 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #10 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:78:9
    #11 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #12 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #13 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #14 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #15 0x7fdf4f89f55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
    #16 0x7fdf4f89f60b in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2d60b)
    #17 0x421fd4 in _start (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421fd4)

SUMMARY: libFuzzer: timeout
```
2022-01-29 00:59:56 +00:00
Frantisek Sumsal
6c66575f0b
Merge pull request #22282 from yuwata/test-revert-workaronds
test: revert workaronds
2022-01-28 12:37:12 +00:00
Yu Watanabe
71df50a973 sd-dhcp-server: refuse too large packet to send
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44134.
2022-01-28 10:22:53 +00:00
Yu Watanabe
a1a42fd8a8
Merge pull request #22277 from yuwata/test-network-activation-policy
test-network: fixes for test_activation_policy
2022-01-28 12:45:49 +09:00
Yu Watanabe
673a181702
Merge pull request #22272 from bluca/state_dir_private_rootfs
core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used
2022-01-28 12:04:41 +09:00
Yu Watanabe
5ea91cf8f3 Revert "test: wait for user inactive"
As it does not work, and the test still randomly fails.

This reverts commit de27f4c8b8.
2022-01-28 10:44:12 +09:00
Yu Watanabe
477ebd2b30 Revert "test: wait for newly created btrfs triggered"
This reverts commit 39f83dd760.

As this does not solve the issue.
2022-01-28 10:42:51 +09:00
Luca Boccassi
dd802109c6
Merge pull request #22276 from mrc0mmand/TEST-64-workaround
test: temporary workaround for #21819
2022-01-28 00:56:04 +00:00
Luca Boccassi
3fa80e5e75 core: do not attempt to add 'private' symlinks when RootImage/RootDirectory are used
A bind mount is added directly from private on the host to the actual
destination directory, no need for the symlinks (which cannot be created
as the bind mount happens first and creates the target as an actual directory)

Fixes https://github.com/systemd/systemd/issues/22264
2022-01-28 00:54:10 +00:00
Yu Watanabe
073ad7ed1f test-network: wait for a while if manual policy is always-{up,down}
If wait_operstate() is called super quickly after ip command, then the
up/down state may not be changed and propagated to networkd, and
wait_operstate() mistakenly pass with the previous state.

To avoid such situation, wait for a while to make networkd actually
detect the interface brought up/down.
2022-01-28 07:29:37 +09:00
Yu Watanabe
ebb5036ff2 test-network: dummy interface is initially down when activation policy is manual 2022-01-28 07:17:08 +09:00
Yu Watanabe
cfbdc4387f test-network: wait for the link is activated
This fixes the following race:
1. when a dummy interface is created, it is initially down state,
2. hence, wait_operstate() may pass before the link is activated,
3. and the ip command bring up the interface before the activation,
4. and networkd activates, that is, brings down the interface,
5. thus, next wait_operstate() timedout, as it waits for the interface up.

To fix the race, let's wait the link is activated, before enter the loop
of wait_operstate().

Fixes #22267.
2022-01-28 07:02:03 +09:00
Yu Watanabe
b67f3d73b0 test-network: always cleanup the testing environment
Previously, if a subtest fail, then the cleanup process does not run,
and affects the subsequent tests.
2022-01-28 06:59:52 +09:00
Frantisek Sumsal
95e35511bb test: temporary workaround for #21819
Since the TEST-64-UDEV-STORAGE fails are quite frequent now and the root
cause is yet to be discovered, let's add a kludge that attempts to retry
the test up to two more times in case it fails, so we don't
unnecessarily disturb CIs while the issue is being investigated.

Revert this commit once #21819 is sorted out.
2022-01-27 22:51:15 +01:00
Frantisek Sumsal
888d0bc074 test: don't leak local variable to outer scopes 2022-01-27 22:50:58 +01:00
Yu Watanabe
e6d31fc97a tree-wide: fix typo 2022-01-28 04:47:39 +09:00
Yu Watanabe
33db66aa36
Merge pull request #22132 from joanbm/main
resolved: Fix DoT timeout on multiple answer records (for CloudFlare, Google, etc. DoT servers)
2022-01-28 04:23:34 +09:00
Luca Boccassi
392d46d7a8 test: use mksquashfs -noappend
Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image
2022-01-27 14:21:29 +00:00
Luca Boccassi
d76f0de746 test: rename service used in TEST-29-PORTABLE to avoid conflict
There's an app0.service in the extension app0.raw, so don't use the same
name for a unit in minimal.raw
2022-01-27 14:21:29 +00:00
Yu Watanabe
a21440f6d6
Merge pull request #22259 from bluca/exec_cond_restart
core: do not restart a service with Restart=always when ExecCondition fails
2022-01-27 15:09:47 +09:00
Joan Bruguera
726bcd81b9 resolved: Test for DnsStream (plain TCP DNS and DoT)
Tests DnsStream event handling, both for plain TCP DNS and DNS over TLS.

The DoT test requires the "openssl s_server" command line tool to mock a simple
TLS server. Thus the test's TLS part is skipped if openssl it not available.
The test works for both DNS_OVER_TLS_USE_GNUTLS and DNS_OVER_TLS_USE_OPENSSL.

The DoT case fails due to a bug, which is fixed on the next commit.
2022-01-27 14:33:56 +09:00
Evgeny Vereshchagin
b28d06e059 tests: fuzz dhcp_server_relay_message
It's a follow-up to https://github.com/systemd/systemd/pull/19384 where
dhcp_server_relay_message was introduced.

This PR was prompted by https://github.com/systemd/systemd/pull/22236#issuecomment-1020113269
for the most part.
2022-01-27 13:49:36 +09:00
Luca Boccassi
abb99360d3 core: do not restart a service with Restart=always when ExecCondition fails
When a Condition*= fails, and a service has Restart=always,
the service is not restarted.
Follow the same behaviour for ExecCondition= to avoid inconsistencies.

Fixes #22257
2022-01-26 19:02:11 +00:00
Jan Janssen
b2ba8511e6 meson: Remove test-efi-create-disk.sh
The script was probably not used for a very long time. It is currently
passed systemd_boot.so as boot loader, which cannot work. The test
entries it creates are all pointing at non-existant efi/linux binaries,
which means they would not even show up in the menu if the created image
were actually booted. There is also nothing that actually tries to run
the image in the first place.

If we end up creating a proper systemd-boot test suite, it would be
better to start from scratch. In the meantime, mkosi already covers
the bare minimum with a simple bootup test.
2022-01-26 14:40:51 +01:00
Luca Boccassi
e3f7ed944a portable: add flag to return extension-releases in GetImageMetadataWithExtensions
Return the name of each extension and the associated extension-release
file, and pretty-print them in 'portablectl inspect', if a new flag
is passed.

$ portablectl inspect --extension app2 --extension app0  minimal app0 app1
(Matching unit files with prefixes 'app0', 'app1'.)
Image:
        /run/portables/minimal.raw
Portable Service:
        n/a
Operating System:
        Debian GNU/Linux 10 (buster)
Extension:
        /run/portables/app2.raw
        Extension Scope:
                n/a
        Extension Compatibility Level:
                n/a
        Portable Service:
                n/a
        Portable Prefixes:
                n/a
        Operating System:
                n/a (debian 10)
Extension:
        /run/portables/app0.raw
        Extension Scope:
                n/a
        Extension Compatibility Level:
                n/a
        Portable Service:
                n/a
        Portable Prefixes:
                n/a
        Operating System:
                n/a (debian 10)
Unit files:
        app0.service
2022-01-25 22:22:47 +00:00
Ludwig Nussel
48f3bc5cc4 test: add shutdown test
Wraps nspawn to be able to use pexpect. The test logs in on the console
and runs screen. In one screen window it types in shutdown commands and
checks whether a wall message was sent to the other.
2022-01-25 17:43:13 +01:00
Luca Boccassi
0017415cc5 portable: add GetImageStateWithExtensions method
Allow to correctly query a layered portable service for
attached/detached state.
2022-01-25 06:44:27 +09:00
Yu Watanabe
0590f1b58c fuzz-dhcp-server: duplicate input data
As `dhcp_server_handle_message()` -> `ensure_sane_request()` may modify
the input data, and that causes error in some fuzzing engine.
2022-01-24 19:37:37 +09:00
Yu Watanabe
a596631808 fuzz: add testcases of heap-buffer-overflow for sd-dhcp-server 2022-01-24 04:52:33 +09:00
Luca Boccassi
2ef2024462 portable: add support for ExtensionDirectories in --extension
Same as for the root os image, support passing a directory, using
the new ExtensionDirectories setting.
2022-01-24 00:21:15 +09:00
Daan De Meyer
e93ada9821 meson: Add missing test dependencies
Currently, running "meson build" followed by "meson test -C build"
will result in many failed tests due to missing dependencies. This
commit adds the missing dependencies to make sure no tests fail.
2022-01-22 01:56:03 +09:00
Luca Boccassi
a07b992606 core: add ExtensionDirectories= setting
Add a new setting that follows the same principle and implementation
as ExtensionImages, but using directories as sources.
It will be used to implement support for extending portable images
with directories, since portable services can already use a directory
as root.
2022-01-21 22:53:12 +09:00
Luca Boccassi
de843f8582
Merge pull request #21865 from yuwata/network-sr-iov
udev/net: support configuring SR-IOV virtual functions through .link file
2022-01-19 22:38:00 +00:00
Yu Watanabe
5ab9addd68 test: replace multiple echo with cat
Suggested by shell check SC2129.
2022-01-19 20:48:36 +09:00
Yu Watanabe
39f83dd760 test: wait for newly created btrfs triggered
Fixes the second issue in #21819.
2022-01-19 09:32:23 +00:00
Yu Watanabe
1e8e9730d2 test-network: add testcases for configuring SR-IOV by .link file 2022-01-19 15:00:53 +09:00
Yu Watanabe
a03ff4c0fe test-network: split out SR-IOV test to new class 2022-01-19 15:00:53 +09:00
Yu Watanabe
0eed039c92 test-network: silence check for alternative names 2022-01-19 15:00:53 +09:00
Yu Watanabe
41ce9d769d udev/net: allow to set number of SR-IOV virtual functions
This adds SR-IOVVirtualFunctions= setting in [Link] section.
2022-01-19 15:00:53 +09:00
Yu Watanabe
bd29dfef8b udev/net: also support [SR-IOV] section in .link files
The same section is already supported by .network files. But such
low-level inteerface setting should be done by udevd, instead of
networkd. Let's also support the same semantics by .link files.

Prompted by https://github.com/systemd/systemd/issues/20474#issuecomment-901901360.
2022-01-19 15:00:49 +09:00
Yu Watanabe
902bbdc4b6 network: use scope link for direct unicast routes by default
Strictly speaking, this breaks the backward compatibility, but I guess
in most cases people already sets Scope=link for such routes.

This behavior matches with how 'ip route' command adds such route by
default.

Prompted by https://twitter.com/jplitza/status/1480500562391179270.
2022-01-13 22:46:52 +00:00
Luca Boccassi
8e65d93e85 test: do not assume x86-64 arch in TEST-58-REPART 2022-01-12 23:27:05 +00:00
Luca Boccassi
a94b9977d5 test: add partition IDs for s390x and ppc64el to TEST-50-DISSECT 2022-01-12 22:59:20 +00:00
Luca Boccassi
ac172d7063
Merge pull request #22090 from mbiebl/units-oomd-alias
units: don't install dbus-org.freedesktop.oom1.service alias
2022-01-12 15:03:00 +00:00