Commit Graph
7247 Commits
Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek caf889d1ea tty-ask-password-agent: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 5c5d3d2065 socket-activate: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The note about sd_listen_fds() is kept as the
footer.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 440b021cff pty-forward: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek a6dfe21862 path: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. --help now goes through the pager, like other
commands with --no-pager.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 94a955cd31 oomd: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 6fc95be4a2 mute-console: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 548c9cd71c inhibit: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The synopsis now also lists the --list mode,
matching the man page. --help now goes through the pager, like other
commands with --no-pager.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek bde24b07b4 systemd-imds: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is left as it was, nonimperative.
I tried a few different forms but couldn't find one that was clearly
better.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 6515ac25da escape: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The synopsis is updated to be more truthful
and consistent between the prog and man page.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek bf09e3ac21 detect-virt: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek 81f2319291 delta: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. --help now goes through the pager, like other
commands with --no-pager.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek cab5a18abb cgtop: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:30:02 +02:00
Zbigniew Jędrzejewski-Szmek d768cdcceb cgls: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. --help now goes through the pager, like other
commands with --no-pager.

Synopses are adjusted. --user-unit/--unit without any unit names is
technically allowed, but not very meaningful, since it's the same as
the default mode. So [] is dropped. And the prog help string is then
adjusted to match the man page.
2026-08-15 15:28:58 +02:00
Zbigniew Jędrzejewski-Szmek 73d0a3a2ea cat: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. "COMMAND…" is marked as optional, since
'cat' is the default verb.
2026-08-15 15:25:23 +02:00
Zbigniew Jędrzejewski-Szmek 38293644a2 bsod: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:25:23 +02:00
Zbigniew Jędrzejewski-Szmek 50ffe81202 binfmt: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is changed to use the imperative
form ("Register …" instead of "Registers …"), consistent with the other
commands. --help now goes through the pager, like other commands with
--no-pager.
2026-08-15 15:25:23 +02:00
Zbigniew Jędrzejewski-Szmek c0a3967acb battery-check: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:25:23 +02:00
Zbigniew Jędrzejewski-Szmek 7027ca6ee4 systemd-hwdb: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added.
2026-08-15 15:25:23 +02:00
Zbigniew Jędrzejewski-Szmek ba76d38f37 firstboot: convert to VERB_COMMAND and add --introspect-cli
The custom help() is replaced by a COMMAND() description, and
--introspect-cli is added. The abstract is changed to use the imperative
form ("Configure …" instead of "Configures …"), consistent with the
other commands.
2026-08-15 15:24:58 +02:00
Zbigniew Jędrzejewski-Szmek f25a3d3240 TEST-74-AUX-UTILS.introspect-cli: simplify how --introspect-cli is tested
After c9cd66ee3a and
c81b5d36b9, the comment about systemd-backlight
and systemd-veritysetup was outdated. We can test them as any other program.

Also, use an array to make list easier to extend in the future and
adjust $PATH so we don't need to care about the split between public
and non-public programs.
2026-08-15 13:36:54 +02:00
dongshengyuan 507ba1e51c core: fix bind paths whitespace parsing
Stop warning on extra spaces in BindPaths= and BindReadOnlyPaths=.
Keep bind path parsing and serialization consistent.

Fixes: #43214
2026-08-15 00:26:40 +09:00
Paul Meyer d6154a4d4b test: run_subtests_and_exit helper
Replace the "run_subtests; touch /testok" tail with a single wrapper
invocation. Report the test itself as skipped if every subtest is
skipped.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-14 16:00:49 +02:00
Paul Meyer f2e5962fe8 test: skip unrunnable subtests via exit 77
Now that run_subtests() understands 77 as skipped, make the subtests
that bail out early on a missing capability or precondition exit 77
instead of exit 0. Partial skips that run after real assertions, and
exits from inside subshells, are deliberately left untouched.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-14 16:00:49 +02:00
Paul Meyer 2966fbd391 test: let subtests report skips via exit 77
run_subtests() and run_subtests_with_signals() now treat a subtest exit
code of 77 as skipped rather than a failure, track skipped subtests
separately, and list them in the summary. Previously a subtest could
only fake a skip by exiting 0, which was indistinguishable from a real
pass.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-14 16:00:49 +02:00
Paul Meyer c346b82a53 test: move wait_for_machine into util.sh
The vmspawn-based TEST-87 subtests each carried a near-identical
wait_for_machine() helper. Move it into util.sh so it can be shared.
The shared version is the vmspawn.sh variant, which tells missing
vhost-user-fs (nested VM) apart from any other early exit. As a result,
bin-volume and replace-storage now use that distinction too instead of
treating every early exit alike. vmspawn-drives is unaffected of this,
its --image-only console never matches the vhost-user-fs marker, so an
early exit still fails.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-14 16:00:49 +02:00
dongshengyuan 77b9a626ce getty-generator: strip whitespace from getty.auto credential
The getty.auto credential is a textual configuration value, but credentials
are read as raw file contents. A value written by common text-file workflows
can therefore end in a newline, causing false\n to be rejected and ignored.

