Skip to content
Snippets Groups Projects
Commit 2a27c502 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman
Browse files

catalog: only take PTRs from 'zones' subtree

parent be1e052f
Branches
Tags
1 merge request!1132Zone catalog implemeted
......@@ -609,6 +609,7 @@ It's possible to configure more catalog zones.
part of your DNS subtree.
Upon catalog zone (re)load or change, all the PTR records in the zone
sub-tree *zones* (e.g. ``unique-id1.zones.catalog. 0 IN PTR member.com.``)
are processed and member zones created, with zone names taken from the
PTR records' RData, and zone settings taken from the confguration
template specified by :ref:`zone_catalog-template`. Owner names of those PTR
......
......@@ -327,9 +327,18 @@ static int cat_update_add_node(zone_node_t *node, void *data)
int knot_cat_update_from_zone(knot_cat_update_t *u, struct zone_contents *zone,
bool remove, knot_catalog_t *check)
{
size_t zone_size = knot_dname_size(zone->apex->owner);
knot_dname_t sub[zone_size + 6];
memcpy(sub, "\x05""zones", 6);
memcpy(sub + 6, zone->apex->owner, zone_size);
if (zone_contents_find_node(zone, sub) == NULL) {
return KNOT_EOK;
}
cat_upd_ctx_t ctx = { u, zone->apex->owner, remove, check };
pthread_mutex_lock(&u->mutex);
int ret = zone_contents_apply(zone, cat_update_add_node, &ctx);
int ret = zone_tree_sub_apply(zone->nodes, sub, false, cat_update_add_node, &ctx);
pthread_mutex_unlock(&u->mutex);
return ret;
}
......
......@@ -4,4 +4,5 @@ $TTL 0
@ SOA ns admin 1 25 25 80 600
NS ns
ns AAAA ::0
foo.bar PTR cataloged1.
foo.bar.zones PTR cataloged1.
not.zones.in PTR not-cataloged1.
......@@ -46,6 +46,8 @@ resp = slave.dig("cataloged1.", "DNSKEY", dnssec=True)
resp.check(rcode="NOERROR")
resp.check_count(2, "DNSKEY")
resp.check_count(1, "RRSIG")
resp = master.dig("not-cataloged1.", "SOA")
resp.check(rcode="REFUSED")
# Udating a cataloged zone
subprocess.run(["sed", "-i", "s/10001/10002/;$s/$/\\nxyz A 1.2.3.4/", master.dir + "/master/cataloged1.zone"])
......@@ -59,7 +61,7 @@ check_keys(slave, "cataloged1", 2)
# Check adding cataloged zone.
up = master.update(zone[1])
up.add("bar.catalog1.", 0, "PTR", "cataloged2.")
up.add("bar.zones.catalog1.", 0, "PTR", "cataloged2.")
up.send("NOERROR")
t.sleep(6)
resp = master.dig("cataloged2.", "NS")
......@@ -81,8 +83,8 @@ resp0 = slave.dig("cataloged2.", "DNSKEY")
resp0.check_count(2, "DNSKEY")
dnskey0 = resp0.resp.answer[0].to_rdataset()[0]
up = master.update(zone[1])
up.delete("bar.catalog1.", "PTR", "cataloged2.")
up.add("bar.catalog1.", 0, "PTR", "cataloged2.")
up.delete("bar.zones.catalog1.", "PTR", "cataloged2.")
up.add("bar.zones.catalog1.", 0, "PTR", "cataloged2.")
up.send("NOERROR")
t.sleep(4)
resp1 = slave.dig("cataloged2.", "DNSKEY")
......@@ -100,8 +102,8 @@ else:
# Check remove-adding the zone: shall effectively purge it
up = master.update(zone[1])
up.delete("bar.catalog1.", "PTR", "cataloged2.")
up.add("bar2.catalog1.", 0, "PTR", "cataloged2.")
up.delete("bar.zones.catalog1.", "PTR", "cataloged2.")
up.add("bar2.zones.catalog1.", 0, "PTR", "cataloged2.")
up.send("NOERROR")
t.sleep(4)
shutil.copy(t.data_dir + "/cataloged2.zone", master.dir + "/master") # because the purge deletes even zonefile
......@@ -131,11 +133,11 @@ resp.check_count(1, "RRSIG")
# Check adding and removing duplicate
up = master.update(zone[1])
up.add("bar3.catalog1.", 0, "PTR", "cataloged2.")
up.add("bar3.zones.catalog1.", 0, "PTR", "cataloged2.")
up.send("NOERROR")
t.sleep(6)
up = master.update(zone[1])
up.delete("bar3.catalog1.", "PTR")
up.delete("bar3.zones.catalog1.", "PTR")
up.send("NOERROR")
t.sleep(6)
resp = master.dig("cataloged2.", "SOA")
......@@ -146,7 +148,7 @@ check_keys(slave, "cataloged2", 2)
# Check removing cataloged zone
up = master.update(zone[1])
up.delete("foo.bar.catalog1.", "PTR")
up.delete("foo.bar.zones.catalog1.", "PTR")
up.send("NOERROR")
t.sleep(6)
resp = master.dig("cataloged1.", "SOA")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment