]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
catalog/interpret: multiple groups per member are tolerated and ignored
authorLibor Peltan <libor.peltan@nic.cz>
Tue, 5 Sep 2023 15:52:38 +0000 (17:52 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 6 Sep 2023 06:20:07 +0000 (08:20 +0200)
doc/configuration.rst
src/knot/catalog/interpret.c
tests-extra/tests/catalog/groups/test.py

index 6c1766c7735ef6909de112d658ec7e715422e2bf..80c2c530cfef909e2018f09719a47f2a25b2e3cd 100644 (file)
@@ -640,6 +640,8 @@ Additionally, records in the format
 ``group.unique-id.zones.catalog. 0 IN TXT "conf-template"``
 are processed as a definition of the member's *group* property. The
 ``unique-id`` must match the one of the PTR record defining the member.
+It's required that at most one group is defined for each member. If multiple
+groups are defined, one group is picked at random.
 
 All other records and other member properties are ignored. They remain in the catalog
 zone, however, and might be for example transferred to a secondary server,
index e7a5cf0dd99b7b3b773c4e6328ecc32e821e2ce6..7337105c54c0422ad2d16320a721bea279a5b9bd 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2022 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 #include <stdio.h>
 
 #include "knot/catalog/interpret.h"
+#include "knot/common/log.h"
 #include "knot/journal/serialization.h"
 
 struct cat_upd_ctx;
@@ -160,8 +161,8 @@ static int cat_update_add_grp(zone_node_t *node, cat_upd_ctx_t *ctx)
        const knot_rdataset_t *txt = node_rdataset(node, KNOT_RRTYPE_TXT);
        if (txt == NULL) {
                return KNOT_EOK;
-       } else if (txt->count != 1) {
-               return KNOT_ERROR;
+       } else {
+               assert(txt->count >= 1);
        }
 
        const knot_rdataset_t *counter_txt = node_rdataset(binode_counterpart(node), KNOT_RRTYPE_TXT);
@@ -172,13 +173,16 @@ static int cat_update_add_grp(zone_node_t *node, cat_upd_ctx_t *ctx)
        const char *newgr = "";
        size_t grlen = 0;
        if (!ctx->remove) {
-               assert(txt->count == 1);
                // TXT rdata consists of one or more 1-byte prefixed strings.
                if (txt->rdata->len != txt->rdata->data[0] + 1) {
                        return KNOT_EMALF;
                }
                newgr = (const char *)txt->rdata->data + 1;
                grlen = txt->rdata->data[0];
+               if (txt->count > 1) {
+                       log_zone_warning(member, "member zone has multiple groups defined, picking '%.*s'",
+                                                (int)grlen, newgr);
+               }
                assert(grlen <= CATALOG_GROUP_MAXLEN);
        }
 
@@ -233,11 +237,6 @@ static int member_verify(zone_node_t *node, cat_upd_ctx_t *ctx)
 
 static int prop_verify(zone_node_t *node, cat_upd_ctx_t *ctx)
 {
-       if (label_eq(node->owner, CATALOG_GROUP_LABEL) &&
-           rr_count(node, KNOT_RRTYPE_TXT) > 1) {
-               return KNOT_EISRECORD;
-       }
-
        return KNOT_EOK;
 }
 
index f86137f3f7f14408cc7ff02756a383049cc0dadb..a874346febc9097ec0f0228223371c31b6012e72 100644 (file)
@@ -64,6 +64,7 @@ resp.check_count(1, "RRSIG")
 # Move member between groups
 up = master.update(zone)
 up.delete("group.bar.zones.catalog2.", "TXT")
+up.add("group.bar.zones.catalog2.", 0, "TXT", "redundant-ignored")
 up.add("group.bar.zones.catalog2.", 0, "TXT", "catalog-signed")
 up.send("NOERROR")
 t.sleep(4)
@@ -73,6 +74,7 @@ resp.check_count(1, "RRSIG")
 
 # Add member to a group
 up = master.update(zone)
+up.add("group.baz.zones.catalog2.", 0, "TXT", "redundant-ignored")
 up.add("group.baz.zones.catalog2.", 0, "TXT", "catalog-signed")
 up.send("NOERROR")
 t.sleep(4)