resolvectl: clarify IDNA and search path logic in combination with "resolvectl query --type="

When low-level RR resolution is requested from "resolvectl query" via
"--type=" or "--class=" no search domain logic is applied and no IDNA
translation.

Explain this in detail in the documentation, and also mentions this when
users attempt to resolve single-label names or names with international
characters in the output.

I believe the current behaviour is correct, but it is indeed surprising.
Hence the documentation and output improvement.

Fixes: #11325 #10737
This commit is contained in:
Lennart Poettering
2021-02-16 09:51:17 +01:00
parent e557c82dd5
commit 018b642a98
2 changed files with 65 additions and 11 deletions
+34 -2
View File
@@ -407,19 +407,51 @@ static int output_rr_packet(const void *d, size_t l, int ifindex) {
return 0;
}
static int idna_candidate(const char *name, char **ret) {
_cleanup_free_ char *idnafied = NULL;
int r;
assert(name);
assert(ret);
r = dns_name_apply_idna(name, &idnafied);
if (r < 0)
return log_error_errno(r, "Failed to apply IDNA to name '%s': %m", name);
if (r > 0 && !streq(name, idnafied)) {
*ret = TAKE_PTR(idnafied);
return true;
}
*ret = NULL;
return false;
}
static int resolve_record(sd_bus *bus, const char *name, uint16_t class, uint16_t type, bool warn_missing) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *req = NULL, *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *idnafied = NULL;
bool needs_authentication = false;
unsigned n = 0;
uint64_t flags;
int r;
usec_t ts;
bool needs_authentication = false;
int r;
assert(name);
log_debug("Resolving %s %s %s (interface %s).", name, dns_class_to_string(class), dns_type_to_string(type), isempty(arg_ifname) ? "*" : arg_ifname);
if (dns_name_is_single_label(name))
log_notice("(Note that search domains are not appended when resolving raw record types. "
"Please specify fully qualified domain names when resolving raw records, or remove --type= switch from invocation in order to request regular hostname resolution.)");
r = idna_candidate(name, &idnafied);
if (r < 0)
return r;
if (r > 0)
log_notice("(Note that IDNA translation is not applied when resolving raw record types. "
"Please specify translated domain names — i.e. '%s' — when resolving raw records, or remove --type= switch from invocation in order to request regular hostname resolution.",
idnafied);
r = bus_message_new_method_call(bus, &req, bus_resolve_mgr, "ResolveRecord");
if (r < 0)
return bus_log_create_error(r);