summaryrefslogtreecommitdiff
path: root/source4/dns_server
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2010-10-03 12:21:00 +0200
committerKai Blin <kai@samba.org>2010-10-23 10:58:18 +0000
commit72c8ccd408070bcb3defba34865d31a1ea6311fe (patch)
tree5b1914319e3c9f0cf0cd0573e8d116699930c0eb /source4/dns_server
parent005a65660d1d5a39cccdabca1970b7e56537df17 (diff)
downloadsamba-72c8ccd408070bcb3defba34865d31a1ea6311fe.tar.gz
samba-72c8ccd408070bcb3defba34865d31a1ea6311fe.tar.bz2
samba-72c8ccd408070bcb3defba34865d31a1ea6311fe.zip
s4 dns: Implement update record prescan logic
Autobuild-User: Kai Blin <kai@samba.org> Autobuild-Date: Sat Oct 23 10:58:18 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/dns_server')
-rw-r--r--source4/dns_server/dns_update.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/dns_server/dns_update.c b/source4/dns_server/dns_update.c
index 81e3fce599..f789f2d625 100644
--- a/source4/dns_server/dns_update.c
+++ b/source4/dns_server/dns_update.c
@@ -91,6 +91,40 @@ static WERROR check_prerequsites(struct dns_server *dns,
return WERR_OK;
}
+static WERROR update_prescan(const struct dns_name_question *zone,
+ const struct dns_res_rec *updates, uint16_t count)
+{
+ const struct dns_res_rec *r;
+ uint16_t i;
+ size_t host_part_len;
+ bool match;
+
+ for (i = 0; i < count; i++) {
+ r = &updates[i];
+ match = dns_name_match(zone->name, r->name, &host_part_len);
+ if (!match) {
+ return DNS_ERR(NOTZONE);
+ }
+ if (zone->question_class == r->rr_class) {
+ /*TODO: also check for AXFR,MAILA,MAILB */
+ if (r->rr_type == DNS_QTYPE_ALL) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else if (r->rr_class == DNS_QCLASS_ANY) {
+ if (r->ttl != 0 || r->length != 0) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else if (r->rr_class == DNS_QCLASS_NONE) {
+ if (r->ttl != 0 || r->rr_type == DNS_QTYPE_ALL) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ }
+ return WERR_OK;
+}
+
WERROR dns_server_process_update(struct dns_server *dns,
TALLOC_CTX *mem_ctx,
struct dns_name_packet *in,
@@ -144,5 +178,8 @@ WERROR dns_server_process_update(struct dns_server *dns,
return DNS_ERR(REFUSED);
}
+ werror = update_prescan(in->questions, *updates, *update_count);
+ W_ERROR_NOT_OK_RETURN(werror);
+
return werror;
}