catalog/interpret: multiple groups per member are tolerated and ignored

This commit is contained in:
Libor Peltan 2023-09-05 17:52:38 +02:00 committed by Daniel Salzman
parent 4b417ac24f
commit 34b7fb9b41
3 changed files with 12 additions and 9 deletions

View 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,

View 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;
}

View 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)