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
This commit is contained in:
dongshengyuan
2026-08-13 09:02:52 +08:00
parent 32ac7af788
commit 060b0d2f70
2 changed files with 5 additions and 0 deletions
+3
View File
@@ -1161,6 +1161,9 @@ static int verb_tlsa(int argc, char *argv[], uintptr_t _data, void *userdata) {
} else
args = strv_skip(argv, 1);
if (strv_isempty(args))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "The tlsa command requires at least one domain.");
STRV_FOREACH(p, args)
RET_GATHER(ret, resolve_tlsa(family, *p));
+2
View File
@@ -627,6 +627,8 @@ testcase_08_resolved() {
grep -qF '"data":"' "$RUN_OUT"
(! run resolvectl openpgp mr.smith@signed.test --json=short --type=A)
grep -qF -- "The openpgp command may only be combined with --type=OPENPGPKEY." "$RUN_OUT"
(! run resolvectl tlsa tcp)
grep -qF -- "The tlsa command requires at least one domain." "$RUN_OUT"
(! run resolvectl tlsa signed.test:invalid --json=short)
grep -qF 'Invalid port "invalid".' "$RUN_OUT"
(! run resolvectl tlsa signed.test --json=short --type=A)