1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00
Commit Graph

1650 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
b214427752 TEST-22: add --dry-run calls
aCdDefLprRwxXz are tested with --dry-run.
I added a primitive test of bc.
There were no tests for AhHt, and I didn't add those either.
2024-02-12 13:34:32 +01:00
Lennart Poettering
d02018afdb test: add brief test for prclock varlink interfaces and varlinkctl --collect 2024-02-12 12:04:18 +01:00
Lennart Poettering
24835e9933 varlinkctl: if "call" verb is used, imply "-j"
For the other verbs turning off JSON mode makes sense, but for "call"
not so much, after all the contents of a method call reply is JSON we
couldn't really show any other way.

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

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

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

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

Sanitized libsystemd-core.so is also quite big:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This can be tested with the kernel.apparmor_restrict_unprivileged_userns
sysctl.
2024-01-13 06:55:04 +09:00
Yu Watanabe
967cd1712c
Merge pull request #30867 from dtardon/udev-conf-dropins
Allow dropins for udev.conf
2024-01-12 06:37:23 +09:00
Lennart Poettering
28795e4dca
Merge pull request #30777 from poettering/ssh-generator
ssh-generator which makes VMs and containers accessible to ssh via AF_UNIX and AF_VSOCK
2024-01-11 21:31:28 +01:00
Lennart Poettering
25f8d3856a
Merge pull request #30884 from poettering/logind-background-light
logind: add "background-light" + "manager" session classes
2024-01-11 21:20:01 +01:00
David Tardon
dddf640cab test: use dropin dir 2024-01-12 05:12:44 +09:00
Lennart Poettering
a50666e376 id128: add --no-pager, --no-legend, --json=/-j switches to systemd-id128 tool 2024-01-11 17:54:19 +01:00
Lennart Poettering
3b52ef6f00 test: add integration test for new 'background-light' session class 2024-01-11 17:47:41 +01:00
Lennart Poettering
4cb4e6cf6d pam_systemd: register systemd user service manager as class='manager'
Now that we have thew new class, start making us of it in pam_systemd.so
when running for user@.service.
2024-01-11 17:23:47 +01:00
Lennart Poettering
52d863defc test: add testcase for ssh generator 2024-01-11 16:18:26 +01:00
Luca Boccassi
dadd7d46d9
Merge pull request #30809 from yuwata/resolve-fix-EDE-handling
resolve: fix EDE handling
2024-01-10 19:21:55 +00:00
Frantisek Sumsal
f1caa5d6e7 test: introduce a dummy DNS test server
Introduce a _very_ simple DNS server using our internal DNS-related
code, that responds to queries with specifically crafted packets, to
cover scenarios that are difficult to reproduce with well-behaving DNS
servers.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Resolves: #30477

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fix #4883
2023-12-06 22:22:27 +01:00
Lennart Poettering
fb8cc599ed analyze: add "architectures" verb that lists all known architectures 2023-12-06 22:18:14 +01:00
Luca Boccassi
f9a284f02d
Merge pull request #30214 from bluca/wants_mounts_for
Add WantsMountsFor= and use it in the cryptsetup generator
2023-12-06 21:00:37 +00:00
Daan De Meyer
1500fe38b2 test: Add test case for --make-ddi=sysext
Also make sure that the sysext is big enough to not fit in the
minimum partition size so we know Minimize= is being used.
2023-12-06 12:18:32 +01:00
Frantisek Sumsal
1ea27bd79e test: load the io controller before checking if io.latency exists
Otherwise the following test gets always skipped.
2023-12-05 19:58:48 +00:00
Zbigniew Jędrzejewski-Szmek
dd0630277b TEST-26: add test for systemctl edit --stdin 2023-12-05 18:47:19 +01:00
Mike Yuan
cd4dd90b99
logind: introduce Sleep() call and action that automatically choose a sleep operation 2023-12-05 22:18:32 +08:00
Frantisek Sumsal
52c1fb6885 test: set correct group for systemd-journal-upload tests
We can't use the systemd-journal-upload user here, since it's created
dynamically by DynamicUser=yes. However, we can use the group specified
in SupplementaryGroups=, so do exactly that.
2023-12-05 09:07:14 +01:00
Yu Watanabe
0cf392c4e7 test: add test for seqnum and seqnum ID 2023-12-04 15:14:25 +09:00
Mike Yuan
2b98926f98
networkctl: introduce --runtime for editing network config under /run/ 2023-12-02 17:04:57 +08:00
Yu Watanabe
a93be359ae sd-journal: fix corrupted journal handling of generic_array_bisect()
Let's consider the following case:
- the direction is down,
- no cached entry,
- the array has 5 entry objects,
- the function test_object() reutns TEST_LEFT for the 1st object,
- the 2nd, 3rd, and 4th objects are broken, so generic_array_bisect_step()
  returns TEST_RIGHT for the object.

