1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-25 23:21:33 +03:00
Commit Graph

2864 Commits

Author SHA1 Message Date
Yu Watanabe
f7ad162879 test-network: rename one .netdev to make the file removed after the test
Follow-up for 7809cab717.
2022-04-06 18:14:45 +09:00
Yu Watanabe
14f9c81fb4 test: use udevadm wait and lock
Hopefully fixes #22911.
2022-04-05 05:00:39 +09:00
Frantisek Sumsal
c189d3bd78 test: use the new udevadm wait verb to wait for the loop device
The original workaround didn't work, as `systemd-repart` kept failing
 even when the `/dev/loopX` device was present:

 ```
 [   13.959419] H testsuite-58.sh[280]: + LOOP=/dev/loop1
 [   13.959636] H testsuite-58.sh[280]: + :
 [   13.959764] H testsuite-58.sh[280]: + test -e /dev/loop1
 [   13.959895] H testsuite-58.sh[280]: + break
 [   13.960023] H testsuite-58.sh[280]: + systemd-repart --pretty=yes --definitions=/tmp/testsuite-58-sector/ --seed=750b6cd5c4ae4012a15e7be3c29e6a47 --empty=require --dry-run=no /dev/loop1
 [   13.970538] H testsuite-58.sh[363]: Device '/dev/loop1' has no dm-crypt/dm-verity device, no need to look for underlying block device.
 [   13.970538] H testsuite-58.sh[363]: Failed to determine canonical path for '/dev/loop1': No such file or directory
 [   13.970538] H testsuite-58.sh[363]: Failed to open file or determine backing device of /dev/loop1: No such file or directory
 ```
2022-04-04 15:58:03 +02:00
Yu Watanabe
37ebfe49de
Merge pull request #22926 from bluca/analyze_offline_filter
analyze: fix offline checks for syscall filter and 'native' architecture
2022-04-01 23:43:18 +09:00
Luca Boccassi
1449b0f8a9 analyze: fix offline check for 'native' syscall architecture
Enum values are stored in the set, not strings
2022-04-01 10:42:48 +01:00
Yu Watanabe
e529abe24d test: replace helper_wait_for_dev() with 'udevadm wait' 2022-04-01 15:13:18 +09:00
Zbigniew Jędrzejewski-Szmek
c3a053c241 test-systemctl-enable: skip test for %v if kver is not a valid instance
On arm, we'd fail with:
target@v:5.16.8-200.fc35.armv7hl+lpae.socket: not a valid unit name "target@v:5.16.8-200.fc35.armv7hl+lpae.socket": Invalid argument
2022-03-29 22:39:32 +02:00
Zbigniew Jędrzejewski-Szmek
53877d0385
Merge pull request #22649 from keszybz/symlink-enablement-yet-again-punish-me-harder
Fixups to the unit enablement logic
2022-03-29 21:10:03 +02:00
Yu Watanabe
10176f0011 test: add tests for worker error code 2022-03-30 01:27:29 +09:00
Zbigniew Jędrzejewski-Szmek
5c29de29b4 test-systemctl-enable: disable the test for %a for now 2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
2a2d002fb0 test-systemctl-enable: also use freshly-built systemd-id128
Tests were failing on centos7 because systemd-id128 is not in path.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
d6c51c485a test-systemctl-enable: use magic syntax to allow inverted tests
Inspired by 7910ec3bcd.
'! true' passes, because it's a conditional expression.
But '( ! true )' fails, because '( … )' creates a subshell, i.e. a separate
program, and '! true' becomes the return value of that program, and the whole
thing apparently is not a conditional expression for the outer shell.

This is shorter, so let's just do this.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
3fc53351dc shared/install: when creating symlinks, accept different but equivalent symlinks
We would only accept "identical" links, but having e.g. a symlink
/usr/lib/systemd/system/foo-alias.service → /usr/lib/systemd/system/foo.service
when we're trying to create /usr/lib/systemd/system/foo-alias.service →
./foo.service is OK. This fixes an issue found in ubuntuautopkg package
installation, where we'd fail when enabling systemd-resolved.service, because
the existing alias was absolute, and (with the recent patches) we were trying
to create a relative one.

A test is added.
(For .wants/.requires symlinks we were already doing OK. A test is also
added, to verify.)
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
84fdced62c test-systemctl-enable: make shellcheck happy
Quoting is not necessary in many places, but I think it's nicer
to use it consistently.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
48eadb9d9b shared/install: fix handling of a linked unit file
When we have a symlink that goes outside of our search path, we should just
ignore the target file name. But we were verifying it, and rejecting in
the case where a symlink was created manually.
2022-03-29 16:17:57 +02:00
Zbigniew Jędrzejewski-Szmek
d6c9411072 shared/install: create relative symlinks for enablement and aliasing
This is a fairly noticable change, but I think it needs to be done.
So far we'd create an absolute symlink to the target unit file:
  .wants/foo.service → /usr/lib/systemd/system/foo.service
or
  alias.service → /etc/systemd/system/aliased.service.

This works reasonably well, except in one case: where the unit file
is linked. When we look at a file link, the name of the physical file
isn't used, and we only take the account the symlink source name.
(In fact, the destination filename may not even be a well-formed unit name,
so we couldn't use it, even if we wanted to.) But this means that if
a file is linked, and specifies aliases, we'd create absolute links for
those aliases, and systemd would consider each "alias" to be a separate
unit. This isn't checked by the tests here, because we don't have a running
systemd instance, but it is easy enough to check manually.

The most reasonable way to fix this is to create relative links to the
unit file:
  .wants/foo.service → ../foo.service
  alias.service → aliased.service.

I opted to use no prefix for aliases, both normal and 'default.target',
and to add "../" for .wants/ and .requires/. Note that the link that is
created doesn't necessarily point to the file. E.g. if we're enabling
a file under /usr/lib/systemd/system, and create a symlink in /etc/systemd/system,
it'll still be "../foo.service", not "../../usr/lib/systemd/system/foo.service".
For our unit loading logic this doesn't matter, and figuring out a path
that actually leads somewhere would be more work. Since the user is allowed
to move the unit file, or add a new unit file in a different location, and
we don't actually follow the symlink, I think it's OK to create a dangling
symlink. The prefix of "../" is useful to give a hint that the link points
to files that are conceptually "one level up" in the directory hierarchy.

With the relative symlinks, systemd knows that those are aliases.

The tests are adjusted to use the new forms. There were a few tests that
weren't really testing something useful: 'test -e x' fails if 'x' is a
a dangling symlink. Absolute links in the chroot would be dangling, even
though the target existed in the expected path, but become non-dangling
when made relative and the test fails.

This should be described in NEWS, but I'm not adding that here, because
it'd likely result in conflicts.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
9f61c9f79e shared/install: also remove symlinks like .wants/foo@one.service → ../foo@one.service
So far 'systemctl enable' would create absolute links to the target template
name. And we would remove such symlinks just fine. But the user may create
symlinks manually in a different form. In particular, symlinks for instanced
units *must* have the instance in the source name, and then it is natural to
also include it in the target name (.wants/foo@one.service../foo@one.service
rather than .wants/foo@one.service → ../foo@.service). We would choke on such
links, or not remove them at all. A test is added:

before:

+ build-rawhide/systemctl --root=/tmp/systemctl-test.001xda disable templ1@.service
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@seven.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@six.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@five.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@four.service".
Removed "/tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@three.service".
Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service.
Failed to disable unit, refusing to operate on linked unit file /tmp/systemctl-test.001xda/etc/systemd/system/services.target.wants/templ1@two.service.

after:

+ build-rawhide/systemctl --root=/tmp/systemctl-test.QVP0ev disable templ1@.service
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service".
Removed "/tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service".
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@one.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@two.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@three.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@four.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@five.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@six.service
+ test '!' -h /tmp/systemctl-test.QVP0ev/etc/systemd/system/services.target.wants/templ1@seven.service
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
85516075a2 test-systemctl-enable: enhance the test for unit file linking
Current behaviour is wrong, but it cannot be shown in this test, because we
don't have a running systemd instance here.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
0c003e8305 test-systemctl-enable: extend the test for repeated WantedBy/RequiredBy
I was considering deduplicating the list of target units in
WantedBy/RequiredBy. But to do this meaningfully, we'd need to do alias
expansion first, i.e. after the initial parsing is done. This seems to be
more trouble than it would be worth.

Instead, I added tests that we're doing the right thing and creating symlinks
as expected. For duplicate links, we create the link, and on the second time we
see that the link is already there, so the output is correct.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
29a7c59abb shared/install: fix reenable on linked unit files 2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
20d68b3aec install: when linking a file, create the link first or abort
We'd create aliases and other symlinks first, and only then try to create
the main link. Since that can fail, let's do things in opposite order, and
abort immediately if we can't link the file itself.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
17a2679e99 man: fix invalid description of template handling in WantedBy=
We don't need to talk about Alias=. The approach of using Alias= to enable
units is still supported, but hasn't been advertised as the way to do thing
for many years. Using it as an explanation is just confusing.

Also, the description of templated units did not take DefaultInstance=
into account. It is updated and extended.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
f663e6468f shared/install: also check for self-aliases during installation and ignore them
We had a check that was done in unit_file_resolve_symlink(). Let's move
the check to unit_validate_alias_symlink_or_warn(), which makes it available
to the code in install.c.

With this, unit_file_resolve_symlink() behaves almost the same. The warning
about "suspicious symlink" is done a bit later. I think this should be OK.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
0d11db5982 shared/install: return failure when enablement fails, but process as much as possible
So far we'd issue a warning (before this series, just in the logs on the server
side, and before this commit, on stderr on the caller's side), but return
success. It seems that successfull return was introduced by mistake in
aa0f357fd8 (my fault :( ), which was supposed to
be a refactoring without a functional change. I think it's better to fail,
because if enablement fails, the user will most likely want to diagnose the
issue.

Note that we still do partial enablement, as far as that is possible. So if
e.g. we have [Install] Alias=foo.service foobar, we'll create the symlink
'foo.service', but not 'foobar', since that's not a valid unit name. We'll
print info about the action taken, and about 'foobar' being invalid, and return
failure.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
172e9cc3ee shared/specifier: fix %u/%U/%g/%G when called as unprivileged user
We would resolve those specifiers to the calling user/group. This is mostly OK
when done in the manager, because the manager generally operates as root
in system mode, and a non-root in user mode. It would still be wrong if
called with --test though. But in systemctl, this would be generally wrong,
since we can call 'systemctl --system' as a normal user, either for testing
or even for actual operation with '--root=…'.

When operating in --global mode, %u/%U/%g/%G should return an error.

The information whether we're operating in system mode, user mode, or global
mode is passed as the data pointer to specifier_group_name(), specifier_user_name(),
specifier_group_id(), specifier_user_id(). We can't use userdata, because
it's already used for other things.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
19b9d5d0d1 shared/install: provide proper error messages when invalid specifiers are used
$ build/systemctl --root=/tmp/systemctl-test.KXY8fu enable some-some-link6@.socket
Failed to enable unit, invalid specifier in "target@C:%C.socket".
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
6ec4c852c9 shared/specifier: provide proper error messages when specifiers fail to read files
ENOENT is easily confused with the file that we're working on not being
present, e.g. when the file contains %o or something else that requires
os-release to be present. Let's use -EUNATCH instead to reduce that chances of
confusion if the context of the error is lost.

And once we have pinpointed the reason, let's provide a proper error message:

+ build/systemctl --root=/tmp/systemctl-test.TO7Mcb enable some-some-link6@.socket
/tmp/systemctl-test.TO7Mcb/etc/systemd/system/some-some-link6@.socket: Failed to resolve alias "target@A:%A.socket": Protocol driver not attached
Failed to enable unit, cannot resolve specifiers in "target@A:%A.socket".
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
df78419d10 basic: add new variable $SYSTEMD_OS_RELEASE to override location of os-release
The test for the variable is added in test-systemctl-enable because there we
can do it almost for free, and the variable is most likely to be used with
'systemctl enable --root' anyway.
2022-03-29 16:17:56 +02:00
Zbigniew Jędrzejewski-Szmek
50c5f5a3d9 test: add test for systemctl link & enable
This test has overlap with test-install-root, but it tests things at a
different level, so I think it's useful to add. It immediately shows various
bugs which will be fixed in later patches.
2022-03-29 16:17:56 +02:00
Luca Boccassi
2350712e32 portable: allow reattaching when one image has a version and the other does not
A reattach might go from img.raw to img_0.1.raw or viceversa, but this is
not allowed right now as we try to match the full name.

Also take into account that running strcspn(a, '/') on an image name, without
leading path, will return the length of the full string, but the versions
might be different so they won't match, eg:

img_0.1.raw -> 12
img_0.1.1.raw -> 14

So adjust the check to take that into account, and skip it if we are not
dealing with directories
2022-03-29 14:02:48 +01:00
Yu Watanabe
ec4954d934 network: rename netdev kind virtual-wlan -> wlan
The Kind= setting in [Match] section of .network files takes "wlan".
This makes the same setting in .netdev files matches the one in .network
files.
2022-03-28 23:53:12 +09:00
Frantisek Sumsal
41d1aaea64 test: use flock when calling mkfs.btrfs
As stated in https://github.com/systemd/systemd/issues/21819#issuecomment-1064377645
`mkfs.btrfs` doesn't hold the lock for the whole duration of
`mkfs.btrfs`, thus causing unexpected races & test fails. Let's
wrap the `mkfs.btrfs` calls in an flock wrapper to mitigate this.

Hopefully fixes: #21819
2022-03-25 10:28:07 +09:00
Frantisek Sumsal
ed1cbdc347 Revert "test: temporary workaround for #21819"
This reverts commit 95e35511bb.
2022-03-25 10:28:07 +09:00
Zbigniew Jędrzejewski-Szmek
74fbb24f64 TEST-68: instead of calling daemon-reload, just use different cleanup units
On a very slow machine, things are executed out-of-order, and something
pins the previously-exited unit. Instead of fighting with this with daemon-reload,
let's just use a different cleanup unit.

Hopefully fixes #22755.
2022-03-24 14:11:54 +01:00
Zbigniew Jędrzejewski-Szmek
6741235430 TEST-68: get rid of unnecessary descriptions
The name of the unit already says all, no need to duplicate this.
And the comments can easily get out of date, as they did.
2022-03-24 13:45:38 +01:00
Frantisek Sumsal
1b87ca4fe9 test: use a dropin to override the end.service unit
instead of removing it.
2022-03-21 16:41:49 +01:00
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
Michael Biebl
d338b1713a test: enable systemd-oomd.service
Enable the service to ensure dbus-org.freedesktop.oom1.service exists
and D-Bus activation works.

See #18469
2022-01-12 12:29:34 +01:00
Jan Janssen
3a469802f4 meson: Use echo to list files
No need to invoke ls when we are just interested in file names.
Also, the cd to source root makes the output identical to
"git ls-files" (relative instead of absolute paths).
2022-01-11 14:56:33 +01:00
Jan Janssen
68a06b3cdf meson: Add check argument to remaining run_command() calls 2022-01-11 14:56:30 +01:00
Frantisek Sumsal
fd5e5a87fb test: explicitly configure oomd stuff via dropins
so we don't get overridden by distro-shipped ones.

Fixes: #22030
2022-01-09 17:56:57 +00:00
Luca Boccassi
e683878c0f test: store empty files rather than symlinks for test-fstab-generator
Dangling symlinks get pruned when packaging up the installation
directory. Just store empty files instead, and compare the names
rather than the content for .requires/.wants - the filename is
what is important anyway, the content is ignored.

Fixes #22059
2022-01-09 18:17:40 +01:00
Albert Brox
3989bdc1ad core: teach LoadCredential= to load from a directory 2022-01-08 13:17:51 +00:00
Yu Watanabe
8cc8a073a8 test: add test cases for fstab-generator 2022-01-07 00:58:50 +09:00
Yu Watanabe
b322e683ac meson: install test-network-generator-conversion.sh even if networkd is not enabled
Follow-up for 987dd89c77.
2022-01-06 20:14:39 +09:00
Frantisek Sumsal
1b51599f29 test: use full date & time when checking for coredumps
Otherwise we might hit a window where the coredump happens before
midnight, but we check for it after midnight, which yields no results.

E.g.:

```
$ coredumpctl --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
$ coredumpctl --since 23:59:55 --no-legend --no-pager --file system.journal
No coredumps found.
$ coredumpctl --since "2022-01-04 23:59:59" --no-legend --no-pager --file system.journal
Wed 2022-01-05 01:00:06 CET 359 0 0 SIGABRT journal /usr/bin/udevadm n/a
```
2022-01-06 01:18:12 +09:00
Frantisek Sumsal
7847b54814 test: build fuzzers with --werror if set
to catch issues like systemd/systemd#21996.
2022-01-04 18:49:56 +03:00
Yu Watanabe
14b451f20a test-network: add testcase for invalid AllowedIPs= 2021-12-31 02:31:12 +09:00
Ludwig Nussel
b13a8b5b37 test: mark partition bootable
Make test suite partition bootable so nspawn can use the image directly.
Useful for local testing.

https://systemd.io/DISCOVERABLE_PARTITIONS/
2021-12-29 19:23:26 +00:00
Yu Watanabe
cf6562e456 test: add testcases of symlinked drop-in directories 2021-12-29 01:29:21 +09:00
Luca Boccassi
4ac8526215
Merge pull request #21892 from yuwata/network-vxlan-automatic-local-address-selection
network: vxlan: automatic local address selection
2021-12-26 17:27:41 +00:00