Reproducer:
  printf 'false\n' > "$CREDENTIALS_DIRECTORY/getty.auto"

Before: getty units could still be generated because the credential was
ignored as invalid.
Expected: false\n is parsed the same as false and disables getty
generation.

Strip the value in getty-generator before parsing it. This keeps the
credential framework byte-preserving while applying text semantics where
getty.auto is consumed.

Follow-up for: 3a883e89bc
2026-08-14 11:59:58 +02:00
Zbigniew Jędrzejewski-Szmek 8975c5c1cf Add a "declarative program header" and introspection of options and verbs (#43152) 2026-08-14 11:52:42 +02:00
Yu Watanabe 8f4cd7de43 resolvectl: fix query option handling and resolvconf input errors (#43370) 2026-08-14 00:35:58 +09:00
Yu Watanabe df9265b5a3 resolved: fix domain replacement and delegate DNS parsing (#43365) 2026-08-14 00:29:26 +09:00
Luca Boccassi 4f80cc06a1 test: add TEST-94-COCO integration test for confidential VMs (#43296) 2026-08-13 13:19:15 +01:00
Zbigniew Jędrzejewski-Szmek 8a14181f55 resolvectl: separate systemd-resolve in introspection data
Previously, the systemd-resolve compat alias was described in the same
CommandDescription structure and resolvectl. But they have different
option sets, so this doesn't really work. The alias is deprecated, so
describe it as such in the abstract, but give it a separate entry.

$ build/resolvectl --introspect-cli
{
  "mediaType": "application/vnd.io.systemd.cli-introspection-0",
  "commands": [
    {
      "names": [ "resolvconf" ],
      "abstract": [
        "Register DNS server and domain configuration with systemd-resolved."
      ],
      ...
    },
    {
      "names": [ "resolvectl" ],
      "abstract": [
        "Send control commands to the network name resolution manager, or\nresolve domain names, IPv4 and IPv6 addresses, DNS records, and services."
      ],
      ...
    },
    {
      "names": [ "systemd-resolve" ],
      "abstract": [
        "Send control commands to the network name resolution manager, or\nresolve domain names, IPv4 and IPv6 addresses, DNS records, and services.\n\nThis command is deprecated. Use resolvectl.1 instead."
      ],
      ...
    }
  ]
}
2026-08-13 13:23:05 +02:00
Zbigniew Jędrzejewski-Szmek 1a54ce154c various: add --introspect-cli 2026-08-13 13:23:05 +02:00
dongshengyuan 253b34d8ac resolvconf: reject malformed stdin without changing link state
The resolvconf compatibility parser ignored errors from
nameserver, domain, and search lines. If one of those lines was
malformed, resolvectl could still send the partially parsed
configuration to resolved and overwrite the previous link state.

Reproducer:

  IF=enp1s0
  TMP="$(mktemp -d)"

  ln -s "$(command -v resolvectl)" "$TMP/resolvconf"

  sudo resolvectl dns "$IF" 1.1.1.1
  sudo resolvectl domain "$IF" keep.example
  resolvectl domain "$IF"

  printf 'nameserver 1.1.1.1\nsearch "unterminated\n' |
    sudo "$TMP/resolvconf" -a "$IF" || true

  resolvectl domain "$IF"

Before:

  The malformed search line was ignored and the previous domain
  was cleared:

    Link 2 (enp1s0): keep.example
    Link 2 (enp1s0):

After:

  The malformed input fails before updating resolved, so
  keep.example remains configured.

Follow-up for: 097f130731
2026-08-13 17:40:50 +08:00
dongshengyuan e7223f2ab2 resolvectl: reject --raw for regular lookups
--raw only affects ResolveRecord output. Without --type= or an
RFC4501 dns: URI, query takes the ResolveHostname/ResolveAddress
paths, where --raw was silently ignored.

Reproducer:

  build/resolvectl --raw query localhost

Before:

  The command exited successfully and printed regular text output,
  such as:

    localhost: 127.0.0.1

After:

  The command fails before issuing a lookup:

    --raw may only be combined with --type= or dns: URIs.

Follow-up for: 05ea7e87b6
2026-08-13 17:40:49 +08:00
dongshengyuan e021a64391 resolvectl: avoid TXT lookup for plain SRV service queries
The service verb documents the one- and two-argument forms as
SRV lookups. They should not request TXT records by default.
Only the three-argument DNS-SD form should request TXT metadata.

Reproducer:

  Run resolvectl service _mysvc._tcp signed.test in the
  TEST-75-RESOLVED environment, where signed.test contains:

    _mysvc._tcp SRV 10 5 1234 myservice
    _mysvc._tcp TXT "This is TXT for myservice"
    myservice A 10.0.0.20

Before:

  resolvectl service _mysvc._tcp signed.test printed TXT data
  for the plain SRV form:

    _mysvc._tcp/signed.test: myservice.signed.test:1234 [priority=10, weight=5]
                             10.0.0.20
                             fd00:dead:beef:cafe::17
                             This is TXT for myservice

After:

  The plain SRV form suppresses TXT data. The DNS-SD form still
  shows it:

    resolvectl service '' _mysvc._tcp signed.test

Follow-up for: a7a4c60a25
2026-08-13 17:40:49 +08:00
Paul Meyer d66923ea07 test: fix race in TEST-07-PID1 multi-unit transaction subtest
Test failed with the following:

TEST-07-PID1.sh[20020]: + systemctl stop issue8102-nop-dep.service
TEST-07-PID1.sh[20409]: ++ systemctl show -P ActiveState issue8102-nop-dep.service
TEST-07-PID1.sh[20020]: + [[ failed == inactive ]]

systemctl start only waits for the jobs of the units named on the
command line, so the start job pulled in for issue8102-nop-dep.service
via Wants= was not waited for. When the following stop landed while its
ExecStart= was still running, the process was SIGTERMed, and since
Type=oneshot does not treat termination by signal as a clean exit, the
unit ended up failed instead of inactive:

issue8102-nop-dep.service: Changed start -> stop-sigterm
issue8102-nop-dep.service: Main process exited, code=killed, status=15/TERM
issue8102-nop-dep.service: Failed with result 'signal'.

Start both units explicitly so both jobs are waited for.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-13 09:58:53 +01:00
dongshengyuan a572dd2f60 resolved: allow full replacement of link domains
SetLinkDomains() marks old link domains and then builds the replacement
list in place. The marked old domains still counted against
LINK_SEARCH_DOMAINS_MAX, so replacing a non-empty list with exactly the
maximum number of new domains failed while adding the last entry. The error
path then unlinked all domains, so a failed setter call also destroyed the
previous configuration.

Reproducer:

  resolvectl domain dnsbug1 old.example
  busctl call org.freedesktop.resolve1 /org/freedesktop/resolve1 \
    org.freedesktop.resolve1.Manager SetLinkDomains 'ia(sb)' "$ifindex" 1024 "${args[@]}"
  resolvectl domain dnsbug1

Before: the bus call failed with "Argument list too long" and the link's
domain list became empty.

Follow-up for: d2ec6608b9
2026-08-13 09:04:26 +08:00
dongshengyuan 0cfa2d4f4c resolved: keep parsing DNS delegate servers after duplicates
The DNS delegate parser tries to filter duplicate DNS= entries, but the
duplicate branch returned from the whole parser. This made a duplicate
server truncate the rest of the same DNS= line, silently dropping later
valid servers.

Reproducer:

  DNS=192.168.77.78 192.168.77.78 192.168.77.79

Before: only 192.168.77.78 appeared in the delegate server list.

Follow-up for: 7928c0e0a1
2026-08-13 09:02:52 +08:00
dongshengyuan 060b0d2f70 resolvectl: reject tlsa without a domain
The tlsa command accepts an optional service family before the domain list.
When the only argument was "tcp", "udp", or "sctp", we consumed it as the
family and returned success without issuing any query.

Reproducer:

  build/resolvectl tlsa tcp

Before: the command printed nothing and exited with status 0.

Follow-up for: ebbc70e511
2026-08-13 09:02:52 +08:00
Yu Watanabe 3ae53ab8f6 analyze: allow --json= for the chid, blame and identify-tpm2 verbs (#43366)
verb_chid(), verb_blame() and verb_identify_tpm2() all render their
output via table_print_with_pager() with arg_json_format_flags, so JSON
output has been implemented for them since each verb was introduced.
None of them was ever added to the verb allowlist
that gates --json=, so e.g. systemd-analyze chid --json=pretty failed
with:

Option --json= is only supported for security, inspect-elf,
dlopen-metadata, ...

This adds them to the allowlist and the error message. After a sweep of
src/analyze/ for arg_json_format_flags, these are the only remaining
verbs that render through it but were not allowlisted.

has-tpm2 is deliberately not included: verb_has_tpm2() defers to
verb_has_tpm2_generic(), which writes plain text via printf() and has no
JSON support, so accepting --json= there would silently ignore it. The
table_print_with_pager() call in analyze-has-tpm2.c
belongs to verb_identify_tpm2(), which is what got allowlisted instead.

The chid gap went unnoticed because its TEST-65-ANALYZE coverage is
guarded behind a check for SMBIOS board_vendor and a non-container
environment, so it only runs on bare-metal/VM runners.
2026-08-13 00:06:07 +09:00
Paul Meyer b89729b16a test: add TEST-94-COCO integration test for confidential VMs
Teach the harness a --coco=tdx|sev-snp|any flag: it gates the test on
host coco capability (exit 77 otherwise), binds /dev/kvm and the coco
device(s) into the boot-mode container, and passes the resolved type to
the test via $COCO_TYPE.

TEST-94-COCO boots the mkosi image as a confidential guest with
systemd-vmspawn --coco= (using the /vm-images bind) and checks the guest
reports the expected type via systemd-detect-virt --cvm. Runs only on
coco-capable bare-metal hosts, skips elsewhere.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-12 15:57:07 +02:00
Paul Meyer 5f34079a6a test: bind built images into boot-mode tests via a --vm-images option
Integration tests that boot a nested VM (e.g. with systemd-vmspawn) need
the mkosi-built images, which are build outputs rather than installed
test artifacts. Add a --vm-images wrapper flag and 'vm-images' test
option that bind-mount the mkosi output directory read-only into the
boot-mode container at /work/vm-images, instead of exposing the whole
build tree via RuntimeBuildSources.

Signed-off-by: Paul Meyer <katexochen0@gmail.com>
2026-08-12 15:57:07 +02:00
Ivan Kruglov 46a91a1867 test: cover --json= for the blame and identify-tpm2 verbs
Both verbs render through arg_json_format_flags but --json= was rejected for
them until the previous commit, and nothing in TEST-65-ANALYZE exercised it.
Add coverage in line with the other JSON-capable verbs.

identify-tpm2 is only invoked when has-tpm2 reports full support, as it
fails with EOPNOTSUPP when built without TPM2 support.
2026-08-12 03:54:33 -07:00
dongshengyuan 628e8304cc resolved: notice route-only domain updates
SetLinkDomains() tracks whether the configured search domain list changed
so it can skip redundant persistence. The route_only flag is part of the
D-Bus API and is persisted as a ~ prefix, but flipping an existing domain
between search and route-only only updated in-memory state and left
changed false. The method then skipped link_save_user() and
manager_write_resolv_conf(), leaving stale state until restart.

Reproduced on Ubuntu with systemd 259:

  sudo resolvectl domain enp1s0 route-only-repro.test
  sudo resolvectl domain enp1s0 '~route-only-repro.test'
  resolvectl domain enp1s0
  grep '^DOMAINS=' /run/systemd/resolve/netif/$(cat /sys/class/net/enp1s0/ifindex)
  grep -H route-only-repro.test /run/systemd/resolve/*.conf

Before, resolvectl showed ~route-only-repro.test, but the persisted state
file still showed DOMAINS=route-only-repro.test, and the generated
resolv.conf files still contained search route-only-repro.test.

After this change, the state file is updated to
DOMAINS=~route-only-repro.test and the generated resolv.conf files are
refreshed so the route-only domain is not emitted as a search domain.

Follow-up for: cbf23f3853
2026-08-12 18:51:34 +09:00
dongshengyuan e98c68104b core: do not chown fd-passed TTYs
When stdio is passed as file descriptors, the provider of those
descriptors remains responsible for their ownership and access mode.

This keeps run0 in a pipeline from changing the caller's TTY ownership
to the target user, which can otherwise break later terminal access from
the original user.

Fixes #43336
2026-08-12 03:11:02 +09:00
Luca Boccassi 8271442983 test: drop forgotten set +e (#43359)
This was introduced all the way back in 2019 where this particular test
case was the last one in the file, so it worked as intended.
Unfortunately, since then we added new tests after this one, which means
this particular `set +e` masked fails in any of them (except for
assert_*() calls, which call exit on fail).
2026-08-11 17:40:25 +01:00
Frantisek Sumsal ed0727fecd test: sync the journal before checking it for ordering cycle messages
Otherwise we might get an empty match:

TEST-03-JOBS.sh[100]: + IDS_FILE=/tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[314]: + varlinkctl call /run/systemd/io.systemd.Manager io.systemd.Manager.Describe '{}'
TEST-03-JOBS.sh[315]: + jq .runtime.TransactionsWithOrderingCycle
TEST-03-JOBS.sh[316]: ++ jq length /tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[100]: + [[ 20 -ge 20 ]]
TEST-03-JOBS.sh[100]: + for i in {0..19}
TEST-03-JOBS.sh[317]: ++ jq -r '.[0]' /tmp/TEST-03-JOBS-CYCLE-IDS-30241
TEST-03-JOBS.sh[100]: + journalctl -b TRANSACTION_ID=48 --grep 'cycle starting with'
TEST-03-JOBS.sh[318]: -- No entries --
[FAILED] Failed to start TEST-03-JOBS.service - TEST-03-JOBS.
[  !!  ] Exiting: unit TEST-03-JOBS.service failed

Even though the message was properly emitted:

$ journalctl --file TEST-03-JOBS-1.journal -b TRANSACTION_ID=48 --grep 'cycle starting with'
Aug 11 14:46:15 H systemd[1]: [🡕] transaction-cycle17.service: Unable to break cycle starting with transaction-cycle17.service/start
2026-08-11 16:12:42 +02:00
Frantisek Sumsal 143c284567 test: drop forgotten set +e
This was introduced all the way back in 2019 where this particular test
case was the last one in the file, so it worked as intended.
Unfortunately, since then we added new tests after this one, which means
this particular `set +e` masked fails in any of them (except for
assert_*() calls, which call exit on fail).
2026-08-11 16:12:42 +02:00
Frantisek Sumsal 2c4e86c290 test: fix & enhance test for RestartMode=
Stay `set +e` in the test masked that this test has apparently never
worked in the first place: when a unit is killed with a signal, any
bound unit is stopped retroactively via
retroactively_stop_dependencies() but it's not restarted again, as the
restart for the bound unit is queued as TRY_RESTART in a following
transaction - but at this point the bound unit is already inactive, so
the TRY_RESTART job collapses into a NOP.

Let's account for this and also add a couple of test cases for
RestartMode= with an explicit restart, which should trigger the bound
unit as well (assuming it's active).

Follow-up for 9b42c58a2b.
2026-08-11 16:11:25 +02:00
Frantisek Sumsal 2b81535f74 test: fix typo in test unit
Follow-up for bf3dfa6202.
2026-08-11 12:40:53 +02:00