Then, previously, generic_array_bisect_step() updated the values like the following:
  0th: (m = 5, left = 0, right = 4, i = 4) -> (m = 4, left = 0, right = 3, RIGHT)
  1st: (m = 4, left = 0, right = 3, i = 1) -> (m = 4, left = 2, right = 3, LEFT)
  2nd: (m = 4, left = 2, right = 3, i = 2) -> (m = 2, left = 2, right = 1, RIGHT) <- ouch!!
So, assert(left < right) in generic_array_bisect() was triggered.
See issue #30210.

In such situation, there is no matching entry in the array. By returning
TEST_GOTO_PREVIOUS, generic_array_bisect() handles the result so.

Fixes a bug introduced by ab8f553d1e.

Fixes #30210.
2023-12-01 09:56:10 +09:00
Frantisek Sumsal
ee77e0b2de test: ignore gcov errors with RestrictFileSystems=
The errors are valid, since the file system is indeed not writable, but
we don't care about the missing coverage data in this case.

Follow-up to 4a43c2b3a1.
2023-11-29 22:50:37 +00:00
Luca Boccassi
c9be8e420e cryptsetup: use WantsMountsFor= for key/header when nofail is set
The header and keyfile are necessary only for opening the device, not
for closing, so it is not necessary to deactivate the generated
cryptsetup unit when the header or keyfile backing store are removed.

This is especially useful in the case of softreboot, when the new
mount root is setup under /run/nextroot/ but we don't want to close
the cryptsetup devices for encrypted /var/ or so, and we simply
mount it directly on /run/nextroot/var/ before the soft-reboot.
2023-11-29 11:04:59 +00:00
Luca Boccassi
499d32655f
Merge pull request #30203 from yuwata/resolve-dump-cache
resolve: fix varlink message verification
2023-11-28 15:35:11 +00:00
Luca Boccassi
3dfbddf3ee
Merge pull request #30216 from poettering/loginctl-table-tweaks
loginctl: minor tweaks to tabular output
2023-11-28 15:33:35 +00:00
Lennart Poettering
8bfa22f079 loginctl: set appropriate ersatz strings for all tables 2023-11-28 11:33:01 +01:00
Yu Watanabe
5edb35ef7a test: check journal files are not corrupted after soft-reboot 2023-11-28 18:28:18 +09:00
Yu Watanabe
038e455462 test: verify json format passed through varlink
This drops logs of failed unit tests in TEST-02-UNITTESTS from the journal,
as the expected logs from test-varlink-idl makes the post script fail.
Saving logs in journal is simply noisy, and we will output anyway after
qemu or nspawn finished by check_result_{qemu,nspawn}_unittests().
2023-11-28 04:13:44 +09:00
Yu Watanabe
a97d617f18 test: drop remaining console output
Follow-up for fa6f37c043.

Partially reverts d5ab23aa54 and
3540ce8587.
2023-11-28 04:10:25 +09:00
Yu Watanabe
24baa46289 test: add simple coverity test for 'resolvectl show-cache' 2023-11-28 04:10:25 +09:00
Luca Boccassi
04fc5b6047
Merge pull request #30170 from bluca/exec_bpf_fd
core: pass bpf_outer_map_fd to sd-executor only if RestrictFileSystems was set
2023-11-27 15:44:50 +00:00
Frantisek Sumsal
7a2d6c2d08 test: drop 'noearly' from crypttab
It's a Debian thing, we don't support it.

[   30.639971] testsuite-64.sh[475]: + systemctl restart cryptsetup.target
[   30.697667] systemd-cryptsetup[3389]: Encountered unknown /etc/crypttab option 'noearly', ignoring.
[   30.700529] systemd-cryptsetup[3390]: Encountered unknown /etc/crypttab option 'noearly', ignoring.
[   30.700594] systemd-cryptsetup[3391]: Encountered unknown /etc/crypttab option 'noearly', ignoring.
[   30.704638] systemd-cryptsetup[3392]: Encountered unknown /etc/crypttab option 'noearly', ignoring
2023-11-25 22:30:01 +01:00
Frantisek Sumsal
d1ac1aa5ca test: drop invalid LogTarget= assignment
It's been there since the test was introduced and I'm not really sure
what was the original intention behind it, but it makes systemd sad:

