summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-06 01:01:00 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-06 01:04:23 +0100
commitbec690501ed544199e72a292fbd6d28bc1e1727e (patch)
tree324302a341b0883cf7295d8137c276338ee89cbd
parent30c778094b90a637c6691c462a66df81eeb865b5 (diff)
resolved: when dumping the NTA database, sort output
Now that we populate the trust database by default with a larger number of entires, we better make sure to output a more readable version.
-rw-r--r--src/resolve/resolved-dns-trust-anchor.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c
index 928f7f7860..9f8b76ebe2 100644
--- a/src/resolve/resolved-dns-trust-anchor.c
+++ b/src/resolve/resolved-dns-trust-anchor.c
@@ -441,7 +441,13 @@ static int dns_trust_anchor_load_files(
return 0;
}
-static void dns_trust_anchor_dump(DnsTrustAnchor *d) {
+static int domain_name_cmp(const void *a, const void *b) {
+ char **x = (char**) a, **y = (char**) b;
+
+ return dns_name_compare_func(*x, *y);
+}
+
+static int dns_trust_anchor_dump(DnsTrustAnchor *d) {
DnsAnswer *a;
Iterator i;
@@ -462,12 +468,22 @@ static void dns_trust_anchor_dump(DnsTrustAnchor *d) {
if (set_isempty(d->negative_by_name))
log_info("No negative trust anchors defined.");
else {
- char *n;
- log_info("Negative trust anchors:");
+ _cleanup_free_ char **l = NULL, *j = NULL;
+
+ l = set_get_strv(d->negative_by_name);
+ if (!l)
+ return log_oom();
- SET_FOREACH(n, d->negative_by_name, i)
- log_info("%s%s", n, endswith(n, ".") ? "" : ".");
+ qsort_safe(l, set_size(d->negative_by_name), sizeof(char*), domain_name_cmp);
+
+ j = strv_join(l, " ");
+ if (!j)
+ return log_oom();
+
+ log_info("Negative trust anchors: %s", j);
}
+
+ return 0;
}
int dns_trust_anchor_load(DnsTrustAnchor *d) {