SaltDns. Rfc2136. Update
(Salt v1.0.0)
Pure RFC 2136 UPDATE processing: a decoded UPDATE message, a zone snapshot and a permission function in; an rcode and a minimal change list out.
process(message, zone, permit) :: {rcode, [change]}rcode is one of :noerror :formerr :servfail :nxdomain :notimp :refused :yxdomain :yxrrset :nxrrset :notauth :notzone (SaltDns.Rfc2136.Message.rcode_number/1
maps them to numbers). change is {:add | :remove, name, type, ttl, rdata}
with name the canonical owner name (lower case, no trailing dot), type
the upper-case mnemonic ("TXT", "TYPE65280") and rdata a canonical
dns_erlang rdata struct. On any rcode other than :noerror the list is
empty: the update is atomic.
permit.(action, name, type) is asked with the same name and type
spelling. M6b builds it from SaltDns.Auth.Grants.allowed?/5.
Order of processing (RFC 2136 section 3)
- Section 3.1: ZOCOUNT must be 1 and ZTYPE SOA (else FORMERR); the zone must be the snapshot's zone and class IN (else NOTAUTH).
- Section 3.2 form checks, in order: TTL 0 and class (FORMERR), names inside the zone (NOTZONE), empty RDATA for classes ANY/NONE (FORMERR). Section 3.4.1 prescan of the update section likewise.
- Section 3.3 permission (see below).
- Section 3.2 prerequisite state checks (YXDOMAIN, NXDOMAIN, YXRRSET, NXRRSET), value-dependent RRsets compared as sets, TTL ignored (section 3.2.3).
- Section 3.4.2 processing, sequentially, each RR seeing the effect of the ones before it.
Deliberate choices
- Permission before prerequisite state. RFC 2136 places the check
after the prerequisites, but section 3.3.2 only says "this is the point
where such performance should take place" for implementation-dependent
policies. Evaluating prerequisites first lets a key that may write one
name probe which names, RRsets and values exist anywhere in the zone
(NXDOMAIN vs NOERROR). So prerequisites are first checked for form
only, then
permit.(:read, name, type)is asked for each (type"ANY"for the name-level prerequisites), thenpermit.(:update, ...)for every (name, type) the update section touches, and only then is the zone state consulted. Form errors (FORMERR, NOTZONE) therefore win over REFUSED, and REFUSED wins over the state rcodes. A delete-all-RRsets RR (section 3.4.2.3) is asked for as type"ANY"at the name, whatever exists there: only a key that may update every type at the name can send it, and for any other key the answer is REFUSED whether or not the name exists (otherwise REFUSED versus NOERROR would reveal whether a type outside the key's grant is present). Clients that remove one RRset or one record (certbot, lego, acme.sh, Karta) are unaffected. - Managed records are never changed. Apex SOA and NS, and DNSKEY, RRSIG, NSEC, NSEC3, NSEC3PARAM, CDS and CDNSKEY anywhere, are managed by Salt DNS. An update that names one of them (add, delete RRset or delete RR) is REFUSED whatever the grants say (RFC 2136 section 3.3 allows a policy refusal). RFC 2136 section 3.4.2.3 says "delete all RRsets from a name" leaves SOA and NS at the apex alone; this module leaves the managed types alone everywhere and does not refuse for them.
- Names. A name is inside the zone only if its labels end with the
zone's labels (
:dns_domain.split/1, case-insensitive). A name with a label that is empty or contains a dot or backslash (for examplex\.example.comas seen belowexample.com) is REFUSED, in either section: Salt DNS cannot store or grant such names. - Meta types. Section 3.4.1.2's text also rejects "unrecognized" types; its pseudocode and RFC 3597 do not, so unknown types are accepted here (grants decide). Types 41 and 249..255 are meta types. A value-dependent prerequisite of a meta type can never match and gives NXRRSET (section 3.2.3), not FORMERR.
- CNAME rules (3.4.2.2). A CNAME add is ignored when the name has any other RRset (RRSIG, NSEC and NSEC3 excepted) or is the apex; a non-CNAME add is ignored when the name has a CNAME. A CNAME add replaces the whole CNAME RRset. Ignored RRs are silent no-ops.
- TTL. An add to an RRset sets the RRset's TTL to the new value (RFC 2181 section 5.2 only requires one TTL per RRset; the newest wins), including a re-add of an identical RR with a new TTL. A TTL change is reported as removes of every RR at the old TTL and adds at the new TTL.
- Duplicates and no-ops. Duplicate RRs are collapsed (3.4.2.2), deleting what is not there or adding what is already there with the same TTL yields no change. The list is minimal and ordered: removes, then adds, each sorted by name, type and rdata.
- SOA adds below the apex are ignored (no zone SOA there, 3.4.2.2); WKS special handling is not implemented (the record type is not supported by Salt DNS). The additional-data section is ignored (2.6).
Summary
Functions
Processes an UPDATE message against a zone snapshot. See the moduledoc.
Types
Functions
@spec process(term(), SaltDns.Rfc2136.Zone.t(), permit()) :: {rcode(), [SaltDns.Rfc2136.Zone.change()]}
Processes an UPDATE message against a zone snapshot. See the moduledoc.