[    4.909056] systemd[1]: /usr/lib/systemd/tests/testdata/units/testsuite-44.service:13: Unknown key name 'LogTarget' in section 'Service', ignoring.
2023-11-25 21:59:57 +01:00
Frantisek Sumsal
4a43c2b3a1 test: add a couple of tests for RestrictFileSystems= 2023-11-24 17:49:28 +01:00
Frantisek Sumsal
c5035a30e2 test: don't make the final vacuum multiple of 8M
As this would usually mean we'd nuke everything, since there are two
open journals - system and user - both being 8M in size.
2023-11-24 11:51:27 +01:00
Luca Boccassi
31897753fb
Merge pull request #30024 from keszybz/one-doc-thingy
Serialize units ratelimits and document StartLimitIntervalSec=infinity
2023-11-22 17:42:51 +00:00
Zbigniew Jędrzejewski-Szmek
6ef512c0bb core: serialize and deserialize unit start ratelimits
The logic is taken from dump ratelimit: if the config changes, we discard the
counters. This allows the user apply new limits and "start from scratch" in
that case.

This actually makes StartLimitIntervalSec=infinity (or with a large interval)
work as expected, because the counter is maintained even if daemon-reload
operations are interleaved.
2023-11-22 12:12:35 +00:00
Lennart Poettering
5e5d4d36b4 test: make sure pcrlock tests run headless
We want the tests to fail rather than hang if unlock via tpm doesn't
work.
2023-11-21 23:43:23 +00:00
Frantisek Sumsal
7ec22d7d4b bsod: install the signal handler only just before we need it
Otherwise we might get stuck in sd_journal_wait(), since it handles
EINTR internally.

Resolves: #30084
2023-11-21 16:58:33 +00:00
Luca Boccassi
42c1df5e2d test: add simple test case for invalid userspace log records 2023-11-20 14:27:38 +01:00
David Tardon
08d5c74a01 test: read from the right device 2023-11-16 10:16:11 +01:00
Luca Boccassi
e437b28054
Merge pull request #30023 from mrc0mmand/selinux
test: make TEST-06-SELINUX work with the refpolicy and beef it up a bit
2023-11-14 19:04:35 +00:00
Frantisek Sumsal
5ef964f88c test: make TEST-06-SELINUX work with the refpolicy and beef it up a bit
Currently the test works only with policy shipped by Fedora, which makes
it pretty much useless in most of our CIs. Let's drop the custom module
and make the test more generic, so it works with the refpolicy as well,
which should allow us to run it on Arch and probably even in Ubuntu CI.
2023-11-14 18:54:16 +01:00
Zbigniew Jędrzejewski-Szmek
b484c250cc
Merge pull request #29930 from yuwata/meson-default-network-fix-install-path
meson: fix install path of example .network files
2023-11-14 17:33:42 +01:00
Frantisek Sumsal
bbe865b2fe test: switch SELinux to permissive in the config file
The config file has (unfortunately) precedence over the kernel command
line, so let's tweak the config file if necessary.
2023-11-14 12:54:50 +01:00
Luca Boccassi
1029edea3c
Merge pull request #30018 from mrc0mmand/TEST-70
test: skip --tpm2-device-key= tests with older OpenSSL
2023-11-13 20:58:43 +00:00
Frantisek Sumsal
52a09e6230 test: skip --tpm2-device-key= tests with older OpenSSL
--tpm2-device-key= requires OpenSSL >= 3 with KDF-SS, so let's skip the
test if we're running with older OpenSSL.

+ systemd-cryptenroll --tpm2-device-key=/tmp/srk.pub --tpm2-pcrs=12:sha256=F5A5FD42D16A20302798EF6ED309979B43003D2320D9F0E8EA9831A92759FB4B /tmp/systemd-cryptsetup-H8y.IMAGE
Failed to find TPM2 pcrlock policy file 'pcrlock.json': No such file or directory
Allocating context for crypt device /tmp/systemd-cryptsetup-H8y.IMAGE.
Trying to open and read device /tmp/systemd-cryptsetup-H8y.IMAGE with direct-io.
Trying to open device /tmp/systemd-cryptsetup-H8y.IMAGE without direct-io.
Initialising device-mapper backend library.
Trying to load LUKS2 crypt type from device /tmp/systemd-cryptsetup-H8y.IMAGE.
Crypto backend (OpenSSL 1.1.1k  FIPS 25 Mar 2021) initialized in cryptsetup library version 2.3.7.
Detected kernel Linux 4.18.0-521.el8.ppc64le ppc64le.
...
Failed to find TPM PCR public key file 'tpm2-pcr-public-key.pem': No such file or directory
Failed to read TPM2 PCR public key, proceeding without: No such file or directory
Can't find symbol Esys_TR_GetTpmHandle: /lib64/libtss2-esys.so.0: undefined symbol: Esys_TR_GetTpmHandle
libtss2-esys too old, does not include Esys_TR_GetTpmHandle.
Can't find symbol Esys_TR_GetTpmHandle: /lib64/libtss2-esys.so.0: undefined symbol: Esys_TR_GetTpmHandle
libtss2-esys too old, does not include Esys_TR_GetTpmHandle.
PolicyPCR calculated digest: 9a1f511fb94f030eb21d0332ef2739727bf0ead4ec26a204d15b09cdeb4b2555
Calculating sealed object.
Calculating encrypted seed for sealed object.
Calculating encrypted seed for ECC sealed object.
Calculating KDFe().
KDF-SS requires openssl >= 3.
Could not calculate KDFe: Operation not supported
Could not calculate encrypted seed: Operation not supported
Failed to seal to TPM2: Operation not supported
2023-11-13 20:37:36 +01:00
Lennart Poettering
abc19a6ffa storagetm: expose more useful metadata for nvme block devices
don't let the devices to be announced just as model "Linux". Let's instead
propagate the underlying block device's model. Also do something
reasonably smart for the serial and firmware version fields.
2023-11-13 19:32:34 +00:00
David Tardon
9daa7e7454 tests: add test for udevadm control -p
Follow-up for e1593039db .
2023-11-13 19:19:55 +01:00
Yu Watanabe
7fad66b1a7
Merge pull request #29958 from mrc0mmand/journal-line_max
journal: recalculate line_max when stdout stream state changes
2023-11-11 12:39:57 +09:00
Luca Boccassi
be0916f77c
Merge pull request #29955 from poettering/repart-seal-key
repart: add --tpm2-seal-key= support, matching the recently added support cryptenroll has
2023-11-10 16:52:00 +00:00
Luca Boccassi
d8beda5023
Merge pull request #29947 from poettering/srk-beefup
tpm2: make SRK easily accessible for use with systemd-cryptenroll --tpm2-device-key=
2023-11-10 16:47:46 +00:00
Luca Boccassi
ba8eda568c portablectl: fix detaching when an extension image has been deleted 2023-11-10 12:58:45 +00:00
Frantisek Sumsal
1bc4463351 test: drop the workaround for unexpected newlines 2023-11-09 13:30:53 +01:00
Frantisek Sumsal
a155ef7b65 test: add one missing assertion
This also makes sure the first signal doesn't "spill" over into the
second check.
2023-11-09 12:13:33 +00:00
Lennart Poettering
948a4bb5cf test: test the new srk extraction functionality 2023-11-09 12:50:20 +01:00
Lennart Poettering
6528563e64 test: make sure --tpm2-device-key= works correctly in repart, too 2023-11-09 12:28:37 +01:00
Frantisek Sumsal
730ccf9681 test: use Type=notify together with busctl monitor
Let's use the newly gained feature of `busctl` and start is as a
Type=notify unit, which should make sure the unit is started only after
`busctl` is on the bus listening for messages.

This should help with a race spotted in CIs, where we continued too
early after starting `busctl monitor` and miss the emitted signals:

[   10.914831] testsuite-45.sh[694]: + systemd-run --unit busctl-monitor.service --service-type=exec busctl monitor --json=short '--match=type='\''signal'\'',sender=org.freedesktop.timesync1,member='\''PropertiesChanged'\'',path=/org/free>
[   11.064365] systemd[1]: Starting busctl-monitor.service...
[   11.064903] systemd[1]: Started busctl-monitor.service.
[   11.065192] testsuite-45.sh[740]: Running as unit: busctl-monitor.service; invocation ID: ee44a9d713c34b9a97e3e7f6f4fffe77
...
[   11.069255] testsuite-45.sh[694]: + timedatectl ntp-servers ntp99 10.0.0.1
[   11.077140] systemd-timesyncd[728]: Network configuration changed, trying to establish connection.
[   11.077461] testsuite-45.sh[694]: + assert_networkd_ntp ntp99 10.0.0.1
...
[   11.087418] testsuite-45.sh[694]: + assert_timesyncd_signal '2023-11-08 16:28:48.861455' LinkNTPServers 10.0.0.1
...
[   11.095543] testsuite-45.sh[694]: + for _ in {0..9}
[   11.095543] testsuite-45.sh[694]: + journalctl -q '--since=2023-11-08 16:28:48.861455' -p info _SYSTEMD_UNIT=busctl-monitor.service --grep .
[   11.193258] systemd-journald[375]: Received client request to sync journal.
[   11.112424] testsuite-45.sh[694]: + sleep .5
[   11.160318] dbus-daemon[465]: [system] Connection :1.56 (uid=0 pid=741 comm="/usr/bin/busctl monitor --json=short --match=type=") became a monitor.

