6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson/*
fccc836ebfeb8e278b528b59304f451c369baf37Tinderbox User * Copyright (C) 1999-2018 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson */
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#include <config.h>
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <isc/buffer.h>
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington#include <isc/file.h>
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson#include <isc/mem.h>
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews#include <isc/print.h>
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉#include <isc/stats.h>
6028d1ce0380d0ba7f6c6ecd1ad20b31ddd1becbDavid Lawrence#include <isc/string.h> /* Required for HP/UX (and others?) */
364a82f7c25b62967678027043425201a5e5171aBob Halley#include <isc/util.h>
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
1a69a1a78cfaa86f3b68bbc965232b7876d4da2aDavid Lawrence#include <dns/acl.h>
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#include <dns/db.h>
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki#include <dns/ipkeylist.h>
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <dns/fixedname.h>
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson#include <dns/log.h>
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <dns/name.h>
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt#include <dns/masterdump.h>
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#include <dns/rdata.h>
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <dns/rdatatype.h>
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#include <dns/rdataset.h>
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#include <dns/rdatalist.h>
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#include <dns/result.h>
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt#include <dns/sdlz.h>
5afa531442369eed0e93a8af14422b30f400bd89Mark Andrews#include <dns/ssu.h>
8907d8fa04fdaa65baf0bc6b01230b2ebde93106Mark Andrews#include <dns/stats.h>
476386968b1f287a695f73c48862e961011af99bMark Andrews#include <dns/view.h>
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson#include <dns/zone.h>
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27Mark Andrews#include <named/client.h>
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <named/config.h>
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson#include <named/globals.h>
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson#include <named/log.h>
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews#include <named/server.h>
9259fed3d8ac5d1efa9b5a647969e40c9c934484Andreas Gustafsson#include <named/zoneconf.h>
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt/* ACLs associated with zone */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunttypedef enum {
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_notify,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_query,
222d38735f97f771054e223b03f84c5858252332Evan Hunt allow_query_on,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_transfer,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_update,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_update_forwarding
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt} acl_type_t;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson#define RETERR(x) do { \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson isc_result_t _r = (x); \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson if (_r != ISC_R_SUCCESS) \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson return (_r); \
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson } while (0)
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt#define CHECK(x) do { \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt result = (x); \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (result != ISC_R_SUCCESS) \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt goto cleanup; \
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt } while (0)
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson * Convenience function for configuring a single zone ACL.
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson */
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafssonstatic isc_result_t
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsconfigure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt const cfg_obj_t *config, acl_type_t acltype,
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater cfg_aclconfctx_t *actx, dns_zone_t *zone,
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson void (*setzacl)(dns_zone_t *, dns_acl_t *),
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson void (*clearzacl)(dns_zone_t *))
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson{
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson isc_result_t result;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt const cfg_obj_t *maps[5] = {NULL, NULL, NULL, NULL, NULL};
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *aclobj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington int i = 0;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt dns_acl_t **aclp = NULL, *acl = NULL;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt const char *aclname;
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater dns_view_t *view;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater view = dns_zone_getview(zone);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt switch (acltype) {
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt case allow_notify:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (view != NULL)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater aclp = &view->notifyacl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclname = "allow-notify";
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt break;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt case allow_query:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (view != NULL)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater aclp = &view->queryacl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclname = "allow-query";
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt break;
222d38735f97f771054e223b03f84c5858252332Evan Hunt case allow_query_on:
222d38735f97f771054e223b03f84c5858252332Evan Hunt if (view != NULL)
222d38735f97f771054e223b03f84c5858252332Evan Hunt aclp = &view->queryonacl;
222d38735f97f771054e223b03f84c5858252332Evan Hunt aclname = "allow-query-on";
222d38735f97f771054e223b03f84c5858252332Evan Hunt break;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt case allow_transfer:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (view != NULL)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater aclp = &view->transferacl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclname = "allow-transfer";
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt break;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt case allow_update:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (view != NULL)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater aclp = &view->updateacl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclname = "allow-update";
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt break;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt case allow_update_forwarding:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater if (view != NULL)
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater aclp = &view->upfwdacl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclname = "allow-update-forwarding";
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt break;
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater default:
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater INSIST(0);
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater return (ISC_R_FAILURE);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt }
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt /* First check to see if ACL is defined within the zone */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt if (zconfig != NULL) {
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt maps[0] = cfg_tuple_get(zconfig, "options");
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews (void)ns_config_get(maps, aclname, &aclobj);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt if (aclobj != NULL) {
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt aclp = NULL;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt goto parse_acl;
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt }
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt }
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt /* Failing that, see if there's a default ACL already in the view */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt if (aclp != NULL && *aclp != NULL) {
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt (*setzacl)(zone, *aclp);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt return (ISC_R_SUCCESS);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt /* Check for default ACLs that haven't been parsed yet */
cfd262045c23cadb8415f0111f56995258f17361Evan Hunt if (vconfig != NULL) {
cfd262045c23cadb8415f0111f56995258f17361Evan Hunt const cfg_obj_t *options = cfg_tuple_get(vconfig, "options");
cfd262045c23cadb8415f0111f56995258f17361Evan Hunt if (options != NULL)
cfd262045c23cadb8415f0111f56995258f17361Evan Hunt maps[i++] = options;
cfd262045c23cadb8415f0111f56995258f17361Evan Hunt }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (config != NULL) {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *options = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington (void)cfg_map_get(config, "options", &options);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (options != NULL)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington maps[i++] = options;
3eef7eaba00e9bd468d8036c709a296a0e5b76f1Andreas Gustafsson }
7b68fa6229f1edadac44c7ec459c9ed77a8368c8Mark Andrews maps[i++] = ns_g_defaults;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington maps[i] = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews (void)ns_config_get(maps, aclname, &aclobj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (aclobj == NULL) {
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson (*clearzacl)(zone);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson return (ISC_R_SUCCESS);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Huntparse_acl:
ad5bc22a819190839bdcc4d102d023782dc23660Mark Andrews result = cfg_acl_fromconfig(aclobj, config, ns_g_lctx, actx,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt dns_zone_getmctx(zone), 0, &acl);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result != ISC_R_SUCCESS)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (result);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt (*setzacl)(zone, acl);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
11156f82bab19b2e7f5d4df6184ae0c99518442fAutomatic Updater /* Set the view default now */
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt if (aclp != NULL)
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt dns_acl_attach(acl, aclp);
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt dns_acl_detach(&acl);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (ISC_R_SUCCESS);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson}
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington * Parse the zone update-policy statement.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtonstatic isc_result_t
351b62535d4c4f89883bfdba025999dd32490266Evan Huntconfigure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
77b8f88f144928eddcca144c348d6ef53e7d5c43Evan Hunt const char *zname)
77b8f88f144928eddcca144c348d6ef53e7d5c43Evan Hunt{
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *updatepolicy = NULL;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_listelt_t *element, *element2;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_ssutable_t *table = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_mem_t *mctx = dns_zone_getmctx(zone);
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater isc_boolean_t autoddns = ISC_FALSE;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_result_t result;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington (void)cfg_map_get(zconfig, "update-policy", &updatepolicy);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt if (updatepolicy == NULL) {
a687a0592bbe3a582860eb5f03725bf80d7ac1d8Mark Andrews dns_zone_setssutable(zone, NULL);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (ISC_R_SUCCESS);
a687a0592bbe3a582860eb5f03725bf80d7ac1d8Mark Andrews }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater if (cfg_obj_isstring(updatepolicy) &&
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater strcmp("local", cfg_obj_asstring(updatepolicy)) == 0) {
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater autoddns = ISC_TRUE;
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater updatepolicy = NULL;
3e12c54de2238dc90bae06a2e083e4976120bad5Automatic Updater }
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = dns_ssutable_create(mctx, &table);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result != ISC_R_SUCCESS)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (result);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington for (element = cfg_list_first(updatepolicy);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington element != NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington element = cfg_list_next(element))
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *stmt = cfg_listelt_value(element);
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *mode = cfg_tuple_get(stmt, "mode");
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *identity = cfg_tuple_get(stmt, "identity");
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews const char *str;
0015ab097438e041197b19b9de2ba48f6bfd1c6cDavid Lawrence isc_boolean_t grant = ISC_FALSE;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt isc_boolean_t usezone = ISC_FALSE;
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews dns_ssumatchtype_t mtype = DNS_SSUMATCHTYPE_NAME;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_fixedname_t fname, fident;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_buffer_t b;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_rdatatype_t *types;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington unsigned int i, n;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington str = cfg_obj_asstring(mode);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (strcasecmp(str, "grant") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington grant = ISC_TRUE;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else if (strcasecmp(str, "deny") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington grant = ISC_FALSE;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(0);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington str = cfg_obj_asstring(matchtype);
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews CHECK(dns_ssu_mtypefromstring(str, &mtype));
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews if (mtype == dns_ssumatchtype_subdomain) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt usezone = ISC_TRUE;
8f1ed05dc0aae7ae6c3da6ec6d405df61257a61eMark Andrews }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_fixedname_init(&fident);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington str = cfg_obj_asstring(identity);
6f7abb89ec22aef5eda40ed60fcf605a42b78d4dMark Andrews isc_buffer_constinit(&b, str, strlen(str));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_buffer_add(&b, strlen(str));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = dns_name_fromtext(dns_fixedname_name(&fident), &b,
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 dns_rootname, 0, NULL);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result != ISC_R_SUCCESS) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington "'%s' is not a valid name", str);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington goto cleanup;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_fixedname_init(&fname);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (usezone) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt result = dns_name_copy(dns_zone_getorigin(zone),
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt dns_fixedname_name(&fname),
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt NULL);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (result != ISC_R_SUCCESS) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt "error copying origin: %s",
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt isc_result_totext(result));
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt goto cleanup;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt }
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt } else {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt str = cfg_obj_asstring(dname);
6f7abb89ec22aef5eda40ed60fcf605a42b78d4dMark Andrews isc_buffer_constinit(&b, str, strlen(str));
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt isc_buffer_add(&b, strlen(str));
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt result = dns_name_fromtext(dns_fixedname_name(&fname),
307d2084502eddc7ce921e5ce439aec3531d90e0Tatuya JINMEI 神明達哉 &b, dns_rootname, 0, NULL);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (result != ISC_R_SUCCESS) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt "'%s' is not a valid name", str);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt goto cleanup;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington n = ns_config_listcount(typelist);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (n == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington types = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington types = isc_mem_get(mctx, n * sizeof(dns_rdatatype_t));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (types == NULL) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ISC_R_NOMEMORY;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington goto cleanup;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington i = 0;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington for (element2 = cfg_list_first(typelist);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington element2 != NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington element2 = cfg_list_next(element2))
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *typeobj;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_textregion_t r;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(i < n);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington typeobj = cfg_listelt_value(element2);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington str = cfg_obj_asstring(typeobj);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews DE_CONST(str, r.base);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington r.length = strlen(str);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = dns_rdatatype_fromtext(&types[i++], &r);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result != ISC_R_SUCCESS) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington cfg_obj_log(identity, ns_g_lctx, ISC_LOG_ERROR,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington "'%s' is not a valid type", str);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_mem_put(mctx, types,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington n * sizeof(dns_rdatatype_t));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington goto cleanup;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(i == n);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = dns_ssutable_addrule(table, grant,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_fixedname_name(&fident),
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington mtype,
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_fixedname_name(&fname),
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington n, types);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (types != NULL)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_mem_put(mctx, types, n * sizeof(dns_rdatatype_t));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result != ISC_R_SUCCESS) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington goto cleanup;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt /*
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt * If "update-policy local;" and a session key exists,
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt * then use the default policy, which is equivalent to:
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt * update-policy { grant <session-keyname> zonesub any; };
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt */
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (autoddns) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt dns_rdatatype_t any = dns_rdatatype_any;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt if (ns_g_server->session_keyname == NULL) {
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt "failed to enable auto DDNS policy "
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt "for zone %s: session key not found",
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt zname);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt result = ISC_R_NOTFOUND;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt goto cleanup;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt }
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt result = dns_ssutable_addrule(table, ISC_TRUE,
08f860f800d32007a0c9bf456f6c35fbb2ecbc81Evan Hunt ns_g_server->session_keyname,
f592d2f76cac7115038124c510d2ba3050334b4dEvan Hunt DNS_SSUMATCHTYPE_LOCAL,
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt dns_zone_getorigin(zone),
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt 1, &any);
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt if (result != ISC_R_SUCCESS)
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt goto cleanup;
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ISC_R_SUCCESS;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_zone_setssutable(zone, table);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington cleanup:
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_ssutable_detach(&table);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (result);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington}
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉/*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * This is the TTL used for internally generated RRsets for static-stub zones.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * The value doesn't matter because the mapping is static, but needs to be
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * defined for the sake of implementation.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉#define STATICSTUB_SERVER_TTL 86400
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉/*%
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Configure an apex NS with glues for a static-stub zone.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * For example, for the zone named "example.com", the following RRs will be
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * added to the zone DB:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * example.com. NS example.com.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * example.com. A 192.0.2.1
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * example.com. AAAA 2001:db8::1
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉static isc_result_t
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉configure_staticstub_serveraddrs(const cfg_obj_t *zconfig, dns_zone_t *zone,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t *rdatalist_ns,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t *rdatalist_a,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t *rdatalist_aaaa)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉{
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const cfg_listelt_t *element;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_mem_t *mctx = dns_zone_getmctx(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_region_t region, sregion;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_t *rdata;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_result_t result = ISC_R_SUCCESS;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 for (element = cfg_list_first(zconfig);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 element != NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 element = cfg_list_next(element))
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const isc_sockaddr_t* sa;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_netaddr_t na;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const cfg_obj_t *address = cfg_listelt_value(element);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t *rdatalist;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 sa = cfg_obj_assockaddr(address);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (isc_sockaddr_getport(sa) != 0) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "port is not configurable for "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "static stub server-addresses");
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_FAILURE);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_netaddr_fromsockaddr(&na, sa);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (isc_netaddr_getzone(&na) != 0) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "scoped address is not allowed "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "for static stub "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "server-addresses");
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_FAILURE);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 switch (na.family) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 case AF_INET:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.length = sizeof(na.type.in);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist = rdatalist_a;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 break;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 default:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 INSIST(na.family == AF_INET6);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.length = sizeof(na.type.in6);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist = rdatalist_aaaa;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 break;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdata = isc_mem_get(mctx, sizeof(*rdata) + region.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (rdata == NULL)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_NOMEMORY);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.base = (unsigned char *)(rdata + 1);
e851ea826066ac5a5b01c2c23218faa0273a12e8Evan Hunt memmove(region.base, &na.type, region.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_init(rdata);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist->type, &region);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * If no address is specified (unlikely in this context, but possible),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * there's nothing to do anymore.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (ISC_LIST_EMPTY(rdatalist_a->rdata) &&
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 ISC_LIST_EMPTY(rdatalist_aaaa->rdata)) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_SUCCESS);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Add to the list an apex NS with the ns name being the origin name */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_toregion(dns_zone_getorigin(zone), &sregion);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdata = isc_mem_get(mctx, sizeof(*rdata) + sregion.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (rdata == NULL) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Already allocated data will be freed in the caller, so
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * we can simply return here.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_NOMEMORY);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.length = sregion.length;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.base = (unsigned char *)(rdata + 1);
e851ea826066ac5a5b01c2c23218faa0273a12e8Evan Hunt memmove(region.base, sregion.base, region.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_init(rdata);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatatype_ns, &region);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 ISC_LIST_APPEND(rdatalist_ns->rdata, rdata, link);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (result);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉}
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉/*%
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Configure an apex NS with an out-of-zone NS names for a static-stub zone.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * For example, for the zone named "example.com", something like the following
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * RRs will be added to the zone DB:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * example.com. NS ns.example.net.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉static isc_result_t
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉configure_staticstub_servernames(const cfg_obj_t *zconfig, dns_zone_t *zone,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t *rdatalist, const char *zname)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉{
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const cfg_listelt_t *element;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_mem_t *mctx = dns_zone_getmctx(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_t *rdata;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_region_t sregion, region;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_result_t result = ISC_R_SUCCESS;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 for (element = cfg_list_first(zconfig);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 element != NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 element = cfg_list_next(element))
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const cfg_obj_t *obj;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const char *str;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_fixedname_t fixed_name;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_t *nsname;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_buffer_t b;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 obj = cfg_listelt_value(element);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 str = cfg_obj_asstring(obj);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_fixedname_init(&fixed_name);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 nsname = dns_fixedname_name(&fixed_name);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
6f7abb89ec22aef5eda40ed60fcf605a42b78d4dMark Andrews isc_buffer_constinit(&b, str, strlen(str));
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_buffer_add(&b, strlen(str));
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_name_fromtext(nsname, &b, dns_rootname, 0, NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "server-name '%s' is not a valid "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "name", str);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (result);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (dns_name_issubdomain(nsname, dns_zone_getorigin(zone))) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 cfg_obj_log(zconfig, ns_g_lctx, ISC_LOG_ERROR,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "server-name '%s' must not be a "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "subdomain of zone name '%s'",
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 str, zname);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_FAILURE);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_toregion(nsname, &sregion);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdata = isc_mem_get(mctx, sizeof(*rdata) + sregion.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (rdata == NULL)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (ISC_R_NOMEMORY);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.length = sregion.length;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 region.base = (unsigned char *)(rdata + 1);
e851ea826066ac5a5b01c2c23218faa0273a12e8Evan Hunt memmove(region.base, sregion.base, region.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_init(rdata);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatatype_ns, &region);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (result);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉}
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉/*%
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Configure static-stub zone.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉static isc_result_t
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉configure_staticstub(const cfg_obj_t *zconfig, dns_zone_t *zone,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const char *zname, const char *dbtype)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉{
0ccd663a8377dd5accc5121f5938a81a98ed8960Automatic Updater int i = 0;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 const cfg_obj_t *obj;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_mem_t *mctx = dns_zone_getmctx(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_db_t *db = NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_dbversion_t *dbversion = NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_dbnode_t *apexnode = NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_t apexname;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_result_t result;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdataset_t rdataset;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t rdatalist_ns, rdatalist_a, rdatalist_aaaa;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_t* rdatalists[] = {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdatalist_ns, &rdatalist_a, &rdatalist_aaaa, NULL
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 };
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_t *rdata;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_region_t region;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Create the DB beforehand */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 RETERR(dns_db_create(mctx, dbtype, dns_zone_getorigin(zone),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_dbtype_stub, dns_zone_getclass(zone),
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 0, NULL, &db));
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_zone_setdb(zone, db);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_init(&rdatalist_ns);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_ns.rdclass = dns_zone_getclass(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_ns.type = dns_rdatatype_ns;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_ns.ttl = STATICSTUB_SERVER_TTL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_init(&rdatalist_a);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_a.rdclass = dns_zone_getclass(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_a.type = dns_rdatatype_a;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_a.ttl = STATICSTUB_SERVER_TTL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdatalist_init(&rdatalist_aaaa);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_aaaa.rdclass = dns_zone_getclass(zone);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_aaaa.type = dns_rdatatype_aaaa;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 rdatalist_aaaa.ttl = STATICSTUB_SERVER_TTL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Prepare zone RRs from the configuration */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 obj = NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = cfg_map_get(zconfig, "server-addresses", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews if (result == ISC_R_SUCCESS) {
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(obj != NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = configure_staticstub_serveraddrs(obj, zone,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdatalist_ns,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdatalist_a,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdatalist_aaaa);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 obj = NULL;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = cfg_map_get(zconfig, "server-names", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews if (result == ISC_R_SUCCESS) {
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(obj != NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = configure_staticstub_servernames(obj, zone,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdatalist_ns,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 zname);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Sanity check: there should be at least one NS RR at the zone apex
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * to trigger delegation.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (ISC_LIST_EMPTY(rdatalist_ns.rdata)) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "No NS record is configured for a "
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 "static-stub zone '%s'", zname);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = ISC_R_FAILURE;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * Now add NS and glue A/AAAA RRsets to the zone DB.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * First open a new version for the add operation and get a pointer
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * to the apex node (all RRs are of the apex name).
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_db_newversion(db, &dbversion);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_init(&apexname, NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_name_clone(dns_zone_getorigin(zone), &apexname);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_db_findnode(db, &apexname, ISC_FALSE, &apexnode);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Add NS RRset */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdataset_init(&rdataset);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 RUNTIME_CHECK(dns_rdatalist_tordataset(&rdatalist_ns, &rdataset)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 == ISC_R_SUCCESS);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_db_addrdataset(db, apexnode, dbversion, 0, &rdataset,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 0, NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdataset_disassociate(&rdataset);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Add glue A RRset, if any */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (!ISC_LIST_EMPTY(rdatalist_a.rdata)) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 RUNTIME_CHECK(dns_rdatalist_tordataset(&rdatalist_a, &rdataset)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 == ISC_R_SUCCESS);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_db_addrdataset(db, apexnode, dbversion, 0,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdataset, 0, NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdataset_disassociate(&rdataset);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /* Add glue AAAA RRset, if any */
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (!ISC_LIST_EMPTY(rdatalist_aaaa.rdata)) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 RUNTIME_CHECK(dns_rdatalist_tordataset(&rdatalist_aaaa,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdataset)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 == ISC_R_SUCCESS);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = dns_db_addrdataset(db, apexnode, dbversion, 0,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 &rdataset, 0, NULL);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdataset_disassociate(&rdataset);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (result != ISC_R_SUCCESS)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 goto cleanup;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 result = ISC_R_SUCCESS;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 cleanup:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (apexnode != NULL)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_db_detachnode(db, &apexnode);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (dbversion != NULL)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_db_closeversion(db, &dbversion, ISC_TRUE);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 if (db != NULL)
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_db_detach(&db);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 for (i = 0; rdatalists[i] != NULL; i++) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 while ((rdata = ISC_LIST_HEAD(rdatalists[i]->rdata)) != NULL) {
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 ISC_LIST_UNLINK(rdatalists[i]->rdata, rdata, link);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 dns_rdata_toregion(rdata, &region);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 isc_mem_put(mctx, rdata,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 sizeof(*rdata) + region.length);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 }
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
9c0589bc8b1401e02c9b557737cb756e86b094ffMark Andrews INSIST(dbversion == NULL);
9c0589bc8b1401e02c9b557737cb756e86b094ffMark Andrews
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 return (result);
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉}
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington * Convert a config file zone type into a server zone type.
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellingtonstatic inline dns_zonetype_t
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewszonetype_fromconfig(const cfg_obj_t *map) {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_result_t result;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = cfg_map_get(map, "type", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington return (ns_config_getzonetype(obj));
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson}
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * Helper function for strtoargv(). Pardon the gratuitous recursion.
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson */
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafssonstatic isc_result_t
d5e72d5dba7b77ae0036c53578bcabcf3af1f4b7Andreas Gustafssonstrtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp,
d5e72d5dba7b77ae0036c53578bcabcf3af1f4b7Andreas Gustafsson char ***argvp, unsigned int n)
d5e72d5dba7b77ae0036c53578bcabcf3af1f4b7Andreas Gustafsson{
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson isc_result_t result;
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson /* Discard leading whitespace. */
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson while (*s == ' ' || *s == '\t')
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson s++;
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson if (*s == '\0') {
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson /* We have reached the end of the string. */
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson *argcp = n;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson *argvp = isc_mem_get(mctx, n * sizeof(char *));
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson if (*argvp == NULL)
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson return (ISC_R_NOMEMORY);
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson } else {
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson char *p = s;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson while (*p != ' ' && *p != '\t' && *p != '\0')
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson p++;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson if (*p != '\0')
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson *p++ = '\0';
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson if (result != ISC_R_SUCCESS)
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson return (result);
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson (*argvp)[n] = s;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson }
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson return (ISC_R_SUCCESS);
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson}
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * Tokenize the string "s" into whitespace-separated words,
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * return the number of words in '*argcp' and an array
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * of pointers to the words in '*argvp'. The caller
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * must free the array using isc_mem_put(). The string
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson * is modified in-place.
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson */
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafssonstatic isc_result_t
d5e72d5dba7b77ae0036c53578bcabcf3af1f4b7Andreas Gustafssonstrtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson return (strtoargvsub(mctx, s, argcp, argvp, 0));
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson}
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrewsstatic void
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewschecknames(dns_zonetype_t ztype, const cfg_obj_t **maps,
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t **objp)
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews{
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews const char *zone = NULL;
1cf54d1966b3de8f6593e9e80eae9a80a1c011adMark Andrews isc_result_t result;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews switch (ztype) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews case dns_zone_slave: zone = "slave"; break;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews case dns_zone_master: zone = "master"; break;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews default:
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews INSIST(0);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews }
1cf54d1966b3de8f6593e9e80eae9a80a1c011adMark Andrews result = ns_checknames_get(maps, zone, objp);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && objp != NULL && *objp != NULL);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews}
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graffisc_result_t
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *zconfig, cfg_aclconfctx_t *ac,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_t *zone, dns_zone_t *raw)
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson{
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson isc_result_t result;
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews const char *zname;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_rdataclass_t zclass;
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews dns_rdataclass_t vclass;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *maps[5];
7829fad4093f2c1985b1efb7cea00287ff015d2bckb const cfg_obj_t *nodefault[4];
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *zoptions = NULL;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *options = NULL;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *obj;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson const char *filename = NULL;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb const char *dupcheck;
0015ab097438e041197b19b9de2ba48f6bfd1c6cDavid Lawrence dns_notifytype_t notifytype = dns_notifytype_yes;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington isc_uint32_t count;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson unsigned int dbargc;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson char **dbargv;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson static char default_dbtype[] = "rbt";
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt static char dlz_dbtype[] = "dlz";
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt char *cpval = default_dbtype;
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson isc_mem_t *mctx = dns_zone_getmctx(zone);
8dd4cf7fc6c025c547a473de5df7a72939d0cb2aDavid Lawrence dns_dialuptype_t dialup = dns_dialuptype_no;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_zonetype_t ztype;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington int i;
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews isc_int32_t journal_size;
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews isc_boolean_t multi;
476386968b1f287a695f73c48862e961011af99bMark Andrews isc_boolean_t alt;
476386968b1f287a695f73c48862e961011af99bMark Andrews dns_view_t *view;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews isc_boolean_t check = ISC_FALSE, fail = ISC_FALSE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews isc_boolean_t warn = ISC_FALSE, ignore = ISC_FALSE;
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews isc_boolean_t ixfrdiff;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews dns_masterformat_t masterformat;
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt const dns_master_style_t *masterstyle = &dns_master_style_default;
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉 isc_stats_t *zoneqrystats;
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb dns_stats_t *rcvquerystats;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt dns_zonestat_level_t statlevel;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews int seconds;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_t *mayberaw = (raw != NULL) ? raw : zone;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt isc_dscp_t dscp;
b4dfb4747498ab22831a30c44607e81082fef962Michael Graff
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington i = 0;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (zconfig != NULL) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington zoptions = cfg_tuple_get(zconfig, "options");
7829fad4093f2c1985b1efb7cea00287ff015d2bckb nodefault[i] = maps[i] = zoptions;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb i++;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb }
7829fad4093f2c1985b1efb7cea00287ff015d2bckb if (vconfig != NULL) {
7829fad4093f2c1985b1efb7cea00287ff015d2bckb nodefault[i] = maps[i] = cfg_tuple_get(vconfig, "options");
7829fad4093f2c1985b1efb7cea00287ff015d2bckb i++;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (config != NULL) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington (void)cfg_map_get(config, "options", &options);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb if (options != NULL) {
7829fad4093f2c1985b1efb7cea00287ff015d2bckb nodefault[i] = maps[i] = options;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb i++;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb }
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
7829fad4093f2c1985b1efb7cea00287ff015d2bckb nodefault[i] = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington maps[i++] = ns_g_defaults;
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews maps[i] = NULL;
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews if (vconfig != NULL)
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews RETERR(ns_config_getclass(cfg_tuple_get(vconfig, "class"),
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews dns_rdataclass_in, &vclass));
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews else
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews vclass = dns_rdataclass_in;
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson /*
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * Configure values common to all zone types.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews RETERR(ns_config_getclass(cfg_tuple_get(zconfig, "class"),
de9833be77ef92c17b35c02d138a0ad8df34dd91Mark Andrews vclass, &zclass));
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dns_zone_setclass(zone, zclass);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setclass(raw, zclass);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington ztype = zonetype_fromconfig(zoptions);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_settype(raw, ztype);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_settype(zone, dns_zone_master);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews } else
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_settype(zone, ztype);
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = cfg_map_get(zoptions, "database", &obj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result == ISC_R_SUCCESS)
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews if (cpval == NULL)
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews return(ISC_R_NOMEMORY);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt obj = NULL;
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt result = cfg_map_get(zoptions, "dlz", &obj);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt if (result == ISC_R_SUCCESS) {
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt const char *dlzname = cfg_obj_asstring(obj);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt size_t len;
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt if (cpval != default_dbtype) {
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt "zone '%s': both 'database' and 'dlz' "
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt "specified", zname);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt return (ISC_R_FAILURE);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt }
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt len = strlen(dlzname) + 5;
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt cpval = isc_mem_allocate(mctx, len);
fe51e068f0892ae9258d9fd0e14fe2a469ff8edfMark Andrews if (cpval == NULL)
fe51e068f0892ae9258d9fd0e14fe2a469ff8edfMark Andrews return (ISC_R_NOMEMORY);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt snprintf(cpval, len, "dlz %s", dlzname);
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt }
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews result = strtoargv(mctx, cpval, &dbargc, &dbargv);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews if (result != ISC_R_SUCCESS && cpval != default_dbtype) {
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews isc_mem_free(mctx, cpval);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews return (result);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews }
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews /*
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews * ANSI C is strange here. There is no logical reason why (char **)
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews * cannot be promoted automatically to (const char * const *) by the
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews * compiler w/o generating a warning.
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews */
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews result = dns_zone_setdbtype(zone, dbargc, (const char * const *)dbargv);
886b96ebfd555cfeaf37ae46fc08421a41c61392Andreas Gustafsson isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
2b8bed6681d1541474f022586cbe728dfce36880Evan Hunt if (cpval != default_dbtype && cpval != dlz_dbtype)
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews isc_mem_free(mctx, cpval);
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews if (result != ISC_R_SUCCESS)
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews return (result);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = cfg_map_get(zoptions, "file", &obj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (result == ISC_R_SUCCESS)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington filename = cfg_obj_asstring(obj);
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt /*
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt * Unless we're using some alternative database, a master zone
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt * will be needing a master file.
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt */
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews if (ztype == dns_zone_master && cpval == default_dbtype &&
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews filename == NULL) {
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews "zone '%s': 'file' not specified",
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews zname);
c75523bcb30c2b8426ee7cb226d9b429c337325bMark Andrews return (ISC_R_FAILURE);
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt }
86dcc4005887f91d23d970d4574a8f6afa7e28d2Evan Hunt
9570ddcd41e2b0a0e124f0fa50653f73dfc1ef46Evan Hunt if (ztype == dns_zone_slave)
9570ddcd41e2b0a0e124f0fa50653f73dfc1ef46Evan Hunt masterformat = dns_masterformat_raw;
9570ddcd41e2b0a0e124f0fa50653f73dfc1ef46Evan Hunt else
9570ddcd41e2b0a0e124f0fa50653f73dfc1ef46Evan Hunt masterformat = dns_masterformat_text;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews obj = NULL;
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt result = ns_config_get(maps, "masterfile-format", &obj);
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews if (result == ISC_R_SUCCESS) {
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews const char *masterformatstr = cfg_obj_asstring(obj);
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews if (strcasecmp(masterformatstr, "text") == 0)
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews masterformat = dns_masterformat_text;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews else if (strcasecmp(masterformatstr, "raw") == 0)
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews masterformat = dns_masterformat_raw;
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt else if (strcasecmp(masterformatstr, "map") == 0)
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt masterformat = dns_masterformat_map;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews else
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews INSIST(0);
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt obj = NULL;
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt result = ns_config_get(maps, "masterfile-style", &obj);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt if (result == ISC_R_SUCCESS) {
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt const char *masterstylestr = cfg_obj_asstring(obj);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt if (masterformat != dns_masterformat_text) {
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt cfg_obj_log(obj, ns_g_lctx, ISC_LOG_ERROR,
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt "zone '%s': 'masterfile-style' "
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt "can only be used with "
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt "'masterfile-format text'", zname);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt return (ISC_R_FAILURE);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt }
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt if (strcasecmp(masterstylestr, "full") == 0)
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt masterstyle = &dns_master_style_full;
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt else if (strcasecmp(masterstylestr, "relative") == 0)
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt masterstyle = &dns_master_style_default;
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt else
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt INSIST(0);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt }
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt obj = NULL;
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt result = ns_config_get(maps, "max-zone-ttl", &obj);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt if (result == ISC_R_SUCCESS && masterformat == dns_masterformat_map) {
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt "zone '%s': 'max-zone-ttl' is not compatible "
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt "with 'masterfile-format map'", zname);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt return (ISC_R_FAILURE);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt } else if (result == ISC_R_SUCCESS) {
4ca7391e640bd4f0abb31508019d3bd62819fa8eMark Andrews dns_ttl_t maxttl = 0; /* unlimited */
4ca7391e640bd4f0abb31508019d3bd62819fa8eMark Andrews
4ca7391e640bd4f0abb31508019d3bd62819fa8eMark Andrews if (cfg_obj_isuint32(obj))
4ca7391e640bd4f0abb31508019d3bd62819fa8eMark Andrews maxttl = cfg_obj_asuint32(obj);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt dns_zone_setmaxttl(zone, maxttl);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt if (raw != NULL)
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt dns_zone_setmaxttl(raw, maxttl);
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt }
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews obj = NULL;
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews result = ns_config_get(maps, "max-records", &obj);
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews dns_zone_setmaxrecords(mayberaw, cfg_obj_asuint32(obj));
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews if (zone != mayberaw)
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews dns_zone_setmaxrecords(zone, 0);
744c1db6352c4c3f11c8538e4a2a57c8b0e0d570Mark Andrews
41bbb34bc20f189af62e7047ce42822615417f15Evan Hunt if (raw != NULL && filename != NULL) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews#define SIGNED ".signed"
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews size_t signedlen = strlen(filename) + sizeof(SIGNED);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews char *signedname;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt RETERR(dns_zone_setfile3(raw, filename,
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt masterformat, masterstyle));
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews signedname = isc_mem_get(mctx, signedlen);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (signedname == NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews return (ISC_R_NOMEMORY);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews (void)snprintf(signedname, signedlen, "%s" SIGNED, filename);
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt result = dns_zone_setfile3(zone, signedname,
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt dns_masterformat_raw, NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews isc_mem_put(mctx, signedname, signedlen);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (result != ISC_R_SUCCESS)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews return (result);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews } else
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt RETERR(dns_zone_setfile3(zone, filename,
ec3b216506b715f10e0b653afc20068ce8c5aa79Evan Hunt masterformat, masterstyle));
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
207f0a15bb486d8dc27cf5ff963fac6068ee2972Mark Andrews obj = NULL;
207f0a15bb486d8dc27cf5ff963fac6068ee2972Mark Andrews result = cfg_map_get(zoptions, "journal", &obj);
207f0a15bb486d8dc27cf5ff963fac6068ee2972Mark Andrews if (result == ISC_R_SUCCESS)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(dns_zone_setjournal(mayberaw, cfg_obj_asstring(obj)));
207f0a15bb486d8dc27cf5ff963fac6068ee2972Mark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews /*
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews * Notify messages are processed by the raw zone if it exists.
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (ztype == dns_zone_slave)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington RETERR(configure_zone_acl(zconfig, vconfig, config,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews allow_notify, ac, mayberaw,
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews dns_zone_setnotifyacl,
8249eee42adc8c9c06c6ff9aaecc7437e259c687Mark Andrews dns_zone_clearnotifyacl));
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson /*
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * XXXAG This probably does not make sense for stubs.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington RETERR(configure_zone_acl(zconfig, vconfig, config,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_query, ac, zone,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_setqueryacl,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_clearqueryacl));
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson
222d38735f97f771054e223b03f84c5858252332Evan Hunt RETERR(configure_zone_acl(zconfig, vconfig, config,
222d38735f97f771054e223b03f84c5858252332Evan Hunt allow_query_on, ac, zone,
222d38735f97f771054e223b03f84c5858252332Evan Hunt dns_zone_setqueryonacl,
222d38735f97f771054e223b03f84c5858252332Evan Hunt dns_zone_clearqueryonacl));
222d38735f97f771054e223b03f84c5858252332Evan Hunt
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "dialup", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (cfg_obj_isboolean(obj)) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (cfg_obj_asboolean(obj))
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_yes;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_no;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington } else {
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews const char *dialupstr = cfg_obj_asstring(obj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (strcasecmp(dialupstr, "notify") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_notify;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else if (strcasecmp(dialupstr, "notify-passive") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_notifypassive;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else if (strcasecmp(dialupstr, "refresh") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_refresh;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else if (strcasecmp(dialupstr, "passive") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington dialup = dns_dialuptype_passive;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(0);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setdialup(raw, dialup);
dcd12febbd47f5846d6c75f6a4dcba8a873bc153Andreas Gustafsson dns_zone_setdialup(zone, dialup);
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "zone-statistics", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt if (cfg_obj_isboolean(obj)) {
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt if (cfg_obj_asboolean(obj))
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt statlevel = dns_zonestat_full;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt else
85f89d58a50a86859c04069ea87b2b23b3325d11Evan Hunt statlevel = dns_zonestat_none;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt } else {
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt const char *levelstr = cfg_obj_asstring(obj);
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt if (strcasecmp(levelstr, "full") == 0)
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt statlevel = dns_zonestat_full;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt else if (strcasecmp(levelstr, "terse") == 0)
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt statlevel = dns_zonestat_terse;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt else if (strcasecmp(levelstr, "none") == 0)
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt statlevel = dns_zonestat_none;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt else
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt INSIST(0);
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt }
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt dns_zone_setstatlevel(zone, statlevel);
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb zoneqrystats = NULL;
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb rcvquerystats = NULL;
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt if (statlevel == dns_zonestat_full) {
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉 RETERR(isc_stats_create(mctx, &zoneqrystats,
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉 dns_nsstatscounter_max));
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb RETERR(dns_rdatatypestats_create(mctx,
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb &rcvquerystats));
8907d8fa04fdaa65baf0bc6b01230b2ebde93106Mark Andrews }
40a7e85f3ee3bd66a8f87bf8af674e1e48b05396Evan Hunt dns_zone_setrequeststats(zone, zoneqrystats);
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb dns_zone_setrcvquerystats(zone, rcvquerystats);
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb
8907d8fa04fdaa65baf0bc6b01230b2ebde93106Mark Andrews if (zoneqrystats != NULL)
d9059b0c38bd630c367d81424d72b1308cd74b04Tatuya JINMEI 神明達哉 isc_stats_detach(&zoneqrystats);
a3a11c4f3fc9ba972802b811c4d95a9884d6ff4aMichael Sawyer
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb if(rcvquerystats != NULL)
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb dns_stats_detach(&rcvquerystats);
aecadaf3b1bbbe0bd58f703989baf38eedd0ffcackb
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson /*
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * Configure master functionality. This applies
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * to primary masters (type "master") and slaves
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * acting as masters (type "slave"), but not to stubs.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews if (ztype != dns_zone_stub && ztype != dns_zone_staticstub &&
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews ztype != dns_zone_redirect) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "notify", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (cfg_obj_isboolean(obj)) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (cfg_obj_asboolean(obj))
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington notifytype = dns_notifytype_yes;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington notifytype = dns_notifytype_no;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington } else {
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews const char *notifystr = cfg_obj_asstring(obj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (strcasecmp(notifystr, "explicit") == 0)
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington notifytype = dns_notifytype_explicit;
3b1fce680f1dbe9467cd3b0ab3138ea52d5a976fMark Andrews else if (strcasecmp(notifystr, "master-only") == 0)
3b1fce680f1dbe9467cd3b0ab3138ea52d5a976fMark Andrews notifytype = dns_notifytype_masteronly;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington else
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington INSIST(0);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setnotifytype(raw, dns_notifytype_no);
ef653fbdb122e9e251bdfbdd4609d03a208bb79dMichael Graff dns_zone_setnotifytype(zone, notifytype);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "also-notify", &obj);
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt if (result == ISC_R_SUCCESS &&
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt (notifytype == dns_notifytype_yes ||
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt notifytype == dns_notifytype_explicit ||
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt (notifytype == dns_notifytype_masteronly &&
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt ztype == dns_zone_master)))
e45d0508c3460db87afb1f743bc5210522721bb3Evan Hunt {
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki dns_ipkeylist_t ipkl;
4681ab1fc2c40e1d70fae38e64630c72c51c300eWitold Krecicki dns_ipkeylist_init(&ipkl);
4681ab1fc2c40e1d70fae38e64630c72c51c300eWitold Krecicki
ac21f918f23ce95fd5be807428ee9e2c42319878Evan Hunt RETERR(ns_config_getipandkeylist(config, obj, mctx,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki &ipkl));
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki result = dns_zone_setalsonotifydscpkeys(zone,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.addrs,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.dscps,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.keys,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.count);
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki dns_ipkeylist_clear(mctx, &ipkl);
ac21f918f23ce95fd5be807428ee9e2c42319878Evan Hunt RETERR(result);
7e0d7323d73f31ceb678879ad3aca873dc382483Brian Wellington } else
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson RETERR(dns_zone_setalsonotify(zone, NULL, 0));
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "notify-source", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson RETERR(dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setnotifysrc4dscp(zone, dscp));
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
dfd7798d8b870abf03795d8095297a4b982ab6e9Mark Andrews
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "notify-source-v6", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
1f1d36a87b65186d9f89aac7f456ab1fd2a39ef6Andreas Gustafsson RETERR(dns_zone_setnotifysrc6(zone, cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setnotifysrc6dscp(zone, dscp));
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
dfd7798d8b870abf03795d8095297a4b982ab6e9Mark Andrews
ca84283333d22c64abfbcb87872dd5e6d9172c5aMark Andrews obj = NULL;
ca84283333d22c64abfbcb87872dd5e6d9172c5aMark Andrews result = ns_config_get(maps, "notify-to-soa", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
ca84283333d22c64abfbcb87872dd5e6d9172c5aMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_NOTIFYTOSOA,
ca84283333d22c64abfbcb87872dd5e6d9172c5aMark Andrews cfg_obj_asboolean(obj));
ca84283333d22c64abfbcb87872dd5e6d9172c5aMark Andrews
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27Mark Andrews dns_zone_setisself(zone, ns_client_isself, NULL);
3aca8e5bf3740bbcc3bb13dde242d7cc369abb27Mark Andrews
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington RETERR(configure_zone_acl(zconfig, vconfig, config,
5a17fe2916ce37793c12b243ab08c16095a59cf7Evan Hunt allow_transfer, ac, zone,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_setxfracl,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_clearxfracl));
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-transfer-time-out", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
17dba29ba5db791976e505114baee53a1dde88aaBrian Wellington dns_zone_setmaxxfrout(zone, cfg_obj_asuint32(obj) * 60);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-transfer-idle-out", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
17dba29ba5db791976e505114baee53a1dde88aaBrian Wellington dns_zone_setidleout(zone, cfg_obj_asuint32(obj) * 60);
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews obj = NULL;
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews result = ns_config_get(maps, "max-journal-size", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setjournalsize(raw, -1);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson dns_zone_setjournalsize(zone, -1);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson if (cfg_obj_isstring(obj)) {
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson const char *str = cfg_obj_asstring(obj);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson INSIST(strcasecmp(str, "unlimited") == 0);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson journal_size = ISC_UINT32_MAX / 2;
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson } else {
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson isc_resourcevalue_t value;
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson value = cfg_obj_asuint64(obj);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson if (value > ISC_UINT32_MAX / 2) {
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson cfg_obj_log(obj, ns_g_lctx,
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson ISC_LOG_ERROR,
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson "'max-journal-size "
76d9120dd696209fa1186ea289ea01cd4677782fAndreas Gustafsson "%" ISC_PRINT_QUADFORMAT "d' "
76d9120dd696209fa1186ea289ea01cd4677782fAndreas Gustafsson "is too large",
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson value);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson RETERR(ISC_R_RANGE);
cc0a5f714231709409b9e1b85f0f97ae50854451Mark Andrews }
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson journal_size = (isc_uint32_t)value;
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setjournalsize(raw, journal_size);
687b7ef9989c9ab9040f4ccb5f1816b96fa4e43fAndreas Gustafsson dns_zone_setjournalsize(zone, journal_size);
8cccaeaee13993c49009d3915806c1d0bd03743bAndreas Gustafsson
8cccaeaee13993c49009d3915806c1d0bd03743bAndreas Gustafsson obj = NULL;
8cccaeaee13993c49009d3915806c1d0bd03743bAndreas Gustafsson result = ns_config_get(maps, "ixfr-from-differences", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews if (cfg_obj_isboolean(obj))
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ixfrdiff = cfg_obj_asboolean(obj);
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews else if (!strcasecmp(cfg_obj_asstring(obj), "master") &&
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ztype == dns_zone_master)
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ixfrdiff = ISC_TRUE;
2d96b63d311a5252c8583eb30a56b1fc58172419Mark Andrews else if (!strcasecmp(cfg_obj_asstring(obj), "slave") &&
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ztype == dns_zone_slave)
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ixfrdiff = ISC_TRUE;
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews else
1672cff96d0b02badab6f94524e10285dde851fcMark Andrews ixfrdiff = ISC_FALSE;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(raw, DNS_ZONEOPT_IXFRFROMDIFFS,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ISC_TRUE);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS,
1864400107f7dc21e1797d602ab1f8523f599df9Mark Andrews ISC_TRUE);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews } else
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ixfrdiff);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews obj = NULL;
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews result = ns_config_get(maps, "request-expire", &obj);
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews INSIST(result == ISC_R_SUCCESS);
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews dns_zone_setrequestexpire(zone, cfg_obj_asboolean(obj));
43b9737b11f4f14b2d378746d0cd5561b1dc24a0Mark Andrews
fad5116b3d68e825d29f87a1d3cb41409f42e8f5Scott Mann obj = NULL;
fad5116b3d68e825d29f87a1d3cb41409f42e8f5Scott Mann result = ns_config_get(maps, "request-ixfr", &obj);
fad5116b3d68e825d29f87a1d3cb41409f42e8f5Scott Mann INSIST(result == ISC_R_SUCCESS);
fad5116b3d68e825d29f87a1d3cb41409f42e8f5Scott Mann dns_zone_setrequestixfr(zone, cfg_obj_asboolean(obj));
fad5116b3d68e825d29f87a1d3cb41409f42e8f5Scott Mann
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews checknames(ztype, maps, &obj);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews INSIST(obj != NULL);
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews fail = ISC_FALSE;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews check = ISC_TRUE;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews fail = check = ISC_TRUE;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews fail = check = ISC_FALSE;
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews } else
2047977ce2dfcfe3a0fa2d638c3242841310fad3Mark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (raw != NULL) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMES,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews check);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMESFAIL,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews fail);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ISC_FALSE);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ISC_FALSE);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews } else {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews check);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews fail);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews }
48f929d315bafeeffe0a37082ab4c9661a928c39Mark Andrews
48f929d315bafeeffe0a37082ab4c9661a928c39Mark Andrews obj = NULL;
48f929d315bafeeffe0a37082ab4c9661a928c39Mark Andrews result = ns_config_get(maps, "notify-delay", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
48f929d315bafeeffe0a37082ab4c9661a928c39Mark Andrews dns_zone_setnotifydelay(zone, cfg_obj_asuint32(obj));
48f929d315bafeeffe0a37082ab4c9661a928c39Mark Andrews
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews obj = NULL;
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews result = ns_config_get(maps, "check-sibling", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSIBLING,
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews cfg_obj_asboolean(obj));
a1bc94109313bf4ebb6e6ff655d71d45582d2e43Mark Andrews
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews obj = NULL;
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews result = ns_config_get(maps, "check-spf", &obj);
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews check = ISC_TRUE;
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews check = ISC_FALSE;
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews } else
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews INSIST(0);
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSPF, check);
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews
a1bc94109313bf4ebb6e6ff655d71d45582d2e43Mark Andrews obj = NULL;
a1bc94109313bf4ebb6e6ff655d71d45582d2e43Mark Andrews result = ns_config_get(maps, "zero-no-soa-ttl", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
a1bc94109313bf4ebb6e6ff655d71d45582d2e43Mark Andrews dns_zone_setzeronosoattl(zone, cfg_obj_asboolean(obj));
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews obj = NULL;
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews result = ns_config_get(maps, "nsec3-test-zone", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_NSEC3TESTZONE,
6098d364b690cb9dabf96e9664c4689c8559bd2eMark Andrews cfg_obj_asboolean(obj));
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews } else if (ztype == dns_zone_redirect) {
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews dns_zone_setnotifytype(zone, dns_notifytype_no);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews obj = NULL;
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews result = ns_config_get(maps, "max-journal-size", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews dns_zone_setjournalsize(zone, -1);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews if (cfg_obj_isstring(obj)) {
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews const char *str = cfg_obj_asstring(obj);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews INSIST(strcasecmp(str, "unlimited") == 0);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews journal_size = ISC_UINT32_MAX / 2;
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews } else {
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews isc_resourcevalue_t value;
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews value = cfg_obj_asuint64(obj);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews if (value > ISC_UINT32_MAX / 2) {
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews cfg_obj_log(obj, ns_g_lctx,
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews ISC_LOG_ERROR,
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews "'max-journal-size "
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews "%" ISC_PRINT_QUADFORMAT "d' "
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews "is too large",
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews value);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews RETERR(ISC_R_RANGE);
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews }
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews journal_size = (isc_uint32_t)value;
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews }
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews dns_zone_setjournalsize(zone, journal_size);
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson }
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson /*
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * Configure update-related options. These apply to
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * primary masters only.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (ztype == dns_zone_master) {
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson dns_acl_t *updateacl;
351b62535d4c4f89883bfdba025999dd32490266Evan Hunt
80dd46d7aab16c42a8c1acf6156c95406a9f20a4Mark Andrews RETERR(configure_zone_acl(zconfig, vconfig, config,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews allow_update, ac, mayberaw,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_setupdateacl,
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson dns_zone_clearupdateacl));
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews updateacl = dns_zone_getupdateacl(mayberaw);
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson if (updateacl != NULL && dns_acl_isinsecure(updateacl))
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson isc_log_write(ns_g_lctx, DNS_LOGCATEGORY_SECURITY,
9c566a852f31c3a5d0b9d6eaf11463114339c01dAndreas Gustafsson NS_LOGMODULE_SERVER, ISC_LOG_WARNING,
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews "zone '%s' allows unsigned updates "
f1e3dd087b7ce34382df8354efddaae79caa11b7Mark Andrews "from remote hosts, which is insecure",
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington zname);
2f012d936b5ccdf6520c96a4de23721dc58a2221Automatic Updater
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(configure_zone_ssutable(zoptions, mayberaw, zname));
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (ztype == dns_zone_master || raw != NULL) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews isc_boolean_t allow = ISC_FALSE, maint = ISC_FALSE;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "sig-validity-interval", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews {
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews const cfg_obj_t *validity, *resign;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews validity = cfg_tuple_get(obj, "validity");
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews seconds = cfg_obj_asuint32(validity) * 86400;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setsigvalidityinterval(zone, seconds);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews resign = cfg_tuple_get(obj, "re-sign");
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews if (cfg_obj_isvoid(resign)) {
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews seconds /= 4;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews } else {
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews if (seconds > 7 * 86400)
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews seconds = cfg_obj_asuint32(resign) *
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews 86400;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews else
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews seconds = cfg_obj_asuint32(resign) *
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews 3600;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews }
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setsigresigninginterval(zone, seconds);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews }
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington obj = NULL;
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington result = ns_config_get(maps, "key-directory", &obj);
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington if (result == ISC_R_SUCCESS) {
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington filename = cfg_obj_asstring(obj);
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington RETERR(dns_zone_setkeydirectory(zone, filename));
a5c077e40c784cf9e25c95a1ab94db2faab04ae9Brian Wellington }
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews obj = NULL;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews result = ns_config_get(maps, "sig-signing-signatures", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setsignatures(zone, cfg_obj_asuint32(obj));
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews obj = NULL;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews result = ns_config_get(maps, "sig-signing-nodes", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setnodes(zone, cfg_obj_asuint32(obj));
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews obj = NULL;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews result = ns_config_get(maps, "sig-signing-type", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setprivatetype(zone, cfg_obj_asuint32(obj));
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews obj = NULL;
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews result = ns_config_get(maps, "update-check-ksk", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_setoption(zone, DNS_ZONEOPT_UPDATECHECKKSK,
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews cfg_obj_asboolean(obj));
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3727725bb7d63605b68a644060857013d563b67fEvan Hunt obj = NULL;
8e4f3f1cbceef520ba889270c993de0ac376a2a7Evan Hunt result = ns_config_get(maps, "dnssec-dnskey-kskonly", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
3727725bb7d63605b68a644060857013d563b67fEvan Hunt dns_zone_setoption(zone, DNS_ZONEOPT_DNSKEYKSKONLY,
3727725bb7d63605b68a644060857013d563b67fEvan Hunt cfg_obj_asboolean(obj));
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt obj = NULL;
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt result = ns_config_get(maps, "dnssec-loadkeys-interval", &obj);
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt INSIST(result == ISC_R_SUCCESS && obj != NULL);
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt RETERR(dns_zone_setrefreshkeyinterval(zone,
39f2d1a96a7c7494b1db0ea0f45e063a6a5ef9bbEvan Hunt cfg_obj_asuint32(obj)));
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews obj = NULL;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews result = cfg_map_get(zoptions, "auto-dnssec", &obj);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (result == ISC_R_SUCCESS) {
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews const char *arg = cfg_obj_asstring(obj);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (strcasecmp(arg, "allow") == 0)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews allow = ISC_TRUE;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews else if (strcasecmp(arg, "maintain") == 0)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews allow = maint = ISC_TRUE;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews else if (strcasecmp(arg, "off") == 0)
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews else
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, allow);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, maint);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews }
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews if (ztype == dns_zone_slave) {
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews RETERR(configure_zone_acl(zconfig, vconfig, config,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews allow_update_forwarding, ac,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews mayberaw, dns_zone_setforwardacl,
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews dns_zone_clearforwardacl));
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews }
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews /*%
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews * Primary master functionality.
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews */
3f42cf2f3e4dc7e740b4609ba7d7430292348f2bMark Andrews if (ztype == dns_zone_master) {
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews obj = NULL;
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews result = ns_config_get(maps, "check-wildcard", &obj);
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews if (result == ISC_R_SUCCESS)
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews check = cfg_obj_asboolean(obj);
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews else
508f61f8d699c46f962b682f388e54b446a7194dMark Andrews check = ISC_FALSE;
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKWILDCARD, check);
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
7829fad4093f2c1985b1efb7cea00287ff015d2bckb /*
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt * With map files, the default is ignore duplicate
7829fad4093f2c1985b1efb7cea00287ff015d2bckb * records. With other master formats, the default is
7829fad4093f2c1985b1efb7cea00287ff015d2bckb * taken from the global configuration.
7829fad4093f2c1985b1efb7cea00287ff015d2bckb */
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews obj = NULL;
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt if (masterformat != dns_masterformat_map) {
7829fad4093f2c1985b1efb7cea00287ff015d2bckb result = ns_config_get(maps, "check-dup-records", &obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb INSIST(result == ISC_R_SUCCESS && obj != NULL);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb dupcheck = cfg_obj_asstring(obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb } else {
7829fad4093f2c1985b1efb7cea00287ff015d2bckb result = ns_config_get(nodefault, "check-dup-records",
7829fad4093f2c1985b1efb7cea00287ff015d2bckb &obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb if (result == ISC_R_SUCCESS)
7829fad4093f2c1985b1efb7cea00287ff015d2bckb dupcheck = cfg_obj_asstring(obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb else
7829fad4093f2c1985b1efb7cea00287ff015d2bckb dupcheck = "ignore";
7829fad4093f2c1985b1efb7cea00287ff015d2bckb
7829fad4093f2c1985b1efb7cea00287ff015d2bckb }
7829fad4093f2c1985b1efb7cea00287ff015d2bckb if (strcasecmp(dupcheck, "warn") == 0) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews fail = ISC_FALSE;
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews check = ISC_TRUE;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb } else if (strcasecmp(dupcheck, "fail") == 0) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews fail = check = ISC_TRUE;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb } else if (strcasecmp(dupcheck, "ignore") == 0) {
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews fail = check = ISC_FALSE;
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews } else
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRR, check);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRRFAIL, fail);
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews obj = NULL;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews result = ns_config_get(maps, "check-mx", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews fail = ISC_FALSE;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews check = ISC_TRUE;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews fail = check = ISC_TRUE;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews fail = check = ISC_FALSE;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews } else
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMX, check);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMXFAIL, fail);
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
7829fad4093f2c1985b1efb7cea00287ff015d2bckb /*
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt * With map files, the default is *not* to check
7829fad4093f2c1985b1efb7cea00287ff015d2bckb * integrity. With other master formats, the default is
7829fad4093f2c1985b1efb7cea00287ff015d2bckb * taken from the global configuration.
7829fad4093f2c1985b1efb7cea00287ff015d2bckb */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews obj = NULL;
c9611b45736af157e2993c6ef852e55e8e24ca83Evan Hunt if (masterformat != dns_masterformat_map) {
7829fad4093f2c1985b1efb7cea00287ff015d2bckb result = ns_config_get(maps, "check-integrity", &obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb INSIST(result == ISC_R_SUCCESS && obj != NULL);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
7829fad4093f2c1985b1efb7cea00287ff015d2bckb cfg_obj_asboolean(obj));
7829fad4093f2c1985b1efb7cea00287ff015d2bckb } else {
11463c0ac24692e229ec87f307f5e7df3c0a7e10Evan Hunt check = ISC_FALSE;
7829fad4093f2c1985b1efb7cea00287ff015d2bckb result = ns_config_get(nodefault, "check-integrity",
7829fad4093f2c1985b1efb7cea00287ff015d2bckb &obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb if (result == ISC_R_SUCCESS)
7829fad4093f2c1985b1efb7cea00287ff015d2bckb check = cfg_obj_asboolean(obj);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
7829fad4093f2c1985b1efb7cea00287ff015d2bckb check);
7829fad4093f2c1985b1efb7cea00287ff015d2bckb }
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews obj = NULL;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews result = ns_config_get(maps, "check-mx-cname", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ISC_TRUE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews ignore = ISC_FALSE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ignore = ISC_FALSE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ignore = ISC_TRUE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNMXCNAME, warn);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNOREMXCNAME, ignore);
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews obj = NULL;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews result = ns_config_get(maps, "check-srv-cname", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ISC_TRUE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews ignore = ISC_FALSE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ignore = ISC_FALSE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews warn = ignore = ISC_TRUE;
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews } else
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews INSIST(0);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNSRVCNAME, warn);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNORESRVCNAME,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews ignore);
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews obj = NULL;
8e4f3f1cbceef520ba889270c993de0ac376a2a7Evan Hunt result = ns_config_get(maps, "dnssec-secure-to-insecure", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_SECURETOINSECURE,
28479307225582ad0b2e11441d85fcf5169551d0Mark Andrews cfg_obj_asboolean(obj));
77b8f88f144928eddcca144c348d6ef53e7d5c43Evan Hunt
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt obj = NULL;
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt result = cfg_map_get(zoptions, "dnssec-update-mode", &obj);
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt if (result == ISC_R_SUCCESS) {
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt const char *arg = cfg_obj_asstring(obj);
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt if (strcasecmp(arg, "no-resign") == 0)
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt dns_zone_setkeyopt(zone, DNS_ZONEKEY_NORESIGN,
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt ISC_TRUE);
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt else if (strcasecmp(arg, "maintain") == 0)
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt ;
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt else
bfe32d08c51a606744bd0d6ea518eb95084d2eefEvan Hunt INSIST(0);
97639003b0992b5f30ce82bdcc2fcd9d621ff09cAutomatic Updater }
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews obj = NULL;
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews result = ns_config_get(maps, "serial-update-method", &obj);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews if (strcasecmp(cfg_obj_asstring(obj), "unixtime") == 0)
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews dns_zone_setserialupdatemethod(zone,
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews dns_updatemethod_unixtime);
7318bbc26262a66a0d740ceefed769961ef7e476Evan Hunt else if (strcasecmp(cfg_obj_asstring(obj), "date") == 0)
7318bbc26262a66a0d740ceefed769961ef7e476Evan Hunt dns_zone_setserialupdatemethod(zone,
7318bbc26262a66a0d740ceefed769961ef7e476Evan Hunt dns_updatemethod_date);
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews else
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews dns_zone_setserialupdatemethod(zone,
a69070d8fab55dbc63ba9f96c9d3e34f0ea9119aMark Andrews dns_updatemethod_increment);
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson }
6fcfd0c35d3fd6aea3d36ad002b68e59ac62fdc7Brian Wellington
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson /*
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson * Configure slave functionality.
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson */
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington switch (ztype) {
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington case dns_zone_slave:
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington case dns_zone_stub:
0e507dbb816575e6220fe309e8ada68897ffcdbeMark Andrews case dns_zone_redirect:
2674e1a455d4f71de09b2b60e7a8304b9a305588Mark Andrews count = 0;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews (void)cfg_map_get(zoptions, "masters", &obj);
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington if (obj != NULL) {
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki dns_ipkeylist_t ipkl;
4681ab1fc2c40e1d70fae38e64630c72c51c300eWitold Krecicki dns_ipkeylist_init(&ipkl);
4681ab1fc2c40e1d70fae38e64630c72c51c300eWitold Krecicki
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington RETERR(ns_config_getipandkeylist(config, obj, mctx,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki &ipkl));
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki result = dns_zone_setmasterswithkeys(mayberaw,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.addrs,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.keys,
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki ipkl.count);
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki dns_ipkeylist_clear(mctx, &ipkl);
7a00d69909ace5dc11bcff9c1e07c311f92a7f8eWitold Krecicki RETERR(result);
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater } else
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews result = dns_zone_setmasters(mayberaw, NULL, 0);
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson RETERR(result);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews multi = ISC_FALSE;
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews if (count > 1) {
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews obj = NULL;
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews result = ns_config_get(maps, "multi-master", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews multi = cfg_obj_asboolean(obj);
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_MULTIMASTER, multi);
87f4715d6c0a22f3449eb3291c91aa45ba86c955Mark Andrews
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-transfer-time-in", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setmaxxfrin(mayberaw, cfg_obj_asuint32(obj) * 60);
bb56f556f520621bcab33688c31d655953774adcAndreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-transfer-idle-in", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setidlein(mayberaw, cfg_obj_asuint32(obj) * 60);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-refresh-time", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setmaxrefreshtime(mayberaw, cfg_obj_asuint32(obj));
cb9aa603ab2d019032e1b7b2d274e69adf0980f8Michael Graff
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "min-refresh-time", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setminrefreshtime(mayberaw, cfg_obj_asuint32(obj));
cb9aa603ab2d019032e1b7b2d274e69adf0980f8Michael Graff
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "max-retry-time", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setmaxretrytime(mayberaw, cfg_obj_asuint32(obj));
cb9aa603ab2d019032e1b7b2d274e69adf0980f8Michael Graff
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington obj = NULL;
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington result = ns_config_get(maps, "min-retry-time", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setminretrytime(mayberaw, cfg_obj_asuint32(obj));
cb9aa603ab2d019032e1b7b2d274e69adf0980f8Michael Graff
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson obj = NULL;
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson result = ns_config_get(maps, "transfer-source", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(dns_zone_setxfrsource4(mayberaw,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setxfrsource4dscp(mayberaw, dscp));
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson obj = NULL;
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson result = ns_config_get(maps, "transfer-source-v6", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(dns_zone_setxfrsource6(mayberaw,
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setxfrsource6dscp(mayberaw, dscp));
62700b67eb8abb7d13f9c3c1bc4b60a1477d35d8Mark Andrews ns_add_reserved_dispatch(ns_g_server, cfg_obj_assockaddr(obj));
bb60abb44549428414cd55a022f2b8cc4488f7adAndreas Gustafsson
476386968b1f287a695f73c48862e961011af99bMark Andrews obj = NULL;
b500de3be9ba5318da157364bf9fbbda5f88f203Mark Andrews result = ns_config_get(maps, "alt-transfer-source", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(dns_zone_setaltxfrsource4(mayberaw,
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setaltxfrsource4dscp(mayberaw, dscp));
476386968b1f287a695f73c48862e961011af99bMark Andrews
476386968b1f287a695f73c48862e961011af99bMark Andrews obj = NULL;
476386968b1f287a695f73c48862e961011af99bMark Andrews result = ns_config_get(maps, "alt-transfer-source-v6", &obj);
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews INSIST(result == ISC_R_SUCCESS && obj != NULL);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews RETERR(dns_zone_setaltxfrsource6(mayberaw,
4e68c7c87c30c28490c92937adc112dca5b5d5aeAutomatic Updater cfg_obj_assockaddr(obj)));
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = cfg_obj_getdscp(obj);
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt if (dscp == -1)
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt dscp = ns_g_dscp;
67adc03ef81fb610f8df093b17f55275ee816754Evan Hunt RETERR(dns_zone_setaltxfrsource6dscp(mayberaw, dscp));
476386968b1f287a695f73c48862e961011af99bMark Andrews
476386968b1f287a695f73c48862e961011af99bMark Andrews obj = NULL;
476386968b1f287a695f73c48862e961011af99bMark Andrews (void)ns_config_get(maps, "use-alt-transfer-source", &obj);
476386968b1f287a695f73c48862e961011af99bMark Andrews if (obj == NULL) {
476386968b1f287a695f73c48862e961011af99bMark Andrews /*
476386968b1f287a695f73c48862e961011af99bMark Andrews * Default off when views are in use otherwise
ce28ea0f2f8a6fbbafb8944dbe86cd0b98689b84Tatuya JINMEI 神明達哉 * on for BIND 8 compatibility.
476386968b1f287a695f73c48862e961011af99bMark Andrews */
476386968b1f287a695f73c48862e961011af99bMark Andrews view = dns_zone_getview(zone);
476386968b1f287a695f73c48862e961011af99bMark Andrews if (view != NULL && strcmp(view->name, "_default") == 0)
476386968b1f287a695f73c48862e961011af99bMark Andrews alt = ISC_TRUE;
476386968b1f287a695f73c48862e961011af99bMark Andrews else
476386968b1f287a695f73c48862e961011af99bMark Andrews alt = ISC_FALSE;
476386968b1f287a695f73c48862e961011af99bMark Andrews } else
476386968b1f287a695f73c48862e961011af99bMark Andrews alt = cfg_obj_asboolean(obj);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_USEALTXFRSRC, alt);
476386968b1f287a695f73c48862e961011af99bMark Andrews
a45a6ea2b03448751d7c44931e8ac7666e7cc2ceMark Andrews obj = NULL;
a45a6ea2b03448751d7c44931e8ac7666e7cc2ceMark Andrews (void)ns_config_get(maps, "try-tcp-refresh", &obj);
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews dns_zone_setoption(mayberaw, DNS_ZONEOPT_TRYTCPREFRESH,
a45a6ea2b03448751d7c44931e8ac7666e7cc2ceMark Andrews cfg_obj_asboolean(obj));
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson break;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 case dns_zone_staticstub:
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 RETERR(configure_staticstub(zoptions, zone, zname,
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 default_dbtype));
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 break;
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson default:
1adb2e87a20a480e640385609c9652dac04c7dffAndreas Gustafsson break;
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson }
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff return (ISC_R_SUCCESS);
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson}
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt/*
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt * Set up a DLZ zone as writeable
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt */
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Huntisc_result_t
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Huntns_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone,
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt dns_rdataclass_t rdclass, dns_name_t *name)
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt{
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt dns_db_t *db = NULL;
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt isc_time_t now;
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt isc_result_t result;
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt TIME_NOW(&now);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt dns_zone_settype(zone, dns_zone_dlz);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt result = dns_sdlz_setdb(dlzdatabase, rdclass, name, &db);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt if (result != ISC_R_SUCCESS)
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt return (result);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt result = dns_zone_dlzpostload(zone, db);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt dns_db_detach(&db);
793814f80703afdd69b59ade91e63efa81ae4178Evan Hunt return (result);
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt}
71bd858d8ed62672e7c23999dc7c02fd16a55089Evan Hunt
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafssonisc_boolean_t
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewsns_zone_reusable(dns_zone_t *zone, const cfg_obj_t *zconfig) {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *zoptions = NULL;
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews const cfg_obj_t *obj = NULL;
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson const char *cfilename;
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson const char *zfilename;
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews dns_zone_t *raw = NULL;
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews isc_boolean_t has_raw;
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zonetype_t ztype;
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington zoptions = cfg_tuple_get(zconfig, "options");
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 /*
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 * We always reconfigure a static-stub zone for simplicity, assuming
0ccd663a8377dd5accc5121f5938a81a98ed8960Automatic Updater * the amount of data to be loaded is small.
743bbdc18f839499862e4fb28ec32f607b1632dcTatuya JINMEI 神明達哉 */
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt if (zonetype_fromconfig(zoptions) == dns_zone_staticstub) {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zone_log(zone, ISC_LOG_DEBUG(1),
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt "not reusable: staticstub");
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews return (ISC_FALSE);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt }
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt /* If there's a raw zone, use that for filename and type comparison */
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews dns_zone_getraw(zone, &raw);
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews if (raw != NULL) {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt zfilename = dns_zone_getfile(raw);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt ztype = dns_zone_gettype(raw);
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews dns_zone_detach(&raw);
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews has_raw = ISC_TRUE;
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt } else {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt zfilename = dns_zone_getfile(zone);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt ztype = dns_zone_gettype(zone);
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews has_raw = ISC_FALSE;
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt }
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews
9198ab377b1cbf07d6d0c6eec25296c135bd66bdMark Andrews obj = NULL;
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews (void)cfg_map_get(zoptions, "inline-signing", &obj);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt if ((obj == NULL || !cfg_obj_asboolean(obj)) && has_raw) {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zone_log(zone, ISC_LOG_DEBUG(1),
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt "not reusable: old zone was inline-signing");
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews return (ISC_FALSE);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt } else if ((obj != NULL && cfg_obj_asboolean(obj)) && !has_raw) {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zone_log(zone, ISC_LOG_DEBUG(1),
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt "not reusable: old zone was not inline-signing");
02286522fbc6db783b5f0b4318289db0cefbfbcbMark Andrews return (ISC_FALSE);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt }
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt if (zonetype_fromconfig(zoptions) != ztype) {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zone_log(zone, ISC_LOG_DEBUG(1),
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt "not reusable: type mismatch");
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt return (ISC_FALSE);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt }
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt obj = NULL;
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt (void)cfg_map_get(zoptions, "file", &obj);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt if (obj != NULL)
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt cfilename = cfg_obj_asstring(obj);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt else
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt cfilename = NULL;
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt if (!((cfilename == NULL && zfilename == NULL) ||
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt (cfilename != NULL && zfilename != NULL &&
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt strcmp(cfilename, zfilename) == 0)))
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt {
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt dns_zone_log(zone, ISC_LOG_DEBUG(1),
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt "not reusable: filename mismatch");
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt return (ISC_FALSE);
c54dadd85337e9a8417103317a899dfba2a847d1Evan Hunt }
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson return (ISC_TRUE);
6889d57aabc5f48eaee78894e20054215319b461Andreas Gustafsson}