|
|
bcb1e2 |
From 93b8bd39145566053ad8b22cef597146e9175ea4 Mon Sep 17 00:00:00 2001
|
|
|
bcb1e2 |
From: Evan Hunt <each@isc.org>
|
|
|
bcb1e2 |
Date: Tue, 8 Nov 2022 17:32:41 -0800
|
|
|
bcb1e2 |
Subject: [PATCH] move update ACL and update-policy checks before quota
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
check allow-update, update-policy, and allow-update-forwarding before
|
|
|
bcb1e2 |
consuming quota slots, so that unauthorized clients can't fill the
|
|
|
bcb1e2 |
quota.
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
(this moves the access check before the prerequisite check, which
|
|
|
bcb1e2 |
violates the precise wording of RFC 2136. however, RFC co-author Paul
|
|
|
bcb1e2 |
Vixie has stated that the RFC is mistaken on this point; it should have
|
|
|
bcb1e2 |
said that access checking must happen *no later than* the completion of
|
|
|
bcb1e2 |
prerequisite checks, not that it must happen exactly then.)
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
(cherry picked from commit 964f559edb5036880b8e463b8f190b9007ee055d)
|
|
|
bcb1e2 |
---
|
|
|
bcb1e2 |
lib/ns/update.c | 335 ++++++++++++++++++++++++++----------------------
|
|
|
bcb1e2 |
1 file changed, 181 insertions(+), 154 deletions(-)
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
diff --git a/lib/ns/update.c b/lib/ns/update.c
|
|
|
bcb1e2 |
index 9a8c309..036184b 100644
|
|
|
bcb1e2 |
--- a/lib/ns/update.c
|
|
|
bcb1e2 |
+++ b/lib/ns/update.c
|
|
|
bcb1e2 |
@@ -261,6 +261,9 @@ static void
|
|
|
bcb1e2 |
forward_done(isc_task_t *task, isc_event_t *event);
|
|
|
bcb1e2 |
static isc_result_t
|
|
|
bcb1e2 |
add_rr_prepare_action(void *data, rr_t *rr);
|
|
|
bcb1e2 |
+static isc_result_t
|
|
|
bcb1e2 |
+rr_exists(dns_db_t *db, dns_dbversion_t *ver, dns_name_t *name,
|
|
|
bcb1e2 |
+ const dns_rdata_t *rdata, bool *flag);
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
/**************************************************************************/
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
@@ -333,25 +336,26 @@ inc_stats(ns_client_t *client, dns_zone_t *zone, isc_statscounter_t counter) {
|
|
|
bcb1e2 |
static isc_result_t
|
|
|
bcb1e2 |
checkqueryacl(ns_client_t *client, dns_acl_t *queryacl, dns_name_t *zonename,
|
|
|
bcb1e2 |
dns_acl_t *updateacl, dns_ssutable_t *ssutable) {
|
|
|
bcb1e2 |
+ isc_result_t result;
|
|
|
bcb1e2 |
char namebuf[DNS_NAME_FORMATSIZE];
|
|
|
bcb1e2 |
char classbuf[DNS_RDATACLASS_FORMATSIZE];
|
|
|
bcb1e2 |
- int level;
|
|
|
bcb1e2 |
- isc_result_t result;
|
|
|
bcb1e2 |
+ bool update_possible =
|
|
|
bcb1e2 |
+ ((updateacl != NULL && !dns_acl_isnone(updateacl)) ||
|
|
|
bcb1e2 |
+ ssutable != NULL);
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
result = ns_client_checkaclsilent(client, NULL, queryacl, true);
|
|
|
bcb1e2 |
if (result != ISC_R_SUCCESS) {
|
|
|
bcb1e2 |
+ int level = update_possible ? ISC_LOG_ERROR : ISC_LOG_INFO;
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
dns_name_format(zonename, namebuf, sizeof(namebuf));
|
|
|
bcb1e2 |
dns_rdataclass_format(client->view->rdclass, classbuf,
|
|
|
bcb1e2 |
sizeof(classbuf));
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
- level = (updateacl == NULL && ssutable == NULL) ? ISC_LOG_INFO
|
|
|
bcb1e2 |
- : ISC_LOG_ERROR;
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
ns_client_log(client, NS_LOGCATEGORY_UPDATE_SECURITY,
|
|
|
bcb1e2 |
NS_LOGMODULE_UPDATE, level,
|
|
|
bcb1e2 |
"update '%s/%s' denied due to allow-query",
|
|
|
bcb1e2 |
namebuf, classbuf);
|
|
|
bcb1e2 |
- } else if (updateacl == NULL && ssutable == NULL) {
|
|
|
bcb1e2 |
+ } else if (!update_possible) {
|
|
|
bcb1e2 |
dns_name_format(zonename, namebuf, sizeof(namebuf));
|
|
|
bcb1e2 |
dns_rdataclass_format(client->view->rdclass, classbuf,
|
|
|
bcb1e2 |
sizeof(classbuf));
|
|
|
bcb1e2 |
@@ -1543,6 +1547,156 @@ send_update_event(ns_client_t *client, dns_zone_t *zone) {
|
|
|
bcb1e2 |
isc_result_t result = ISC_R_SUCCESS;
|
|
|
bcb1e2 |
update_event_t *event = NULL;
|
|
|
bcb1e2 |
isc_task_t *zonetask = NULL;
|
|
|
bcb1e2 |
+ dns_ssutable_t *ssutable = NULL;
|
|
|
bcb1e2 |
+ dns_message_t *request = client->message;
|
|
|
bcb1e2 |
+ dns_aclenv_t *env =
|
|
|
bcb1e2 |
+ ns_interfacemgr_getaclenv(client->manager->interface->mgr);
|
|
|
bcb1e2 |
+ dns_rdataclass_t zoneclass;
|
|
|
bcb1e2 |
+ dns_rdatatype_t covers;
|
|
|
bcb1e2 |
+ dns_name_t *zonename = NULL;
|
|
|
bcb1e2 |
+ dns_db_t *db = NULL;
|
|
|
bcb1e2 |
+ dns_dbversion_t *ver = NULL;
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ CHECK(dns_zone_getdb(zone, &db);;
|
|
|
bcb1e2 |
+ zonename = dns_db_origin(db);
|
|
|
bcb1e2 |
+ zoneclass = dns_db_class(db);
|
|
|
bcb1e2 |
+ dns_zone_getssutable(zone, &ssutable);
|
|
|
bcb1e2 |
+ dns_db_currentversion(db, &ver);
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ /*
|
|
|
bcb1e2 |
+ * Update message processing can leak record existence information
|
|
|
bcb1e2 |
+ * so check that we are allowed to query this zone. Additionally,
|
|
|
bcb1e2 |
+ * if we would refuse all updates for this zone, we bail out here.
|
|
|
bcb1e2 |
+ */
|
|
|
bcb1e2 |
+ CHECK(checkqueryacl(client, dns_zone_getqueryacl(zone),
|
|
|
bcb1e2 |
+ dns_zone_getorigin(zone),
|
|
|
bcb1e2 |
+ dns_zone_getupdateacl(zone), ssutable));
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ /*
|
|
|
bcb1e2 |
+ * Check requestor's permissions.
|
|
|
bcb1e2 |
+ */
|
|
|
bcb1e2 |
+ if (ssutable == NULL) {
|
|
|
bcb1e2 |
+ CHECK(checkupdateacl(client, dns_zone_getupdateacl(zone),
|
|
|
bcb1e2 |
+ "update", dns_zone_getorigin(zone), false,
|
|
|
bcb1e2 |
+ false));
|
|
|
bcb1e2 |
+ } else if (client->signer == NULL && !TCPCLIENT(client)) {
|
|
|
bcb1e2 |
+ CHECK(checkupdateacl(client, NULL, "update",
|
|
|
bcb1e2 |
+ dns_zone_getorigin(zone), false, true));
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (dns_zone_getupdatedisabled(zone)) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "dynamic update temporarily disabled "
|
|
|
bcb1e2 |
+ "because the zone is frozen. Use "
|
|
|
bcb1e2 |
+ "'rndc thaw' to re-enable updates.");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ /*
|
|
|
bcb1e2 |
+ * Prescan the update section, checking for updates that
|
|
|
bcb1e2 |
+ * are illegal or violate policy.
|
|
|
bcb1e2 |
+ */
|
|
|
bcb1e2 |
+ for (result = dns_message_firstname(request, DNS_SECTION_UPDATE);
|
|
|
bcb1e2 |
+ result == ISC_R_SUCCESS;
|
|
|
bcb1e2 |
+ result = dns_message_nextname(request, DNS_SECTION_UPDATE))
|
|
|
bcb1e2 |
+ {
|
|
|
bcb1e2 |
+ dns_name_t *name = NULL;
|
|
|
bcb1e2 |
+ dns_rdata_t rdata = DNS_RDATA_INIT;
|
|
|
bcb1e2 |
+ dns_ttl_t ttl;
|
|
|
bcb1e2 |
+ dns_rdataclass_t update_class;
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ get_current_rr(request, DNS_SECTION_UPDATE, zoneclass, &name,
|
|
|
bcb1e2 |
+ &rdata, &covers, &ttl, &update_class);
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (!dns_name_issubdomain(name, zonename)) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_NOTZONE, "update RR is outside zone");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ if (update_class == zoneclass) {
|
|
|
bcb1e2 |
+ /*
|
|
|
bcb1e2 |
+ * Check for meta-RRs. The RFC2136 pseudocode says
|
|
|
bcb1e2 |
+ * check for ANY|AXFR|MAILA|MAILB, but the text adds
|
|
|
bcb1e2 |
+ * "or any other QUERY metatype"
|
|
|
bcb1e2 |
+ */
|
|
|
bcb1e2 |
+ if (dns_rdatatype_ismeta(rdata.type)) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ result = dns_zone_checknames(zone, name, &rdata);
|
|
|
bcb1e2 |
+ if (result != ISC_R_SUCCESS) {
|
|
|
bcb1e2 |
+ FAIL(DNS_R_REFUSED);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ } else if (update_class == dns_rdataclass_any) {
|
|
|
bcb1e2 |
+ if (ttl != 0 || rdata.length != 0 ||
|
|
|
bcb1e2 |
+ (dns_rdatatype_ismeta(rdata.type) &&
|
|
|
bcb1e2 |
+ rdata.type != dns_rdatatype_any))
|
|
|
bcb1e2 |
+ {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ } else if (update_class == dns_rdataclass_none) {
|
|
|
bcb1e2 |
+ if (ttl != 0 || dns_rdatatype_ismeta(rdata.type)) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ } else {
|
|
|
bcb1e2 |
+ update_log(client, zone, ISC_LOG_WARNING,
|
|
|
bcb1e2 |
+ "update RR has incorrect class %d",
|
|
|
bcb1e2 |
+ update_class);
|
|
|
bcb1e2 |
+ FAIL(DNS_R_FORMERR);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ /*
|
|
|
bcb1e2 |
+ * draft-ietf-dnsind-simple-secure-update-01 says
|
|
|
bcb1e2 |
+ * "Unlike traditional dynamic update, the client
|
|
|
bcb1e2 |
+ * is forbidden from updating NSEC records."
|
|
|
bcb1e2 |
+ */
|
|
|
bcb1e2 |
+ if (rdata.type == dns_rdatatype_nsec3) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "explicit NSEC3 updates are not "
|
|
|
bcb1e2 |
+ "allowed "
|
|
|
bcb1e2 |
+ "in secure zones");
|
|
|
bcb1e2 |
+ } else if (rdata.type == dns_rdatatype_nsec) {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "explicit NSEC updates are not "
|
|
|
bcb1e2 |
+ "allowed "
|
|
|
bcb1e2 |
+ "in secure zones");
|
|
|
bcb1e2 |
+ } else if (rdata.type == dns_rdatatype_rrsig &&
|
|
|
bcb1e2 |
+ !dns_name_equal(name, zonename))
|
|
|
bcb1e2 |
+ {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "explicit RRSIG updates are "
|
|
|
bcb1e2 |
+ "currently "
|
|
|
bcb1e2 |
+ "not supported in secure zones "
|
|
|
bcb1e2 |
+ "except "
|
|
|
bcb1e2 |
+ "at the apex");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (ssutable != NULL) {
|
|
|
bcb1e2 |
+ isc_netaddr_t netaddr;
|
|
|
bcb1e2 |
+ dst_key_t *tsigkey = NULL;
|
|
|
bcb1e2 |
+ isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (client->message->tsigkey != NULL) {
|
|
|
bcb1e2 |
+ tsigkey = client->message->tsigkey->key;
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (rdata.type != dns_rdatatype_any) {
|
|
|
bcb1e2 |
+ if (!dns_ssutable_checkrules(
|
|
|
bcb1e2 |
+ ssutable, client->signer, name,
|
|
|
bcb1e2 |
+ &netaddr, TCPCLIENT(client), env,
|
|
|
bcb1e2 |
+ rdata.type, tsigkey))
|
|
|
bcb1e2 |
+ {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "rejected by "
|
|
|
bcb1e2 |
+ "secure update");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ } else {
|
|
|
bcb1e2 |
+ if (!ssu_checkall(db, ver, name, ssutable,
|
|
|
bcb1e2 |
+ client->signer, &netaddr, env,
|
|
|
bcb1e2 |
+ TCPCLIENT(client), tsigkey))
|
|
|
bcb1e2 |
+ {
|
|
|
bcb1e2 |
+ FAILC(DNS_R_REFUSED, "rejected by "
|
|
|
bcb1e2 |
+ "secure update");
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+ if (result != ISC_R_NOMORE) {
|
|
|
bcb1e2 |
+ FAIL(result);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ update_log(client, zone, LOGLEVEL_DEBUG, "update section prescan OK");
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
result = isc_quota_attach(&client->manager->sctx->updquota,
|
|
|
bcb1e2 |
&(isc_quota_t *){ NULL });
|
|
|
bcb1e2 |
@@ -1552,9 +1706,7 @@ send_update_event(ns_client_t *client, dns_zone_t *zone) {
|
|
|
bcb1e2 |
isc_result_totext(result));
|
|
|
bcb1e2 |
ns_stats_increment(client->manager->sctx->nsstats,
|
|
|
bcb1e2 |
ns_statscounter_updatequota);
|
|
|
bcb1e2 |
- ns_client_drop(client, result);
|
|
|
bcb1e2 |
- isc_nmhandle_detach(&client->reqhandle);
|
|
|
bcb1e2 |
- return (DNS_R_DROP);
|
|
|
bcb1e2 |
+ CHECK(DNS_R_DROP);
|
|
|
bcb1e2 |
}
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
event = (update_event_t *)isc_event_allocate(
|
|
|
bcb1e2 |
@@ -1571,6 +1723,16 @@ send_update_event(ns_client_t *client, dns_zone_t *zone) {
|
|
|
bcb1e2 |
dns_zone_gettask(zone, &zonetask);
|
|
|
bcb1e2 |
isc_task_send(zonetask, ISC_EVENT_PTR(&event));
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
+failure:
|
|
|
bcb1e2 |
+ if (db != NULL) {
|
|
|
bcb1e2 |
+ dns_db_closeversion(db, &ver, false);
|
|
|
bcb1e2 |
+ dns_db_detach(&db);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
+ if (ssutable != NULL) {
|
|
|
bcb1e2 |
+ dns_ssutable_detach(&ssutable);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
return (result);
|
|
|
bcb1e2 |
}
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
@@ -1671,9 +1833,6 @@ ns_update_start(ns_client_t *client, isc_nmhandle_t *handle,
|
|
|
bcb1e2 |
break;
|
|
|
bcb1e2 |
case dns_zone_secondary:
|
|
|
bcb1e2 |
case dns_zone_mirror:
|
|
|
bcb1e2 |
- CHECK(checkupdateacl(client, dns_zone_getforwardacl(zone),
|
|
|
bcb1e2 |
- "update forwarding", zonename, true,
|
|
|
bcb1e2 |
- false));
|
|
|
bcb1e2 |
CHECK(send_forward_event(client, zone));
|
|
|
bcb1e2 |
break;
|
|
|
bcb1e2 |
default:
|
|
|
bcb1e2 |
@@ -1685,8 +1844,6 @@ ns_update_start(ns_client_t *client, isc_nmhandle_t *handle,
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
failure:
|
|
|
bcb1e2 |
if (result == DNS_R_REFUSED) {
|
|
|
bcb1e2 |
- INSIST(dns_zone_gettype(zone) == dns_zone_secondary ||
|
|
|
bcb1e2 |
- dns_zone_gettype(zone) == dns_zone_mirror);
|
|
|
bcb1e2 |
inc_stats(client, zone, ns_statscounter_updaterej);
|
|
|
bcb1e2 |
}
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
@@ -2578,7 +2735,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
|
|
bcb1e2 |
dns_rdatatype_t covers;
|
|
|
bcb1e2 |
dns_message_t *request = client->message;
|
|
|
bcb1e2 |
dns_rdataclass_t zoneclass;
|
|
|
bcb1e2 |
- dns_name_t *zonename;
|
|
|
bcb1e2 |
+ dns_name_t *zonename = NULL;
|
|
|
bcb1e2 |
dns_ssutable_t *ssutable = NULL;
|
|
|
bcb1e2 |
dns_fixedname_t tmpnamefixed;
|
|
|
bcb1e2 |
dns_name_t *tmpname = NULL;
|
|
|
bcb1e2 |
@@ -2590,8 +2747,6 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
|
|
bcb1e2 |
dns_ttl_t maxttl = 0;
|
|
|
bcb1e2 |
uint32_t maxrecords;
|
|
|
bcb1e2 |
uint64_t records;
|
|
|
bcb1e2 |
- dns_aclenv_t *env =
|
|
|
bcb1e2 |
- ns_interfacemgr_getaclenv(client->manager->interface->mgr);
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
INSIST(event->ev_type == DNS_EVENT_UPDATE);
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
@@ -2602,14 +2757,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
|
|
bcb1e2 |
zonename = dns_db_origin(db);
|
|
|
bcb1e2 |
zoneclass = dns_db_class(db);
|
|
|
bcb1e2 |
dns_zone_getssutable(zone, &ssutable);
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- /*
|
|
|
bcb1e2 |
- * Update message processing can leak record existence information
|
|
|
bcb1e2 |
- * so check that we are allowed to query this zone. Additionally
|
|
|
bcb1e2 |
- * if we would refuse all updates for this zone we bail out here.
|
|
|
bcb1e2 |
- */
|
|
|
bcb1e2 |
- CHECK(checkqueryacl(client, dns_zone_getqueryacl(zone), zonename,
|
|
|
bcb1e2 |
- dns_zone_getupdateacl(zone), ssutable));
|
|
|
bcb1e2 |
+ options = dns_zone_getoptions(zone);
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
/*
|
|
|
bcb1e2 |
* Get old and new versions now that queryacl has been checked.
|
|
|
bcb1e2 |
@@ -2745,135 +2893,10 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
update_log(client, zone, LOGLEVEL_DEBUG, "prerequisites are OK");
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
- /*
|
|
|
bcb1e2 |
- * Check Requestor's Permissions. It seems a bit silly to do this
|
|
|
bcb1e2 |
- * only after prerequisite testing, but that is what RFC2136 says.
|
|
|
bcb1e2 |
- */
|
|
|
bcb1e2 |
- if (ssutable == NULL) {
|
|
|
bcb1e2 |
- CHECK(checkupdateacl(client, dns_zone_getupdateacl(zone),
|
|
|
bcb1e2 |
- "update", zonename, false, false));
|
|
|
bcb1e2 |
- } else if (client->signer == NULL && !TCPCLIENT(client)) {
|
|
|
bcb1e2 |
- CHECK(checkupdateacl(client, NULL, "update", zonename, false,
|
|
|
bcb1e2 |
- true));
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- if (dns_zone_getupdatedisabled(zone)) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "dynamic update temporarily disabled "
|
|
|
bcb1e2 |
- "because the zone is frozen. Use "
|
|
|
bcb1e2 |
- "'rndc thaw' to re-enable updates.");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- /*
|
|
|
bcb1e2 |
- * Perform the Update Section Prescan.
|
|
|
bcb1e2 |
- */
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- for (result = dns_message_firstname(request, DNS_SECTION_UPDATE);
|
|
|
bcb1e2 |
- result == ISC_R_SUCCESS;
|
|
|
bcb1e2 |
- result = dns_message_nextname(request, DNS_SECTION_UPDATE))
|
|
|
bcb1e2 |
- {
|
|
|
bcb1e2 |
- dns_name_t *name = NULL;
|
|
|
bcb1e2 |
- dns_rdata_t rdata = DNS_RDATA_INIT;
|
|
|
bcb1e2 |
- dns_ttl_t ttl;
|
|
|
bcb1e2 |
- dns_rdataclass_t update_class;
|
|
|
bcb1e2 |
- get_current_rr(request, DNS_SECTION_UPDATE, zoneclass, &name,
|
|
|
bcb1e2 |
- &rdata, &covers, &ttl, &update_class);
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- if (!dns_name_issubdomain(name, zonename)) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_NOTZONE, "update RR is outside zone");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- if (update_class == zoneclass) {
|
|
|
bcb1e2 |
- /*
|
|
|
bcb1e2 |
- * Check for meta-RRs. The RFC2136 pseudocode says
|
|
|
bcb1e2 |
- * check for ANY|AXFR|MAILA|MAILB, but the text adds
|
|
|
bcb1e2 |
- * "or any other QUERY metatype"
|
|
|
bcb1e2 |
- */
|
|
|
bcb1e2 |
- if (dns_rdatatype_ismeta(rdata.type)) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- result = dns_zone_checknames(zone, name, &rdata);
|
|
|
bcb1e2 |
- if (result != ISC_R_SUCCESS) {
|
|
|
bcb1e2 |
- FAIL(DNS_R_REFUSED);
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- } else if (update_class == dns_rdataclass_any) {
|
|
|
bcb1e2 |
- if (ttl != 0 || rdata.length != 0 ||
|
|
|
bcb1e2 |
- (dns_rdatatype_ismeta(rdata.type) &&
|
|
|
bcb1e2 |
- rdata.type != dns_rdatatype_any))
|
|
|
bcb1e2 |
- {
|
|
|
bcb1e2 |
- FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- } else if (update_class == dns_rdataclass_none) {
|
|
|
bcb1e2 |
- if (ttl != 0 || dns_rdatatype_ismeta(rdata.type)) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_FORMERR, "meta-RR in update");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- } else {
|
|
|
bcb1e2 |
- update_log(client, zone, ISC_LOG_WARNING,
|
|
|
bcb1e2 |
- "update RR has incorrect class %d",
|
|
|
bcb1e2 |
- update_class);
|
|
|
bcb1e2 |
- FAIL(DNS_R_FORMERR);
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- /*
|
|
|
bcb1e2 |
- * draft-ietf-dnsind-simple-secure-update-01 says
|
|
|
bcb1e2 |
- * "Unlike traditional dynamic update, the client
|
|
|
bcb1e2 |
- * is forbidden from updating NSEC records."
|
|
|
bcb1e2 |
- */
|
|
|
bcb1e2 |
- if (rdata.type == dns_rdatatype_nsec3) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "explicit NSEC3 updates are not "
|
|
|
bcb1e2 |
- "allowed "
|
|
|
bcb1e2 |
- "in secure zones");
|
|
|
bcb1e2 |
- } else if (rdata.type == dns_rdatatype_nsec) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "explicit NSEC updates are not "
|
|
|
bcb1e2 |
- "allowed "
|
|
|
bcb1e2 |
- "in secure zones");
|
|
|
bcb1e2 |
- } else if (rdata.type == dns_rdatatype_rrsig &&
|
|
|
bcb1e2 |
- !dns_name_equal(name, zonename)) {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "explicit RRSIG updates are "
|
|
|
bcb1e2 |
- "currently "
|
|
|
bcb1e2 |
- "not supported in secure zones "
|
|
|
bcb1e2 |
- "except "
|
|
|
bcb1e2 |
- "at the apex");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- if (ssutable != NULL) {
|
|
|
bcb1e2 |
- isc_netaddr_t netaddr;
|
|
|
bcb1e2 |
- dst_key_t *tsigkey = NULL;
|
|
|
bcb1e2 |
- isc_netaddr_fromsockaddr(&netaddr, &client->peeraddr);
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- if (client->message->tsigkey != NULL) {
|
|
|
bcb1e2 |
- tsigkey = client->message->tsigkey->key;
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- if (rdata.type != dns_rdatatype_any) {
|
|
|
bcb1e2 |
- if (!dns_ssutable_checkrules(
|
|
|
bcb1e2 |
- ssutable, client->signer, name,
|
|
|
bcb1e2 |
- &netaddr, TCPCLIENT(client), env,
|
|
|
bcb1e2 |
- rdata.type, tsigkey))
|
|
|
bcb1e2 |
- {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "rejected by "
|
|
|
bcb1e2 |
- "secure update");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- } else {
|
|
|
bcb1e2 |
- if (!ssu_checkall(db, ver, name, ssutable,
|
|
|
bcb1e2 |
- client->signer, &netaddr, env,
|
|
|
bcb1e2 |
- TCPCLIENT(client), tsigkey))
|
|
|
bcb1e2 |
- {
|
|
|
bcb1e2 |
- FAILC(DNS_R_REFUSED, "rejected by "
|
|
|
bcb1e2 |
- "secure update");
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
- if (result != ISC_R_NOMORE) {
|
|
|
bcb1e2 |
- FAIL(result);
|
|
|
bcb1e2 |
- }
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
- update_log(client, zone, LOGLEVEL_DEBUG, "update section prescan OK");
|
|
|
bcb1e2 |
-
|
|
|
bcb1e2 |
/*
|
|
|
bcb1e2 |
* Process the Update Section.
|
|
|
bcb1e2 |
*/
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
- options = dns_zone_getoptions(zone);
|
|
|
bcb1e2 |
for (result = dns_message_firstname(request, DNS_SECTION_UPDATE);
|
|
|
bcb1e2 |
result == ISC_R_SUCCESS;
|
|
|
bcb1e2 |
result = dns_message_nextname(request, DNS_SECTION_UPDATE))
|
|
|
bcb1e2 |
@@ -3307,10 +3330,7 @@ update_action(isc_task_t *task, isc_event_t *event) {
|
|
|
bcb1e2 |
if (result == ISC_R_SUCCESS && records > maxrecords) {
|
|
|
bcb1e2 |
update_log(client, zone, ISC_LOG_ERROR,
|
|
|
bcb1e2 |
"records in zone (%" PRIu64 ") "
|
|
|
bcb1e2 |
- "exceeds"
|
|
|
bcb1e2 |
- " max-"
|
|
|
bcb1e2 |
- "records"
|
|
|
bcb1e2 |
- " (%u)",
|
|
|
bcb1e2 |
+ "exceeds max-records (%u)",
|
|
|
bcb1e2 |
records, maxrecords);
|
|
|
bcb1e2 |
result = DNS_R_TOOMANYRECORDS;
|
|
|
bcb1e2 |
goto failure;
|
|
|
bcb1e2 |
@@ -3601,6 +3621,13 @@ send_forward_event(ns_client_t *client, dns_zone_t *zone) {
|
|
|
bcb1e2 |
update_event_t *event = NULL;
|
|
|
bcb1e2 |
isc_task_t *zonetask = NULL;
|
|
|
bcb1e2 |
|
|
|
bcb1e2 |
+ result = checkupdateacl(client, dns_zone_getforwardacl(zone),
|
|
|
bcb1e2 |
+ "update forwarding", dns_zone_getorigin(zone),
|
|
|
bcb1e2 |
+ true, false);
|
|
|
bcb1e2 |
+ if (result != ISC_R_SUCCESS) {
|
|
|
bcb1e2 |
+ return (result);
|
|
|
bcb1e2 |
+ }
|
|
|
bcb1e2 |
+
|
|
|
bcb1e2 |
result = isc_quota_attach(&client->manager->sctx->updquota,
|
|
|
bcb1e2 |
&(isc_quota_t *){ NULL });
|
|
|
bcb1e2 |
if (result != ISC_R_SUCCESS) {
|
|
|
bcb1e2 |
--
|
|
|
bcb1e2 |
2.39.1
|
|
|
bcb1e2 |
|