Resolves: #29923
2023-11-09 00:00:27 +01:00
Frantisek Sumsal
9a42457bae test: drop some unnecessary quotes 2023-11-08 23:38:28 +01:00
Yu Watanabe
797b237c77 test: use wait-online 2023-11-09 07:16:56 +09:00
Yu Watanabe
e1d4613eaa test: prefix network config files with digits 2023-11-09 07:16:56 +09:00
Frantisek Sumsal
4e55082f74 test: retry the property check a couple of times
41e4ce06fe shortened existing sleeps, which resulted in the check being
sometimes done before the property had a chance to update. Let's do what
what we do with the rest of the checks and retry it a couple of times.

Resolves: #29923
2023-11-08 10:03:53 +00:00
Lennart Poettering
e3c5842732
Merge pull request #28519 from ddstreet/tpm2_external_seal
Update systemd-cryptenroll to enroll TPM using only public key
2023-11-08 10:28:28 +01:00
Yu Watanabe
c62345ffc7 tree-wide: fix typo 2023-11-08 14:57:33 +09:00
Frantisek Sumsal
9521574cd4 timesync: fix PropertiesChanges signals for NTP properties
As in their current form they didn't work at all:

systemd-timesyncd[190115]: Assertion 's' failed at src/libsystemd/sd-event/sd-event.c:3058, function sd_event_source_set_enabled(). Ignoring.
systemd-timesyncd[190115]: Failed to reenable system ntp server change event source!
systemd-timesyncd[190115]: Failed to enable ntp server defer event, ignoring: Invalid argument

This was also pointed out in the post-merge review [0].

Let's address this together with the rest of the comments, and add
some tests to make sure everything works as it should.

Resolves: #28770
Follow-up to: 8f1c446

[0] 8f1c446979 (r124147466)
2023-11-07 21:36:59 +01:00
Frantisek Sumsal
41e4ce06fe test: "prettify" the test a bit 2023-11-07 21:36:59 +01:00
Dan Streetman
803e95932f test: update TEST-70 with systemd-cryptenroll calculated TPM2 enrollment
Update test to check systemd-cryptenroll --tpm2-device-key= enrollment.
2023-11-07 12:29:36 -05:00
Dan Streetman
57f0786ee0 test: fix env var name of persistent handle used for testing so it is removed after test
The cleanup uses PERSISTENT_HANDLE while the test uses PERSISTENT, so change
the test to use PERSISTENT_HANDLE so it's cleaned up (i.e. removed from the
tpm) after the test.
2023-11-07 12:28:56 -05:00
Frantisek Sumsal
4457a2e0ee test: wait for the "latest" systemd-bsod message
Let's wait for the "latest" message systemd-bsod prints to the console
to appear, otherwise we might be too fast and take a console snapshot
before it contains all the information:

[   44.237788] testsuite-04.sh[1744]: + setterm --term linux --dump --file /tmp/console.dump
[   44.246089] systemd-bsod[1858]: QR code could not be printed, ignoring: Operation not supported
[   44.305692] testsuite-04.sh[1744]: + grep -aq 'The current boot has failed' /tmp/console.dump
[   44.308047] testsuite-04.sh[1744]: + grep -aq 'Service emergency message' /tmp/console.dump
[   44.311200] testsuite-04.sh[1744]: + grep -aq 'Press any key to exit' /tmp/console.dump
[   44.314359] testsuite-04.sh[1744]: + at_exit
[   44.315087] testsuite-04.sh[1744]: + local EC=1
[   44.315945] testsuite-04.sh[1744]: + [[ 1 -ne 0 ]]
[   44.316647] testsuite-04.sh[1744]: + [[ -e /tmp/console.dump ]]
[   44.318305] testsuite-04.sh[1744]: + cat /tmp/console.dump
[   44.319320] testsuite-04.sh[1871]:    The current boot has failed!
[   44.319970] testsuite-04.sh[1871]:    Service emergency message
2023-11-06 21:01:24 +00:00
Frantisek Sumsal
7dafeb6d6b test: add test case for issue #29863 2023-11-06 20:26:53 +09:00
Frantisek Sumsal
0ffb690111 test: make the test happy with coverage builds
Bump the LimitFSIZE=, since the process needs to write quite a lot of
.gcda files, and suppress coverage errors with DynamicUser=true.
2023-11-05 00:32:04 +00:00
Yu Watanabe
ab8f553d1e sd-journal: rework generic_array_bisect()
- Rename generic_array_bisect_one() -> generic_array_bisect_step(), as there
  is also generic_array_bisect_plus_one(), so the original name is confusing.
- Make generic_array_bisect_step() return TEST_GOTO_NEXT or TEST_GOTO_PREVIOUS
  when the current array does not contain any matching entries.
- Make generic_array_bisect_step() symmetric with respect to the direction
  we are going to, except for the journal corruption handling.
- Make generic_array_bisect_step() gracefully handle journal corruptions,
  so the corruption handling in the caller side can be mostly dropped.
