From: Lennart Poettering Date: Mon, 4 Mar 2024 09:00:05 +0000 (+0100) Subject: resolvectl: output nice error message if we can't JSONify RR X-Git-Tag: v256-rc1~650 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbcfa943cde6c55a41feda34d01741dd70e2b5e5;p=thirdparty%2Fsystemd.git resolvectl: output nice error message if we can't JSONify RR Some RR types we don't have a mapping to JSON for. Handle this reasonably. --- diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c index 580913b94e4..405e8ec215d 100644 --- a/src/resolve/resolvectl.c +++ b/src/resolve/resolvectl.c @@ -454,6 +454,9 @@ static int output_rr_packet(const void *d, size_t l, int ifindex) { if (r < 0) return log_error_errno(r, "Failed to convert RR to JSON: %m"); + if (!j) + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "JSON formatting for records of type %s (%u) not available.", dns_type_to_string(rr->key->type), rr->key->type); + r = json_variant_dump(j, arg_json_format_flags, NULL, NULL); if (r < 0) return r;