From 34b7fb9b41810dc8385ecce4af151d2f9fc4cf19 Mon Sep 17 00:00:00 2001 From: Libor Peltan Date: Tue, 5 Sep 2023 17:52:38 +0200 Subject: [PATCH] catalog/interpret: multiple groups per member are tolerated and ignored --- doc/configuration.rst | 2 ++ src/knot/catalog/interpret.c | 17 ++++++++--------- tests-extra/tests/catalog/groups/test.py | 2 ++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index 6c1766c77..80c2c530c 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -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, diff --git a/src/knot/catalog/interpret.c b/src/knot/catalog/interpret.c index e7a5cf0dd..7337105c5 100644 --- a/src/knot/catalog/interpret.c +++ b/src/knot/catalog/interpret.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2022 CZ.NIC, z.s.p.o. +/* Copyright (C) 2023 CZ.NIC, z.s.p.o. 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 #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; } diff --git a/tests-extra/tests/catalog/groups/test.py b/tests-extra/tests/catalog/groups/test.py index f86137f3f..a874346fe 100644 --- a/tests-extra/tests/catalog/groups/test.py +++ b/tests-extra/tests/catalog/groups/test.py @@ -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)