- Especially, when the last entry in an array is corrupted, previously
  we tried to find a valid entry sequentially from the end of the array,
  but now we anyway bisect the array. That should improve performance of
  reading corrupted journal files.
- Return earlier when no entry linked to the chained array (n == 0).
- Add many comments.

No behavior change unless journal is corrupted.
2023-11-04 11:01:30 +09:00
Frantisek Sumsal
12c2560997 test: wait for the nvme device to appear
Also, use a /dev/disk/by-id/ symlink to the device, which should be
predictable, unlike the /dev/nvmeX stuff.
2023-11-03 23:26:57 +00:00
Frantisek Sumsal
ebefce6eab test: add a couple of tests for systemd-bsod
Add some basic tests for systemd-bsod, mainly to have something to build on
for #29056.
2023-11-03 20:39:15 +00:00
Maanya Goenka
db776f6935 portable: add support for confext
Support confexts for portable services
2023-11-03 16:59:58 +00:00
Luca Boccassi
f0304df6e4 core: check that extensions have the hierarchies before overlaying
Before confext was added, hierarchies always existed in extensions. Now
they are optional - i.e., a sysext will not contain /etc/. So mixing a
confext and a sysext fails, as we'll try to create an overlay with /etc/
from the base, the confext and the sysext, but the latter doesn't have
the directory.

After the source images are mounted, check that each hierarchy exists in
each source image before creating the overlay, and drop them if they
don't.

Follow-up for 55ea4ef096
2023-11-03 16:59:58 +00:00
Luca Boccassi
8d04721507
Merge pull request #28891 from poettering/pcrlock
new pcrlock tool for generating signed PCR policies for PCR 0, 1, 4, …
2023-11-03 16:07:43 +00:00
Frantisek Sumsal
d4317fe172 nspawn: allow disabling os-release check
Introduce a new env variable $SYSTEMD_NSPAWN_CHECK_OS_RELEASE, that can
be used to disable the os-release check for bootable OS trees. Useful
when trying to boot a container with empty /etc/ and bind-mounted /usr/.

Resolves: #29185
2023-11-03 16:05:14 +00:00
Lennart Poettering
3e6a25a6f3 test: add pcrlock integration test
(Contains various test additions added by @mrc0mmand)
2023-11-03 11:25:14 +01:00
Luca Boccassi
d2e99d288e
Merge pull request #29792 from poettering/resolved-monitor-packet
resolved: make sure "resolvectl monitor" can properly deal with stub …
2023-11-02 20:43:19 +00:00
Frantisek Sumsal
a0e000076a test: check that resolvectl monitor --json generates valid JSON
Provides coverage for #29580.
2023-11-02 18:08:30 +01:00
Lennart Poettering
565b7c90eb test: add integration test for systemd-storagetm 2023-11-02 14:19:32 +01:00
Peter Hutterer
4f7a629e6c analyze: handle CAP_BPF support 2023-11-01 10:25:59 +00:00
Frantisek Sumsal
3d72a9645e test: exercise more systemd-executor related stuff 2023-10-31 18:52:00 +01:00
Frantisek Sumsal
72d50da4f6 test: skip SocketBind*= tests when built without a bpf framework
The test intentionally checks for -BPF_FRAMEWORK so we run the test case
(and fail) even if we rename the feature flag.
2023-10-31 17:36:03 +01:00
Yu Watanabe
d19434fbf8 tree-wide: fix typo 2023-10-31 14:35:33 +09:00
Frantisek Sumsal
d203e5e008 test: add one missing cleanup
So the test doesn't fail when run multiple times with the same image.
2023-10-30 22:37:08 +09:00
Luca Boccassi
7b6d3dcdd2 exec-invoke: don't double-close FDs on error
When a late error occurs in sd-executor, the cleanup-on-close of the
context structs happen, but at that time all FDs might have already
been closed via close_all_fds(), so a double-close happens. This
can be seen when DynamicUser is enabled, with a non-existing
WorkingDirectory.

Invalidate the FDs in the context structs if close_all_fds succeeds.
2023-10-28 16:56:25 +02:00
Luca Boccassi
3ad5aedadc test: io.latency cgroup support might not be available, skip test
It doesn't seem to be enabled on Debian stable, and the test fails.

Follow-up for 5efc8183c9
2023-10-28 08:08:42 +00:00
Luca Boccassi
8a505d3b6b
Merge pull request #29734 from YHNdnzj/fstab-filter-options
fstab-generator: drop ignored mount options from mount unit Options=
2023-10-27 23:20:46 +01:00
Frantisek Sumsal
5efc8183c9 test: cover more sd-executor related stuff
Let's probe directives that have slightly more "complex" handling in
the serialization/deserialization machinery.
2023-10-27 21:01:33 +02:00
Mike Yuan
b3ee014879
fstab-generator: drop unapplicable mount options for / from mount unit Options=
Prompted by #29705

Note that x-systemd.wanted-by= and x-systemd.required-by= are not
dropped, since we ignore them because they are unnecessary rather
than unapplicable.
2023-10-27 23:51:01 +08:00
Luca Boccassi
63862de4b7 core: do not post-process skipped mounts
When a mount is gracefully skipped (e.g.: BindReadOnlyPaths=-/nonexistent)
we still post-process it, like making it read-only. Except if nothing
has been mounted, the mount point will be made read-only for no reason.
Track when mounts are skipped and avoid post-processing.

One day we'll switch all of this to the new mount api and do these
operations atomically or not at all.

Fixes https://github.com/systemd/systemd/issues/29725
2023-10-26 21:15:41 +01:00
Luca Boccassi
e34836aa59
Merge pull request #29529 from yuwata/core-namespace-check-priv
core/namespace: check if we have enough privilege
2023-10-26 14:27:56 +01:00
Yu Watanabe
e9af462aba test: add a simple test for PrivateNetwork= 2023-10-26 19:09:49 +09:00
Frantisek Sumsal
d08b67e55e test: slightly extend systemd-tpm2-setup's coverage 2023-10-25 18:18:48 +02:00
Frantisek Sumsal
af70e2021e test: add a couple more tests for systemd-pcrextend 2023-10-25 18:18:47 +02:00
Frantisek Sumsal
45534eefe6 test: make the TPM event log checking a bit more robust
Don't hardcode the event number, so the test works correctly even if
someone wrote to the event log before us. Also, explicitly pick the
sha256 bank when checking digests, as the indexing may vary depending on
current TPM's capabilities.
2023-10-25 18:18:11 +02:00
Frantisek Sumsal
29be59555f test: split TEST-70-TPM2 into subtests 2023-10-25 14:48:30 +02:00
Luca Boccassi
7470e161cf
Merge pull request #29553 from keszybz/analyze-cat-config-tldr
analyze/cat-config: add switch to print only "interesting" parts of conffiles
2023-10-25 09:53:19 +01:00
Zbigniew Jędrzejewski-Szmek
063c838206 analyze/cat-config: add switch to print only "interesting" parts of config files
When looking at configuration, often a user wants to suppress the comments and
just look at the parts that actually configure something, roughly equivalent to
  systemd-analyze cat-config … | rg -v '^(#|;|$)
This switch implements this natively, skipping lines that start with a comment
character or only contain whitespace.

For formats that have section headers, section headers are skipped, if only
followed by stuff that would be skipped. (The last section header is printed
when we're about to print some actual output.)

Note that the caller doesn't know if the format has headers or not. We do format
type detection in pretty-print.c. So the caller only specifies tldr=true|false, and
conf_files_cat() figures out if the format has headers and whether those should
be handled specially.

The comments that show the file name are always printed, even if all of the file
is suppressed.

This is a partial answer to the discussions in
https://github.com/systemd/systemd/pull/28919,
https://github.com/systemd/systemd/pull/29248. If the default config is shown in
config files, the user can conveniently use '--tldr' to show the relevant parts.
2023-10-24 15:59:34 +02:00
Luca Boccassi
665a3d6d15 systemctl: automatically softreboot/kexec if set up on reboot
Automatically softreboot if the nextroot has been set up with an OS
tree, or automatically kexec if a kernel has been loaded with kexec
--load.

Add SYSTEMCTL_SKIP_AUTO_KEXEC and SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT to
skip the automated switchover.
2023-10-20 11:45:37 +01:00
Luca Boccassi
f5a7476677
Merge pull request #29628 from mrc0mmand/systemd-executor-test
test: slightly improve sd-executor's coverage
2023-10-19 19:39:39 +01:00
Frantisek Sumsal
e98f7f9122 test: skip Protect{Home,System}= tests with coverage builds
With coverage builds we disable Protect{Home,System}= via a service.d
dropin in /etc, which has, unfortunately, higher priority than our
transient systemd-run stuff. Let's just skip the affected tests in that
case instead of making the test setup even more complicated.
2023-10-19 18:03:57 +01:00
Frantisek Sumsal
a2dd592002 test: unify checking for user xattrs support in cgroupfs
Also, run the coredump forwarding test only if user xattrs are
supported.
2023-10-19 18:01:07 +01:00
Frantisek Sumsal
4701425dd5 test: add coverage for #29610
As reproducing it is actually pretty easy, with the benefit of hindsight:

~# systemd-run -P -p MountImages="/this/should/definitely/not/exist.img:/run/img2\:3:nosuid" false
Running as unit: run-u42.service
free(): double free detected in tcache 2
2023-10-19 16:23:28 +02:00
Mike Yuan
2ee346160c
systemctl: is-failed: check if system is degraded when no unit given
Closes #3335
2023-10-19 00:12:28 +08:00
Frantisek Sumsal
7e9c7d6f5b test: use Type=exec for the test unit
Make sure everything we need is set up before continuing further with
the test. This should, hopefully, help with a race where we check
a dynamic user before it's created by NFTSet= stuff.

Before:
$ journalctl -o short-monotonic --grep '(test-nft|NFT|testsuite-75)' --no-hostname
...
[ 3657.929223] testsuite-75.sh[48]: + systemd-run -u test-nft.service -p DynamicUser=yes -p 'NFTSet=cgroup:inet:sd_test:c user:inet:sd_test:u group:inet:sd_test:g' sleep 10000
...
[ 3657.977372] systemd[1]: test-nft.service: Changed dead -> running
[ 3657.977388] systemd[1]: test-nft.service: Job 376 test-nft.service/start finished, result=done
[ 3657.977407] testsuite-75.sh[853]: Running as unit: test-nft.service; invocation ID: 8776af2ec7864a60a058cb5d403d1ca6
[ 3657.982437] testsuite-75.sh[856]:                 elements = { "system.slice/test-nft.service" }
[ 3657.984570] testsuite-75.sh[48]: + grep -qF test-nft.service /tmp/tmp.uqXKfyzcpJ
[ 3657.985400] testsuite-75.sh[859]: ++ getent passwd test-nft
[ 3657.986434] systemd[1]: varlink-12: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test-nft","service":"io.systemd.DynamicUser"}}
[ 3657.986503] systemd[1]: varlink-12: Sending message: {"error":"io.systemd.UserDatabase.NoRecordFound","parameters":{}}
[ 3657.986643] systemd[1]: testsuite-75.service: Child 48 belongs to testsuite-75.service.
[ 3657.986660] systemd[1]: testsuite-75.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
[ 3657.986681] systemd[1]: testsuite-75.service: Failed with result 'exit-code'.
...
[ 3657.989885] systemd[1]: test-nft.service: User lookup succeeded: uid=64568 gid=64568
[ 3657.989936] systemd[1]: Added NFT set: family inet, table sd_test, set u, ID 64568
[ 3657.989965] systemd[1]: Added NFT set: family inet, table sd_test, set g, ID 64568

After:
$ journalctl -o short-monotonic --grep '(test-nft|NFT|testsuite-75)' --no-hostname
[ 1523.874408] testsuite-75.sh[49]: + systemd-run -u test-nft.service --service-type=exec -p DynamicUser=yes -p 'NFTSet=cgroup:inet:sd_test:c user:inet:sd_test:u group:inet:sd_test:g' sleep 10000
...
[ 1523.924091] systemd[1]: Starting test-nft.service...
[ 1523.928891] systemd[1]: test-nft.service: User lookup succeeded: uid=64568 gid=64568
[ 1523.929102] systemd[1]: Added NFT set: family inet, table sd_test, set u, ID 64568
[ 1523.929220] systemd[1]: Added NFT set: family inet, table sd_test, set g, ID 64568
...
[ 1523.933263] systemd[1]: Started test-nft.service.
[ 1523.933626] testsuite-75.sh[849]: Running as unit: test-nft.service; invocation ID: d1a5c3eacbc647a7a5fcbd46c7b2f863
[ 1523.940810] testsuite-75.sh[852]:                 elements = { "system.slice/test-nft.service" }
[ 1523.942880] testsuite-75.sh[49]: + grep -qF test-nft.service /tmp/tmp.gWka2x3mQq
[ 1523.944031] testsuite-75.sh[855]: ++ getent passwd test-nft
[ 1523.945496] systemd[1]: varlink-18: New incoming message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"userName":"test-nft","service":"io.systemd.DynamicUser"}}
[ 1523.951593] systemd[1]: varlink-18: Sending message: {"parameters":{"record":{"userName":"test-nft","uid":64568,"gid":64568,"realName":"Dynamic User",...
2023-10-18 16:08:44 +01:00
Frantisek Sumsal
41231bec0c test: don't restart journal-upload on an expected fail
In c08bec1587 the journal-upload unit gained Restart=on-fail, which goes
against this one particular test that expects the unit to fail, making
the test flaky. Let's disable the automatic restarts just for this test
to make it stable once again.
2023-10-17 14:55:12 +01:00
Daan De Meyer
37ba73b1b2
Merge pull request #28373 from DaanDeMeyer/udevadm-query
Add --json and filtering options for --export-db to udevadm info
2023-10-17 10:16:43 +02:00
Lennart Poettering
e0eb051f95
Merge pull request #29546 from poettering/run-invoc-id
run: output invocation ID when starting service and scope units
2023-10-16 19:00:18 +02:00