1999-12-16 23:11:07 +00:00
|
|
|
/*
|
2018-02-23 09:53:12 +01:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2016-06-27 14:56:38 +10:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2018-02-23 09:53:12 +01:00
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
1999-12-16 23:11:07 +00:00
|
|
|
*/
|
|
|
|
|
2018-03-28 14:56:40 +02:00
|
|
|
#include <inttypes.h>
|
2018-04-17 08:29:14 -07:00
|
|
|
#include <stdbool.h>
|
2018-03-28 14:56:40 +02:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
#include <isc/buffer.h>
|
2002-01-21 11:00:25 +00:00
|
|
|
#include <isc/file.h>
|
2000-08-10 00:53:36 +00:00
|
|
|
#include <isc/mem.h>
|
2001-08-30 05:23:00 +00:00
|
|
|
#include <isc/print.h>
|
2009-01-27 22:30:00 +00:00
|
|
|
#include <isc/stats.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <isc/string.h> /* Required for HP/UX (and others?) */
|
2000-04-28 01:12:23 +00:00
|
|
|
#include <isc/util.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <dns/acl.h>
|
2010-12-16 09:51:30 +00:00
|
|
|
#include <dns/db.h>
|
2001-03-04 21:21:39 +00:00
|
|
|
#include <dns/fixedname.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <dns/ipkeylist.h>
|
2017-05-02 13:23:08 -07:00
|
|
|
#include <dns/journal.h>
|
2019-09-03 11:42:10 +02:00
|
|
|
#include <dns/kasp.h>
|
2000-12-01 18:22:17 +00:00
|
|
|
#include <dns/log.h>
|
2014-04-17 17:10:29 -07:00
|
|
|
#include <dns/masterdump.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <dns/name.h>
|
2010-12-16 09:51:30 +00:00
|
|
|
#include <dns/rdata.h>
|
|
|
|
#include <dns/rdatalist.h>
|
2020-02-12 13:59:18 +01:00
|
|
|
#include <dns/rdataset.h>
|
|
|
|
#include <dns/rdatatype.h>
|
2010-12-16 09:51:30 +00:00
|
|
|
#include <dns/result.h>
|
2010-12-18 01:56:23 +00:00
|
|
|
#include <dns/sdlz.h>
|
2000-08-29 03:48:00 +00:00
|
|
|
#include <dns/ssu.h>
|
2008-04-03 05:55:52 +00:00
|
|
|
#include <dns/stats.h>
|
2017-09-08 13:39:09 -07:00
|
|
|
#include <dns/tsig.h>
|
2003-02-26 23:29:00 +00:00
|
|
|
#include <dns/view.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
#include <dns/zone.h>
|
2000-11-27 19:42:38 +00:00
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
#include <ns/client.h>
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
#include <named/config.h>
|
2000-12-01 18:22:17 +00:00
|
|
|
#include <named/globals.h>
|
|
|
|
#include <named/log.h>
|
2004-01-05 06:56:44 +00:00
|
|
|
#include <named/server.h>
|
2000-11-27 19:42:38 +00:00
|
|
|
#include <named/zoneconf.h>
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2008-05-21 23:17:21 +00:00
|
|
|
/* ACLs associated with zone */
|
|
|
|
typedef enum {
|
|
|
|
allow_notify,
|
|
|
|
allow_query,
|
2013-01-03 15:13:45 -08:00
|
|
|
allow_query_on,
|
2008-05-21 23:17:21 +00:00
|
|
|
allow_transfer,
|
|
|
|
allow_update,
|
|
|
|
allow_update_forwarding
|
|
|
|
} acl_type_t;
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define RETERR(x) \
|
|
|
|
do { \
|
|
|
|
isc_result_t _r = (x); \
|
|
|
|
if (_r != ISC_R_SUCCESS) \
|
2020-02-13 21:48:23 +01:00
|
|
|
return ((_r)); \
|
2000-05-25 19:27:48 +00:00
|
|
|
} while (0)
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
#define CHECK(x) \
|
|
|
|
do { \
|
|
|
|
result = (x); \
|
|
|
|
if (result != ISC_R_SUCCESS) \
|
|
|
|
goto cleanup; \
|
2009-06-10 00:27:22 +00:00
|
|
|
} while (0)
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
1999-12-16 23:11:07 +00:00
|
|
|
* Convenience function for configuring a single zone ACL.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2006-02-28 02:39:52 +00:00
|
|
|
configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig,
|
2008-05-21 23:17:21 +00:00
|
|
|
const cfg_obj_t *config, acl_type_t acltype,
|
2008-01-18 23:46:58 +00:00
|
|
|
cfg_aclconfctx_t *actx, dns_zone_t *zone,
|
1999-12-16 23:11:07 +00:00
|
|
|
void (*setzacl)(dns_zone_t *, dns_acl_t *),
|
2020-02-13 14:44:37 -08:00
|
|
|
void (*clearzacl)(dns_zone_t *)) {
|
|
|
|
isc_result_t result;
|
2020-02-12 13:59:18 +01:00
|
|
|
const cfg_obj_t *maps[5] = { NULL, NULL, NULL, NULL, NULL };
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *aclobj = NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
int i = 0;
|
|
|
|
dns_acl_t **aclp = NULL, *acl = NULL;
|
|
|
|
const char *aclname;
|
|
|
|
dns_view_t *view;
|
2008-05-21 23:17:21 +00:00
|
|
|
|
2008-05-21 23:47:01 +00:00
|
|
|
view = dns_zone_getview(zone);
|
2008-05-21 23:17:21 +00:00
|
|
|
|
|
|
|
switch (acltype) {
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_notify:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2008-05-21 23:47:01 +00:00
|
|
|
aclp = &view->notifyacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
aclname = "allow-notify";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_query:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2008-05-21 23:47:01 +00:00
|
|
|
aclp = &view->queryacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
aclname = "allow-query";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_query_on:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2013-01-03 15:13:45 -08:00
|
|
|
aclp = &view->queryonacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-01-03 15:13:45 -08:00
|
|
|
aclname = "allow-query-on";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_transfer:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2008-05-21 23:47:01 +00:00
|
|
|
aclp = &view->transferacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
aclname = "allow-transfer";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_update:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2008-05-21 23:47:01 +00:00
|
|
|
aclp = &view->updateacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
aclname = "allow-update";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
case allow_update_forwarding:
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view != NULL) {
|
2008-05-21 23:47:01 +00:00
|
|
|
aclp = &view->upfwdacl;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
aclname = "allow-update-forwarding";
|
|
|
|
break;
|
2020-02-12 13:59:18 +01:00
|
|
|
default:
|
2008-05-21 23:47:01 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
2008-05-21 23:17:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* First check to see if ACL is defined within the zone */
|
|
|
|
if (zconfig != NULL) {
|
|
|
|
maps[0] = cfg_tuple_get(zconfig, "options");
|
2017-09-08 13:39:09 -07:00
|
|
|
(void)named_config_get(maps, aclname, &aclobj);
|
2008-05-21 23:17:21 +00:00
|
|
|
if (aclobj != NULL) {
|
|
|
|
aclp = NULL;
|
|
|
|
goto parse_acl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Failing that, see if there's a default ACL already in the view */
|
|
|
|
if (aclp != NULL && *aclp != NULL) {
|
|
|
|
(*setzacl)(zone, *aclp);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2008-05-21 23:17:21 +00:00
|
|
|
/* Check for default ACLs that haven't been parsed yet */
|
2010-08-11 18:14:20 +00:00
|
|
|
if (vconfig != NULL) {
|
|
|
|
const cfg_obj_t *options = cfg_tuple_get(vconfig, "options");
|
2020-02-13 21:48:23 +01:00
|
|
|
if (options != NULL) {
|
2010-08-11 18:14:20 +00:00
|
|
|
maps[i++] = options;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-08-11 18:14:20 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
if (config != NULL) {
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *options = NULL;
|
2001-03-04 21:21:39 +00:00
|
|
|
(void)cfg_map_get(config, "options", &options);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (options != NULL) {
|
2001-03-04 21:21:39 +00:00
|
|
|
maps[i++] = options;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-02-22 21:24:24 +00:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
maps[i++] = named_g_defaults;
|
2001-03-04 21:21:39 +00:00
|
|
|
maps[i] = NULL;
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
(void)named_config_get(maps, aclname, &aclobj);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (aclobj == NULL) {
|
1999-12-16 23:11:07 +00:00
|
|
|
(*clearzacl)(zone);
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2008-05-21 23:17:21 +00:00
|
|
|
parse_acl:
|
2017-09-08 13:39:09 -07:00
|
|
|
result = cfg_acl_fromconfig(aclobj, config, named_g_lctx, actx,
|
2008-05-21 23:17:21 +00:00
|
|
|
dns_zone_getmctx(zone), 0, &acl);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2001-03-04 21:21:39 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
(*setzacl)(zone, acl);
|
|
|
|
|
2008-05-21 23:47:01 +00:00
|
|
|
/* Set the view default now */
|
2020-02-13 21:48:23 +01:00
|
|
|
if (aclp != NULL) {
|
2008-05-21 23:17:21 +00:00
|
|
|
dns_acl_attach(acl, aclp);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-05-21 23:17:21 +00:00
|
|
|
|
|
|
|
dns_acl_detach(&acl);
|
2001-03-04 21:21:39 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
2001-03-04 21:21:39 +00:00
|
|
|
* Parse the zone update-policy statement.
|
2000-05-25 19:27:48 +00:00
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
static isc_result_t
|
2009-06-10 00:27:22 +00:00
|
|
|
configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *zname) {
|
|
|
|
const cfg_obj_t *updatepolicy = NULL;
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_listelt_t *element, *element2;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_ssutable_t *table = NULL;
|
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
|
|
|
bool autoddns = false;
|
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
(void)cfg_map_get(zconfig, "update-policy", &updatepolicy);
|
2009-06-10 00:27:22 +00:00
|
|
|
|
2009-07-14 22:54:57 +00:00
|
|
|
if (updatepolicy == NULL) {
|
2006-01-05 03:32:50 +00:00
|
|
|
dns_zone_setssutable(zone, NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
2006-01-05 03:32:50 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2009-07-14 23:47:54 +00:00
|
|
|
if (cfg_obj_isstring(updatepolicy) &&
|
2020-02-13 14:44:37 -08:00
|
|
|
strcmp("local", cfg_obj_asstring(updatepolicy)) == 0)
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
autoddns = true;
|
2009-07-14 23:47:54 +00:00
|
|
|
updatepolicy = NULL;
|
|
|
|
}
|
2009-07-14 22:54:57 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
result = dns_ssutable_create(mctx, &table);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2001-03-04 21:21:39 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
for (element = cfg_list_first(updatepolicy); element != NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
|
|
|
const cfg_obj_t *stmt = cfg_listelt_value(element);
|
|
|
|
const cfg_obj_t *mode = cfg_tuple_get(stmt, "mode");
|
|
|
|
const cfg_obj_t *identity = cfg_tuple_get(stmt, "identity");
|
|
|
|
const cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
|
|
|
|
const cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
|
|
|
|
const cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
|
|
|
|
const char *str;
|
|
|
|
bool grant = false;
|
|
|
|
bool usezone = false;
|
2018-09-20 15:50:07 +10:00
|
|
|
dns_ssumatchtype_t mtype = dns_ssumatchtype_name;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_fixedname_t fname, fident;
|
|
|
|
isc_buffer_t b;
|
|
|
|
dns_rdatatype_t *types;
|
|
|
|
unsigned int i, n;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
str = cfg_obj_asstring(mode);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(str, "grant") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
grant = true;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(str, "deny") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
grant = false;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
str = cfg_obj_asstring(matchtype);
|
2018-02-07 13:34:02 +11:00
|
|
|
CHECK(dns_ssu_mtypefromstring(str, &mtype));
|
|
|
|
if (mtype == dns_ssumatchtype_subdomain) {
|
2018-04-17 08:29:14 -07:00
|
|
|
usezone = true;
|
2018-02-07 13:34:02 +11:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
dns_fixedname_init(&fident);
|
|
|
|
str = cfg_obj_asstring(identity);
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&b, str, strlen(str));
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_buffer_add(&b, strlen(str));
|
|
|
|
result = dns_name_fromtext(dns_fixedname_name(&fident), &b,
|
2009-09-01 00:22:28 +00:00
|
|
|
dns_rootname, 0, NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(identity, named_g_lctx, ISC_LOG_ERROR,
|
2001-03-04 21:21:39 +00:00
|
|
|
"'%s' is not a valid name", str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_fixedname_init(&fname);
|
2009-06-10 00:27:22 +00:00
|
|
|
if (usezone) {
|
2019-09-10 14:42:41 +02:00
|
|
|
dns_name_copynf(dns_zone_getorigin(zone),
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_fixedname_name(&fname));
|
2009-06-10 00:27:22 +00:00
|
|
|
} else {
|
|
|
|
str = cfg_obj_asstring(dname);
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&b, str, strlen(str));
|
2009-06-10 00:27:22 +00:00
|
|
|
isc_buffer_add(&b, strlen(str));
|
|
|
|
result = dns_name_fromtext(dns_fixedname_name(&fname),
|
2009-09-01 00:22:28 +00:00
|
|
|
&b, dns_rootname, 0, NULL);
|
2009-06-10 00:27:22 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(identity, named_g_lctx,
|
|
|
|
ISC_LOG_ERROR,
|
2009-06-10 00:27:22 +00:00
|
|
|
"'%s' is not a valid name", str);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
n = named_config_listcount(typelist);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (n == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
types = NULL;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
types = isc_mem_get(mctx, n * sizeof(dns_rdatatype_t));
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
2020-02-12 13:59:18 +01:00
|
|
|
for (element2 = cfg_list_first(typelist); element2 != NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
element2 = cfg_list_next(element2))
|
|
|
|
{
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *typeobj;
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_textregion_t r;
|
|
|
|
|
|
|
|
INSIST(i < n);
|
|
|
|
|
|
|
|
typeobj = cfg_listelt_value(element2);
|
|
|
|
str = cfg_obj_asstring(typeobj);
|
2005-08-23 02:36:11 +00:00
|
|
|
DE_CONST(str, r.base);
|
2001-03-04 21:21:39 +00:00
|
|
|
r.length = strlen(str);
|
|
|
|
|
|
|
|
result = dns_rdatatype_fromtext(&types[i++], &r);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(identity, named_g_lctx,
|
|
|
|
ISC_LOG_ERROR,
|
2001-03-04 21:21:39 +00:00
|
|
|
"'%s' is not a valid type", str);
|
|
|
|
isc_mem_put(mctx, types,
|
|
|
|
n * sizeof(dns_rdatatype_t));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
INSIST(i == n);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = dns_ssutable_addrule(
|
|
|
|
table, grant, dns_fixedname_name(&fident), mtype,
|
|
|
|
dns_fixedname_name(&fname), n, types);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (types != NULL) {
|
2001-03-04 21:21:39 +00:00
|
|
|
isc_mem_put(mctx, types, n * sizeof(dns_rdatatype_t));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2009-06-10 00:27:22 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2009-06-10 00:27:22 +00:00
|
|
|
/*
|
2009-07-14 22:54:57 +00:00
|
|
|
* If "update-policy local;" and a session key exists,
|
|
|
|
* then use the default policy, which is equivalent to:
|
|
|
|
* update-policy { grant <session-keyname> zonesub any; };
|
2009-06-10 00:27:22 +00:00
|
|
|
*/
|
|
|
|
if (autoddns) {
|
|
|
|
dns_rdatatype_t any = dns_rdatatype_any;
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
if (named_g_server->session_keyname == NULL) {
|
|
|
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2009-06-10 00:27:22 +00:00
|
|
|
"failed to enable auto DDNS policy "
|
|
|
|
"for zone %s: session key not found",
|
|
|
|
zname);
|
|
|
|
result = ISC_R_NOTFOUND;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
result = dns_ssutable_addrule(
|
|
|
|
table, true, named_g_server->session_keyname,
|
|
|
|
dns_ssumatchtype_local, dns_zone_getorigin(zone), 1,
|
|
|
|
&any);
|
2009-06-10 00:27:22 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2009-06-10 00:27:22 +00:00
|
|
|
goto cleanup;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-01-21 19:22:35 +00:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
dns_zone_setssutable(zone, table);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
cleanup:
|
2001-03-04 21:21:39 +00:00
|
|
|
dns_ssutable_detach(&table);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
/*
|
|
|
|
* This is the TTL used for internally generated RRsets for static-stub zones.
|
|
|
|
* The value doesn't matter because the mapping is static, but needs to be
|
|
|
|
* defined for the sake of implementation.
|
|
|
|
*/
|
|
|
|
#define STATICSTUB_SERVER_TTL 86400
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Configure an apex NS with glues for a static-stub zone.
|
|
|
|
* For example, for the zone named "example.com", the following RRs will be
|
|
|
|
* added to the zone DB:
|
|
|
|
* example.com. NS example.com.
|
|
|
|
* example.com. A 192.0.2.1
|
|
|
|
* example.com. AAAA 2001:db8::1
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
configure_staticstub_serveraddrs(const cfg_obj_t *zconfig, dns_zone_t *zone,
|
|
|
|
dns_rdatalist_t *rdatalist_ns,
|
|
|
|
dns_rdatalist_t *rdatalist_a,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdatalist_t *rdatalist_aaaa) {
|
2010-12-16 09:51:30 +00:00
|
|
|
const cfg_listelt_t *element;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
|
|
|
isc_region_t region, sregion;
|
|
|
|
dns_rdata_t *rdata;
|
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2020-02-12 13:59:18 +01:00
|
|
|
|
|
|
|
for (element = cfg_list_first(zconfig); element != NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
2020-02-12 13:59:18 +01:00
|
|
|
const isc_sockaddr_t *sa;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_netaddr_t na;
|
|
|
|
const cfg_obj_t *address = cfg_listelt_value(element);
|
|
|
|
dns_rdatalist_t *rdatalist;
|
2010-12-16 09:51:30 +00:00
|
|
|
|
|
|
|
sa = cfg_obj_assockaddr(address);
|
|
|
|
if (isc_sockaddr_getport(sa) != 0) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(zconfig, named_g_lctx, ISC_LOG_ERROR,
|
2010-12-16 09:51:30 +00:00
|
|
|
"port is not configurable for "
|
|
|
|
"static stub server-addresses");
|
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
isc_netaddr_fromsockaddr(&na, sa);
|
|
|
|
if (isc_netaddr_getzone(&na) != 0) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(zconfig, named_g_lctx, ISC_LOG_ERROR,
|
2020-02-12 13:59:18 +01:00
|
|
|
"scoped address is not allowed "
|
|
|
|
"for static stub "
|
|
|
|
"server-addresses");
|
2010-12-16 09:51:30 +00:00
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (na.family) {
|
|
|
|
case AF_INET:
|
|
|
|
region.length = sizeof(na.type.in);
|
|
|
|
rdatalist = rdatalist_a;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
INSIST(na.family == AF_INET6);
|
|
|
|
region.length = sizeof(na.type.in6);
|
|
|
|
rdatalist = rdatalist_aaaa;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rdata = isc_mem_get(mctx, sizeof(*rdata) + region.length);
|
|
|
|
region.base = (unsigned char *)(rdata + 1);
|
2014-01-08 16:27:10 -08:00
|
|
|
memmove(region.base, &na.type, region.length);
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdata_init(rdata);
|
|
|
|
dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
|
|
|
|
rdatalist->type, ®ion);
|
|
|
|
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If no address is specified (unlikely in this context, but possible),
|
|
|
|
* there's nothing to do anymore.
|
|
|
|
*/
|
|
|
|
if (ISC_LIST_EMPTY(rdatalist_a->rdata) &&
|
|
|
|
ISC_LIST_EMPTY(rdatalist_aaaa->rdata)) {
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add to the list an apex NS with the ns name being the origin name */
|
|
|
|
dns_name_toregion(dns_zone_getorigin(zone), &sregion);
|
|
|
|
rdata = isc_mem_get(mctx, sizeof(*rdata) + sregion.length);
|
|
|
|
region.length = sregion.length;
|
|
|
|
region.base = (unsigned char *)(rdata + 1);
|
2014-01-08 16:27:10 -08:00
|
|
|
memmove(region.base, sregion.base, region.length);
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdata_init(rdata);
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdata_fromregion(rdata, dns_zone_getclass(zone), dns_rdatatype_ns,
|
|
|
|
®ion);
|
2010-12-16 09:51:30 +00:00
|
|
|
ISC_LIST_APPEND(rdatalist_ns->rdata, rdata, link);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Configure an apex NS with an out-of-zone NS names for a static-stub zone.
|
|
|
|
* For example, for the zone named "example.com", something like the following
|
|
|
|
* RRs will be added to the zone DB:
|
|
|
|
* example.com. NS ns.example.net.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
configure_staticstub_servernames(const cfg_obj_t *zconfig, dns_zone_t *zone,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdatalist_t *rdatalist,
|
|
|
|
const char *zname) {
|
2010-12-16 09:51:30 +00:00
|
|
|
const cfg_listelt_t *element;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
|
|
|
dns_rdata_t *rdata;
|
|
|
|
isc_region_t sregion, region;
|
|
|
|
isc_result_t result = ISC_R_SUCCESS;
|
2020-02-12 13:59:18 +01:00
|
|
|
|
|
|
|
for (element = cfg_list_first(zconfig); element != NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
element = cfg_list_next(element))
|
|
|
|
{
|
2010-12-16 09:51:30 +00:00
|
|
|
const cfg_obj_t *obj;
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *str;
|
|
|
|
dns_fixedname_t fixed_name;
|
|
|
|
dns_name_t *nsname;
|
|
|
|
isc_buffer_t b;
|
2010-12-16 09:51:30 +00:00
|
|
|
|
|
|
|
obj = cfg_listelt_value(element);
|
|
|
|
str = cfg_obj_asstring(obj);
|
|
|
|
|
2018-03-28 14:38:09 +02:00
|
|
|
nsname = dns_fixedname_initname(&fixed_name);
|
2010-12-16 09:51:30 +00:00
|
|
|
|
2012-12-08 12:48:57 +11:00
|
|
|
isc_buffer_constinit(&b, str, strlen(str));
|
2010-12-16 09:51:30 +00:00
|
|
|
isc_buffer_add(&b, strlen(str));
|
|
|
|
result = dns_name_fromtext(nsname, &b, dns_rootname, 0, NULL);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(zconfig, named_g_lctx, ISC_LOG_ERROR,
|
2020-02-12 13:59:18 +01:00
|
|
|
"server-name '%s' is not a valid "
|
|
|
|
"name",
|
|
|
|
str);
|
2010-12-16 09:51:30 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
if (dns_name_issubdomain(nsname, dns_zone_getorigin(zone))) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(zconfig, named_g_lctx, ISC_LOG_ERROR,
|
2010-12-16 09:51:30 +00:00
|
|
|
"server-name '%s' must not be a "
|
|
|
|
"subdomain of zone name '%s'",
|
|
|
|
str, zname);
|
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
dns_name_toregion(nsname, &sregion);
|
|
|
|
rdata = isc_mem_get(mctx, sizeof(*rdata) + sregion.length);
|
|
|
|
region.length = sregion.length;
|
|
|
|
region.base = (unsigned char *)(rdata + 1);
|
2014-01-08 16:27:10 -08:00
|
|
|
memmove(region.base, sregion.base, region.length);
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdata_init(rdata);
|
|
|
|
dns_rdata_fromregion(rdata, dns_zone_getclass(zone),
|
|
|
|
dns_rdatatype_ns, ®ion);
|
|
|
|
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Configure static-stub zone.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
|
|
|
configure_staticstub(const cfg_obj_t *zconfig, dns_zone_t *zone,
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *zname, const char *dbtype) {
|
|
|
|
int i = 0;
|
2010-12-16 09:51:30 +00:00
|
|
|
const cfg_obj_t *obj;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
|
|
|
dns_db_t *db = NULL;
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_dbversion_t *dbversion = NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_dbnode_t *apexnode = NULL;
|
|
|
|
dns_name_t apexname;
|
|
|
|
isc_result_t result;
|
|
|
|
dns_rdataset_t rdataset;
|
|
|
|
dns_rdatalist_t rdatalist_ns, rdatalist_a, rdatalist_aaaa;
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdatalist_t *rdatalists[] = { &rdatalist_ns, &rdatalist_a,
|
|
|
|
&rdatalist_aaaa, NULL };
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdata_t *rdata;
|
|
|
|
isc_region_t region;
|
2010-12-16 09:51:30 +00:00
|
|
|
|
|
|
|
/* Create the DB beforehand */
|
|
|
|
RETERR(dns_db_create(mctx, dbtype, dns_zone_getorigin(zone),
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_dbtype_stub, dns_zone_getclass(zone), 0, NULL,
|
|
|
|
&db));
|
2019-09-04 14:02:33 +10:00
|
|
|
|
|
|
|
dns_rdataset_init(&rdataset);
|
2010-12-16 09:51:30 +00:00
|
|
|
|
|
|
|
dns_rdatalist_init(&rdatalist_ns);
|
|
|
|
rdatalist_ns.rdclass = dns_zone_getclass(zone);
|
|
|
|
rdatalist_ns.type = dns_rdatatype_ns;
|
|
|
|
rdatalist_ns.ttl = STATICSTUB_SERVER_TTL;
|
|
|
|
|
|
|
|
dns_rdatalist_init(&rdatalist_a);
|
|
|
|
rdatalist_a.rdclass = dns_zone_getclass(zone);
|
|
|
|
rdatalist_a.type = dns_rdatatype_a;
|
|
|
|
rdatalist_a.ttl = STATICSTUB_SERVER_TTL;
|
|
|
|
|
|
|
|
dns_rdatalist_init(&rdatalist_aaaa);
|
|
|
|
rdatalist_aaaa.rdclass = dns_zone_getclass(zone);
|
|
|
|
rdatalist_aaaa.type = dns_rdatatype_aaaa;
|
|
|
|
rdatalist_aaaa.ttl = STATICSTUB_SERVER_TTL;
|
|
|
|
|
|
|
|
/* Prepare zone RRs from the configuration */
|
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zconfig, "server-addresses", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
INSIST(obj != NULL);
|
2020-02-12 13:59:18 +01:00
|
|
|
CHECK(configure_staticstub_serveraddrs(obj, zone, &rdatalist_ns,
|
2019-09-04 14:02:33 +10:00
|
|
|
&rdatalist_a,
|
|
|
|
&rdatalist_aaaa));
|
2010-12-16 09:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zconfig, "server-names", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
INSIST(obj != NULL);
|
2020-02-12 13:59:18 +01:00
|
|
|
CHECK(configure_staticstub_servernames(obj, zone, &rdatalist_ns,
|
2019-09-04 14:02:33 +10:00
|
|
|
zname));
|
2010-12-16 09:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check: there should be at least one NS RR at the zone apex
|
|
|
|
* to trigger delegation.
|
|
|
|
*/
|
|
|
|
if (ISC_LIST_EMPTY(rdatalist_ns.rdata)) {
|
2017-09-08 13:39:09 -07:00
|
|
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2010-12-16 09:51:30 +00:00
|
|
|
"No NS record is configured for a "
|
2020-02-12 13:59:18 +01:00
|
|
|
"static-stub zone '%s'",
|
|
|
|
zname);
|
2010-12-16 09:51:30 +00:00
|
|
|
result = ISC_R_FAILURE;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now add NS and glue A/AAAA RRsets to the zone DB.
|
|
|
|
* First open a new version for the add operation and get a pointer
|
|
|
|
* to the apex node (all RRs are of the apex name).
|
|
|
|
*/
|
2019-09-04 14:02:33 +10:00
|
|
|
CHECK(dns_db_newversion(db, &dbversion));
|
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_name_init(&apexname, NULL);
|
|
|
|
dns_name_clone(dns_zone_getorigin(zone), &apexname);
|
2019-09-04 14:02:33 +10:00
|
|
|
CHECK(dns_db_findnode(db, &apexname, false, &apexnode));
|
2010-12-16 09:51:30 +00:00
|
|
|
|
|
|
|
/* Add NS RRset */
|
2020-02-12 13:59:18 +01:00
|
|
|
RUNTIME_CHECK(dns_rdatalist_tordataset(&rdatalist_ns, &rdataset) ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
CHECK(dns_db_addrdataset(db, apexnode, dbversion, 0, &rdataset, 0,
|
|
|
|
NULL));
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
|
|
|
|
/* Add glue A RRset, if any */
|
|
|
|
if (!ISC_LIST_EMPTY(rdatalist_a.rdata)) {
|
2020-02-12 13:59:18 +01:00
|
|
|
RUNTIME_CHECK(
|
|
|
|
dns_rdatalist_tordataset(&rdatalist_a, &rdataset) ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
CHECK(dns_db_addrdataset(db, apexnode, dbversion, 0, &rdataset,
|
|
|
|
0, NULL));
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add glue AAAA RRset, if any */
|
|
|
|
if (!ISC_LIST_EMPTY(rdatalist_aaaa.rdata)) {
|
2020-02-12 13:59:18 +01:00
|
|
|
RUNTIME_CHECK(
|
|
|
|
dns_rdatalist_tordataset(&rdatalist_aaaa, &rdataset) ==
|
|
|
|
ISC_R_SUCCESS);
|
|
|
|
CHECK(dns_db_addrdataset(db, apexnode, dbversion, 0, &rdataset,
|
|
|
|
0, NULL));
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
}
|
|
|
|
|
2019-09-04 14:02:33 +10:00
|
|
|
dns_db_closeversion(db, &dbversion, true);
|
|
|
|
dns_zone_setdb(zone, db);
|
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
cleanup:
|
2019-09-04 14:02:33 +10:00
|
|
|
if (dns_rdataset_isassociated(&rdataset)) {
|
|
|
|
dns_rdataset_disassociate(&rdataset);
|
|
|
|
}
|
|
|
|
if (apexnode != NULL) {
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_db_detachnode(db, &apexnode);
|
2019-09-04 14:02:33 +10:00
|
|
|
}
|
|
|
|
if (dbversion != NULL) {
|
|
|
|
dns_db_closeversion(db, &dbversion, false);
|
|
|
|
}
|
|
|
|
if (db != NULL) {
|
2010-12-16 09:51:30 +00:00
|
|
|
dns_db_detach(&db);
|
2019-09-04 14:02:33 +10:00
|
|
|
}
|
2010-12-16 09:51:30 +00:00
|
|
|
for (i = 0; rdatalists[i] != NULL; i++) {
|
|
|
|
while ((rdata = ISC_LIST_HEAD(rdatalists[i]->rdata)) != NULL) {
|
|
|
|
ISC_LIST_UNLINK(rdatalists[i]->rdata, rdata, link);
|
|
|
|
dns_rdata_toregion(rdata, ®ion);
|
|
|
|
isc_mem_put(mctx, rdata,
|
|
|
|
sizeof(*rdata) + region.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-03 07:50:09 +10:00
|
|
|
INSIST(dbversion == NULL);
|
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
2001-03-04 21:21:39 +00:00
|
|
|
* Convert a config file zone type into a server zone type.
|
|
|
|
*/
|
|
|
|
static inline dns_zonetype_t
|
2020-02-13 14:44:37 -08:00
|
|
|
zonetype_fromconfig(const cfg_obj_t *map) {
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *obj = NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_result_t result;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
|
|
|
result = cfg_map_get(map, "type", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2017-09-08 13:39:09 -07:00
|
|
|
return (named_config_getzonetype(obj));
|
2000-01-21 19:22:35 +00:00
|
|
|
}
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
2000-08-10 00:53:36 +00:00
|
|
|
* Helper function for strtoargv(). Pardon the gratuitous recursion.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
strtoargvsub(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp,
|
2020-02-13 14:44:37 -08:00
|
|
|
unsigned int n) {
|
2000-08-10 00:53:36 +00:00
|
|
|
isc_result_t result;
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2000-08-10 00:53:36 +00:00
|
|
|
/* Discard leading whitespace. */
|
2020-02-13 21:48:23 +01:00
|
|
|
while (*s == ' ' || *s == '\t') {
|
2000-08-10 00:53:36 +00:00
|
|
|
s++;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2000-08-10 00:53:36 +00:00
|
|
|
if (*s == '\0') {
|
|
|
|
/* We have reached the end of the string. */
|
|
|
|
*argcp = n;
|
|
|
|
*argvp = isc_mem_get(mctx, n * sizeof(char *));
|
|
|
|
} else {
|
|
|
|
char *p = s;
|
2020-02-13 21:48:23 +01:00
|
|
|
while (*p != ' ' && *p != '\t' && *p != '\0') {
|
2000-08-10 00:53:36 +00:00
|
|
|
p++;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (*p != '\0') {
|
2000-08-10 00:53:36 +00:00
|
|
|
*p++ = '\0';
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-08-10 00:53:36 +00:00
|
|
|
|
|
|
|
result = strtoargvsub(mctx, p, argcp, argvp, n + 1);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2000-08-10 00:53:36 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-08-10 00:53:36 +00:00
|
|
|
(*argvp)[n] = s;
|
|
|
|
}
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2005-04-27 04:57:32 +00:00
|
|
|
/*%
|
2000-08-10 00:53:36 +00:00
|
|
|
* Tokenize the string "s" into whitespace-separated words,
|
|
|
|
* return the number of words in '*argcp' and an array
|
|
|
|
* of pointers to the words in '*argvp'. The caller
|
|
|
|
* must free the array using isc_mem_put(). The string
|
|
|
|
* is modified in-place.
|
|
|
|
*/
|
|
|
|
static isc_result_t
|
2020-02-13 14:44:37 -08:00
|
|
|
strtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) {
|
2000-08-10 00:53:36 +00:00
|
|
|
return (strtoargvsub(mctx, s, argcp, argvp, 0));
|
|
|
|
}
|
|
|
|
|
2004-02-27 20:41:51 +00:00
|
|
|
static void
|
2020-02-13 14:44:37 -08:00
|
|
|
checknames(dns_zonetype_t ztype, const cfg_obj_t **maps,
|
|
|
|
const cfg_obj_t **objp) {
|
|
|
|
const char *zone = NULL;
|
2004-04-20 14:11:47 +00:00
|
|
|
isc_result_t result;
|
2004-02-27 20:41:51 +00:00
|
|
|
|
|
|
|
switch (ztype) {
|
2018-10-09 10:54:51 +02:00
|
|
|
case dns_zone_slave:
|
|
|
|
case dns_zone_mirror:
|
|
|
|
zone = "slave";
|
|
|
|
break;
|
|
|
|
case dns_zone_master:
|
|
|
|
zone = "master";
|
|
|
|
break;
|
2004-02-27 20:41:51 +00:00
|
|
|
default:
|
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_checknames_get(maps, zone, objp);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && objp != NULL && *objp != NULL);
|
2004-02-27 20:41:51 +00:00
|
|
|
}
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
/*
|
|
|
|
* Callback to see if a non-recursive query coming from 'srcaddr' to
|
|
|
|
* 'destaddr', with optional key 'mykey' for class 'rdclass' would be
|
|
|
|
* delivered to 'myview'.
|
|
|
|
*
|
|
|
|
* We run this unlocked as both the view list and the interface list
|
|
|
|
* are updated when the appropriate task has exclusivity.
|
|
|
|
*/
|
2018-04-17 08:29:14 -07:00
|
|
|
static bool
|
2020-02-12 13:59:18 +01:00
|
|
|
isself(dns_view_t *myview, dns_tsigkey_t *mykey, const isc_sockaddr_t *srcaddr,
|
2020-02-13 14:44:37 -08:00
|
|
|
const isc_sockaddr_t *dstaddr, dns_rdataclass_t rdclass, void *arg) {
|
2020-02-12 13:59:18 +01:00
|
|
|
ns_interfacemgr_t *interfacemgr = (ns_interfacemgr_t *)arg;
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_aclenv_t *env = ns_interfacemgr_getaclenv(interfacemgr);
|
|
|
|
dns_view_t *view;
|
|
|
|
dns_tsigkey_t *key = NULL;
|
|
|
|
isc_netaddr_t netsrc;
|
|
|
|
isc_netaddr_t netdst;
|
2017-09-08 13:39:09 -07:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (interfacemgr == NULL) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (!ns_interfacemgr_listeningon(interfacemgr, dstaddr)) {
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
|
|
|
|
isc_netaddr_fromsockaddr(&netsrc, srcaddr);
|
|
|
|
isc_netaddr_fromsockaddr(&netdst, dstaddr);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
for (view = ISC_LIST_HEAD(named_g_server->viewlist); view != NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
view = ISC_LIST_NEXT(view, link))
|
|
|
|
{
|
2019-09-27 09:39:35 +02:00
|
|
|
const dns_name_t *tsig = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (view->matchrecursiveonly) {
|
2017-09-08 13:39:09 -07:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (rdclass != view->rdclass) {
|
2017-09-08 13:39:09 -07:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
|
|
|
|
if (mykey != NULL) {
|
2020-02-13 14:44:37 -08:00
|
|
|
bool match;
|
2017-09-08 13:39:09 -07:00
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
result = dns_view_gettsig(view, &mykey->name, &key);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2017-09-08 13:39:09 -07:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
match = dst_key_compare(mykey->key, key->key);
|
|
|
|
dns_tsigkey_detach(&key);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (!match) {
|
2017-09-08 13:39:09 -07:00
|
|
|
continue;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
tsig = dns_tsigkey_identity(mykey);
|
|
|
|
}
|
|
|
|
|
2018-04-26 20:57:41 -07:00
|
|
|
if (dns_acl_allowed(&netsrc, tsig, view->matchclients, env) &&
|
|
|
|
dns_acl_allowed(&netdst, tsig, view->matchdestinations,
|
2020-02-13 14:44:37 -08:00
|
|
|
env))
|
|
|
|
{
|
2017-09-08 13:39:09 -07:00
|
|
|
break;
|
2018-04-26 20:57:41 -07:00
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
}
|
2018-04-17 08:29:14 -07:00
|
|
|
return (view == myview);
|
2017-09-08 13:39:09 -07:00
|
|
|
}
|
|
|
|
|
Clean up handling of NOTIFY settings for mirror zones
Previous way of handling NOTIFY settings for mirror zones was a bit
tricky: any value of the "notify" option was accepted, but it was
subsequently overridden with dns_notifytype_explicit. Given the way
zone configuration is performed, this resulted in the following
behavior:
- if "notify yes;" was set explicitly at any configuration level or
inherited from default configuration, it was silently changed and so
only hosts specified in "also-notify", if any, were notified,
- if "notify no;" was set at any configuration level, it was
effectively honored since even though zone->notifytype was silently
set to dns_notifytype_explicit, the "also-notify" option was never
processed due to "notify no;" being set.
Effectively, this only allowed the hosts specified in "also-notify" to
be notified, when either "notify yes;" or "notify explicit;" was
explicitly set or inherited from default configuration.
Clean up handling of NOTIFY settings for mirror zones by:
- reporting a configuration error when anything else than "notify no;"
or "notify explicit;" is set for a mirror zone at the zone level,
- overriding inherited "notify yes;" setting with "notify explicit;"
for mirror zones,
- informing the user when the "notify" setting is overridden, unless
the setting in question was inherited from default configuration.
2018-10-09 10:54:51 +02:00
|
|
|
/*%
|
|
|
|
* For mirror zones, change "notify yes;" to "notify explicit;", informing the
|
|
|
|
* user only if "notify" was explicitly configured rather than inherited from
|
|
|
|
* default configuration.
|
|
|
|
*/
|
|
|
|
static dns_notifytype_t
|
|
|
|
process_notifytype(dns_notifytype_t ntype, dns_zonetype_t ztype,
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *zname, const cfg_obj_t **maps) {
|
Clean up handling of NOTIFY settings for mirror zones
Previous way of handling NOTIFY settings for mirror zones was a bit
tricky: any value of the "notify" option was accepted, but it was
subsequently overridden with dns_notifytype_explicit. Given the way
zone configuration is performed, this resulted in the following
behavior:
- if "notify yes;" was set explicitly at any configuration level or
inherited from default configuration, it was silently changed and so
only hosts specified in "also-notify", if any, were notified,
- if "notify no;" was set at any configuration level, it was
effectively honored since even though zone->notifytype was silently
set to dns_notifytype_explicit, the "also-notify" option was never
processed due to "notify no;" being set.
Effectively, this only allowed the hosts specified in "also-notify" to
be notified, when either "notify yes;" or "notify explicit;" was
explicitly set or inherited from default configuration.
Clean up handling of NOTIFY settings for mirror zones by:
- reporting a configuration error when anything else than "notify no;"
or "notify explicit;" is set for a mirror zone at the zone level,
- overriding inherited "notify yes;" setting with "notify explicit;"
for mirror zones,
- informing the user when the "notify" setting is overridden, unless
the setting in question was inherited from default configuration.
2018-10-09 10:54:51 +02:00
|
|
|
const cfg_obj_t *obj = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the original setting if this is not a mirror zone or if the
|
|
|
|
* zone is configured with something else than "notify yes;".
|
|
|
|
*/
|
|
|
|
if (ztype != dns_zone_mirror || ntype != dns_notifytype_yes) {
|
|
|
|
return (ntype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only log a message if "notify" was set in the configuration
|
|
|
|
* hierarchy supplied in 'maps'.
|
|
|
|
*/
|
|
|
|
if (named_config_get(maps, "notify", &obj) == ISC_R_SUCCESS) {
|
|
|
|
cfg_obj_log(obj, named_g_lctx, ISC_LOG_INFO,
|
|
|
|
"'notify explicit;' will be used for mirror zone "
|
2020-02-12 13:59:18 +01:00
|
|
|
"'%s'",
|
|
|
|
zname);
|
Clean up handling of NOTIFY settings for mirror zones
Previous way of handling NOTIFY settings for mirror zones was a bit
tricky: any value of the "notify" option was accepted, but it was
subsequently overridden with dns_notifytype_explicit. Given the way
zone configuration is performed, this resulted in the following
behavior:
- if "notify yes;" was set explicitly at any configuration level or
inherited from default configuration, it was silently changed and so
only hosts specified in "also-notify", if any, were notified,
- if "notify no;" was set at any configuration level, it was
effectively honored since even though zone->notifytype was silently
set to dns_notifytype_explicit, the "also-notify" option was never
processed due to "notify no;" being set.
Effectively, this only allowed the hosts specified in "also-notify" to
be notified, when either "notify yes;" or "notify explicit;" was
explicitly set or inherited from default configuration.
Clean up handling of NOTIFY settings for mirror zones by:
- reporting a configuration error when anything else than "notify no;"
or "notify explicit;" is set for a mirror zone at the zone level,
- overriding inherited "notify yes;" setting with "notify explicit;"
for mirror zones,
- informing the user when the "notify" setting is overridden, unless
the setting in question was inherited from default configuration.
2018-10-09 10:54:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (dns_notifytype_explicit);
|
|
|
|
}
|
2017-09-08 13:39:09 -07:00
|
|
|
|
1999-12-23 00:09:04 +00:00
|
|
|
isc_result_t
|
2017-09-08 13:39:09 -07:00
|
|
|
named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
|
2019-09-03 11:42:10 +02:00
|
|
|
const cfg_obj_t *zconfig, cfg_aclconfctx_t *ac,
|
|
|
|
dns_kasplist_t *kasplist, dns_zone_t *zone,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_zone_t *raw) {
|
|
|
|
isc_result_t result;
|
|
|
|
const char *zname;
|
|
|
|
dns_rdataclass_t zclass;
|
|
|
|
dns_rdataclass_t vclass;
|
|
|
|
const cfg_obj_t *maps[5];
|
|
|
|
const cfg_obj_t *nodefault[4];
|
|
|
|
const cfg_obj_t *zoptions = NULL;
|
|
|
|
const cfg_obj_t *options = NULL;
|
|
|
|
const cfg_obj_t *obj;
|
|
|
|
const char *filename = NULL;
|
|
|
|
const char *kaspname = NULL;
|
|
|
|
const char *dupcheck;
|
|
|
|
dns_notifytype_t notifytype = dns_notifytype_yes;
|
|
|
|
uint32_t count;
|
|
|
|
unsigned int dbargc;
|
|
|
|
char **dbargv;
|
|
|
|
static char default_dbtype[] = "rbt";
|
|
|
|
static char dlz_dbtype[] = "dlz";
|
|
|
|
char *cpval = default_dbtype;
|
|
|
|
isc_mem_t *mctx = dns_zone_getmctx(zone);
|
|
|
|
dns_dialuptype_t dialup = dns_dialuptype_no;
|
|
|
|
dns_zonetype_t ztype;
|
|
|
|
int i;
|
|
|
|
int32_t journal_size;
|
|
|
|
bool multi;
|
|
|
|
bool alt;
|
|
|
|
dns_view_t *view = NULL;
|
|
|
|
dns_kasp_t *kasp = NULL;
|
|
|
|
bool check = false, fail = false;
|
|
|
|
bool warn = false, ignore = false;
|
|
|
|
bool ixfrdiff;
|
|
|
|
dns_masterformat_t masterformat;
|
2014-04-17 17:10:29 -07:00
|
|
|
const dns_master_style_t *masterstyle = &dns_master_style_default;
|
2020-02-13 14:44:37 -08:00
|
|
|
isc_stats_t *zoneqrystats;
|
|
|
|
dns_stats_t *rcvquerystats;
|
|
|
|
dns_stats_t *dnssecsignstats;
|
|
|
|
dns_stats_t *dnssecrefreshstats;
|
|
|
|
dns_zonestat_level_t statlevel = dns_zonestat_none;
|
|
|
|
int seconds;
|
|
|
|
dns_zone_t *mayberaw = (raw != NULL) ? raw : zone;
|
|
|
|
isc_dscp_t dscp;
|
2000-07-31 19:36:48 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
i = 0;
|
|
|
|
if (zconfig != NULL) {
|
|
|
|
zoptions = cfg_tuple_get(zconfig, "options");
|
2012-06-20 14:13:12 -05:00
|
|
|
nodefault[i] = maps[i] = zoptions;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (vconfig != NULL) {
|
|
|
|
nodefault[i] = maps[i] = cfg_tuple_get(vconfig, "options");
|
|
|
|
i++;
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
|
|
|
if (config != NULL) {
|
|
|
|
(void)cfg_map_get(config, "options", &options);
|
2012-06-20 14:13:12 -05:00
|
|
|
if (options != NULL) {
|
|
|
|
nodefault[i] = maps[i] = options;
|
|
|
|
i++;
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
2012-06-20 14:13:12 -05:00
|
|
|
nodefault[i] = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
maps[i++] = named_g_defaults;
|
2011-03-11 06:11:27 +00:00
|
|
|
maps[i] = NULL;
|
2001-08-07 01:58:59 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (vconfig != NULL) {
|
2017-09-08 13:39:09 -07:00
|
|
|
RETERR(named_config_getclass(cfg_tuple_get(vconfig, "class"),
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_rdataclass_in, &vclass));
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2001-08-07 01:58:59 +00:00
|
|
|
vclass = dns_rdataclass_in;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-08-07 01:58:59 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure values common to all zone types.
|
|
|
|
*/
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(named_config_getclass(cfg_tuple_get(zconfig, "class"), vclass,
|
|
|
|
&zclass));
|
2001-03-04 21:21:39 +00:00
|
|
|
dns_zone_setclass(zone, zclass);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setclass(raw, zclass);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
ztype = zonetype_fromconfig(zoptions);
|
2011-08-30 05:16:15 +00:00
|
|
|
if (raw != NULL) {
|
|
|
|
dns_zone_settype(raw, ztype);
|
|
|
|
dns_zone_settype(zone, dns_zone_master);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_settype(zone, ztype);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-08-30 23:46:53 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "database", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2005-08-23 02:36:11 +00:00
|
|
|
cpval = isc_mem_strdup(mctx, cfg_obj_asstring(obj));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
if (cpval == NULL) {
|
2020-02-12 13:59:18 +01:00
|
|
|
return (ISC_R_NOMEMORY);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-08-23 02:36:11 +00:00
|
|
|
|
2012-12-06 12:39:52 -08:00
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "dlz", &obj);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
const char *dlzname = cfg_obj_asstring(obj);
|
2020-02-13 14:44:37 -08:00
|
|
|
size_t len;
|
2012-12-06 12:39:52 -08:00
|
|
|
|
|
|
|
if (cpval != default_dbtype) {
|
2020-02-12 13:59:18 +01:00
|
|
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
|
|
|
"zone '%s': both 'database' and 'dlz' "
|
|
|
|
"specified",
|
|
|
|
zname);
|
|
|
|
return (ISC_R_FAILURE);
|
2012-12-06 12:39:52 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
len = strlen(dlzname) + 5;
|
|
|
|
cpval = isc_mem_allocate(mctx, len);
|
|
|
|
snprintf(cpval, len, "dlz %s", dlzname);
|
|
|
|
}
|
|
|
|
|
2005-08-23 02:36:11 +00:00
|
|
|
result = strtoargv(mctx, cpval, &dbargc, &dbargv);
|
|
|
|
if (result != ISC_R_SUCCESS && cpval != default_dbtype) {
|
|
|
|
isc_mem_free(mctx, cpval);
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
2000-08-22 05:14:59 +00:00
|
|
|
/*
|
|
|
|
* ANSI C is strange here. There is no logical reason why (char **)
|
|
|
|
* cannot be promoted automatically to (const char * const *) by the
|
|
|
|
* compiler w/o generating a warning.
|
|
|
|
*/
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setdbtype(zone, dbargc, (const char *const *)dbargv);
|
2000-08-10 00:53:36 +00:00
|
|
|
isc_mem_put(mctx, dbargv, dbargc * sizeof(*dbargv));
|
2019-07-23 14:56:24 -04:00
|
|
|
if (cpval != default_dbtype && cpval != dlz_dbtype) {
|
2005-08-23 02:36:11 +00:00
|
|
|
isc_mem_free(mctx, cpval);
|
2019-07-23 14:56:24 -04:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "file", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2001-03-04 21:21:39 +00:00
|
|
|
filename = cfg_obj_asstring(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-06-20 01:05:33 +00:00
|
|
|
|
2010-07-11 00:12:57 +00:00
|
|
|
/*
|
|
|
|
* Unless we're using some alternative database, a master zone
|
|
|
|
* will be needing a master file.
|
|
|
|
*/
|
2010-09-15 03:32:34 +00:00
|
|
|
if (ztype == dns_zone_master && cpval == default_dbtype &&
|
|
|
|
filename == NULL) {
|
2017-09-08 13:39:09 -07:00
|
|
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2020-02-12 13:59:18 +01:00
|
|
|
"zone '%s': 'file' not specified", zname);
|
2010-09-15 03:32:34 +00:00
|
|
|
return (ISC_R_FAILURE);
|
2010-07-11 00:12:57 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (ztype == dns_zone_slave || ztype == dns_zone_mirror) {
|
2011-10-26 15:23:37 +00:00
|
|
|
masterformat = dns_masterformat_raw;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2011-10-26 15:23:37 +00:00
|
|
|
masterformat = dns_masterformat_text;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2005-06-20 01:05:33 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "masterfile-format", &obj);
|
2005-06-20 01:05:33 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2005-08-23 02:36:11 +00:00
|
|
|
const char *masterformatstr = cfg_obj_asstring(obj);
|
2005-06-20 01:05:33 +00:00
|
|
|
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(masterformatstr, "text") == 0) {
|
2005-06-20 01:05:33 +00:00
|
|
|
masterformat = dns_masterformat_text;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(masterformatstr, "raw") == 0) {
|
2005-06-20 01:05:33 +00:00
|
|
|
masterformat = dns_masterformat_raw;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(masterformatstr, "map") == 0) {
|
2013-01-24 14:20:48 -08:00
|
|
|
masterformat = dns_masterformat_map;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2005-06-20 01:05:33 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2005-06-20 01:05:33 +00:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
|
2014-04-17 17:10:29 -07:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "masterfile-style", &obj);
|
2014-04-17 17:10:29 -07:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
const char *masterstylestr = cfg_obj_asstring(obj);
|
|
|
|
|
|
|
|
if (masterformat != dns_masterformat_text) {
|
2017-09-08 13:39:09 -07:00
|
|
|
cfg_obj_log(obj, named_g_lctx, ISC_LOG_ERROR,
|
2014-04-17 17:10:29 -07:00
|
|
|
"zone '%s': 'masterfile-style' "
|
|
|
|
"can only be used with "
|
2020-02-12 13:59:18 +01:00
|
|
|
"'masterfile-format text'",
|
|
|
|
zname);
|
2014-04-17 17:10:29 -07:00
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
}
|
|
|
|
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(masterstylestr, "full") == 0) {
|
2014-04-17 17:10:29 -07:00
|
|
|
masterstyle = &dns_master_style_full;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(masterstylestr, "relative") == 0) {
|
2014-04-17 17:10:29 -07:00
|
|
|
masterstyle = &dns_master_style_default;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2014-04-17 17:10:29 -07:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2014-04-17 17:10:29 -07:00
|
|
|
}
|
|
|
|
|
2014-02-18 23:26:50 -08:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-zone-ttl", &obj);
|
2014-02-18 23:26:50 -08:00
|
|
|
if (result == ISC_R_SUCCESS && masterformat == dns_masterformat_map) {
|
2017-09-08 13:39:09 -07:00
|
|
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
|
2014-02-18 23:26:50 -08:00
|
|
|
"zone '%s': 'max-zone-ttl' is not compatible "
|
2020-02-12 13:59:18 +01:00
|
|
|
"with 'masterfile-format map'",
|
|
|
|
zname);
|
2014-02-18 23:26:50 -08:00
|
|
|
return (ISC_R_FAILURE);
|
|
|
|
} else if (result == ISC_R_SUCCESS) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_ttl_t maxttl = 0; /* unlimited */
|
2015-09-09 17:02:11 +10:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (cfg_obj_isduration(obj)) {
|
2019-09-02 15:46:28 +02:00
|
|
|
maxttl = cfg_obj_asduration(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-02-18 23:26:50 -08:00
|
|
|
dns_zone_setmaxttl(zone, maxttl);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2014-02-18 23:26:50 -08:00
|
|
|
dns_zone_setmaxttl(raw, maxttl);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2014-02-18 23:26:50 -08:00
|
|
|
}
|
|
|
|
|
2016-11-02 17:31:27 +11:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-records", &obj);
|
2016-11-02 17:31:27 +11:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
dns_zone_setmaxrecords(mayberaw, cfg_obj_asuint32(obj));
|
2020-02-13 21:48:23 +01:00
|
|
|
if (zone != mayberaw) {
|
2016-11-02 17:31:27 +11:00
|
|
|
dns_zone_setmaxrecords(zone, 0);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2016-11-02 17:31:27 +11:00
|
|
|
|
2012-10-02 23:44:03 -07:00
|
|
|
if (raw != NULL && filename != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
#define SIGNED ".signed"
|
|
|
|
size_t signedlen = strlen(filename) + sizeof(SIGNED);
|
2020-02-13 14:44:37 -08:00
|
|
|
char *signedname;
|
2011-08-30 05:16:15 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(dns_zone_setfile(raw, filename, masterformat,
|
|
|
|
masterstyle));
|
2011-08-30 05:16:15 +00:00
|
|
|
signedname = isc_mem_get(mctx, signedlen);
|
|
|
|
|
|
|
|
(void)snprintf(signedname, signedlen, "%s" SIGNED, filename);
|
2018-04-03 16:34:41 +02:00
|
|
|
result = dns_zone_setfile(zone, signedname,
|
|
|
|
dns_masterformat_raw, NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
isc_mem_put(mctx, signedname, signedlen);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2011-08-30 05:16:15 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(dns_zone_setfile(zone, filename, masterformat,
|
|
|
|
masterstyle));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2004-10-07 02:15:14 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "journal", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(dns_zone_setjournal(mayberaw, cfg_obj_asstring(obj)));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-10-07 02:15:14 +00:00
|
|
|
|
2011-08-30 05:16:15 +00:00
|
|
|
/*
|
|
|
|
* Notify messages are processed by the raw zone if it exists.
|
|
|
|
*/
|
2020-02-13 21:48:23 +01:00
|
|
|
if (ztype == dns_zone_slave || ztype == dns_zone_mirror) {
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(configure_zone_acl(
|
|
|
|
zconfig, vconfig, config, allow_notify, ac, mayberaw,
|
|
|
|
dns_zone_setnotifyacl, dns_zone_clearnotifyacl));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* XXXAG This probably does not make sense for stubs.
|
|
|
|
*/
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(configure_zone_acl(zconfig, vconfig, config, allow_query, ac,
|
|
|
|
zone, dns_zone_setqueryacl,
|
2000-05-25 19:27:48 +00:00
|
|
|
dns_zone_clearqueryacl));
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(configure_zone_acl(zconfig, vconfig, config, allow_query_on, ac,
|
|
|
|
zone, dns_zone_setqueryonacl,
|
2013-01-03 15:13:45 -08:00
|
|
|
dns_zone_clearqueryonacl));
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "dialup", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (cfg_obj_isboolean(obj)) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (cfg_obj_asboolean(obj)) {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_yes;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_no;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
} else {
|
2005-08-23 02:36:11 +00:00
|
|
|
const char *dialupstr = cfg_obj_asstring(obj);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(dialupstr, "notify") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_notify;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(dialupstr, "notify-passive") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_notifypassive;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(dialupstr, "refresh") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_refresh;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(dialupstr, "passive") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
dialup = dns_dialuptype_passive;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setdialup(raw, dialup);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-11-11 01:05:43 +00:00
|
|
|
dns_zone_setdialup(zone, dialup);
|
2000-05-25 19:27:48 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "zone-statistics", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2013-02-27 11:53:58 -08:00
|
|
|
if (cfg_obj_isboolean(obj)) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (cfg_obj_asboolean(obj)) {
|
2013-02-27 11:53:58 -08:00
|
|
|
statlevel = dns_zonestat_full;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2013-02-27 13:37:54 -08:00
|
|
|
statlevel = dns_zonestat_none;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-02-27 11:53:58 -08:00
|
|
|
} else {
|
|
|
|
const char *levelstr = cfg_obj_asstring(obj);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(levelstr, "full") == 0) {
|
2013-02-27 11:53:58 -08:00
|
|
|
statlevel = dns_zonestat_full;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(levelstr, "terse") == 0) {
|
2013-02-27 11:53:58 -08:00
|
|
|
statlevel = dns_zonestat_terse;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(levelstr, "none") == 0) {
|
2013-02-27 11:53:58 -08:00
|
|
|
statlevel = dns_zonestat_none;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2013-02-27 11:53:58 -08:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2013-02-27 11:53:58 -08:00
|
|
|
}
|
|
|
|
dns_zone_setstatlevel(zone, statlevel);
|
2012-11-14 12:44:15 -06:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
zoneqrystats = NULL;
|
2012-11-14 12:44:15 -06:00
|
|
|
rcvquerystats = NULL;
|
2019-06-19 16:02:50 +02:00
|
|
|
dnssecsignstats = NULL;
|
2019-06-21 10:30:05 +02:00
|
|
|
dnssecrefreshstats = NULL;
|
2013-02-27 11:53:58 -08:00
|
|
|
if (statlevel == dns_zonestat_full) {
|
2009-01-27 22:30:00 +00:00
|
|
|
RETERR(isc_stats_create(mctx, &zoneqrystats,
|
2017-09-08 13:39:09 -07:00
|
|
|
ns_statscounter_max));
|
2019-06-19 16:02:50 +02:00
|
|
|
RETERR(dns_rdatatypestats_create(mctx, &rcvquerystats));
|
|
|
|
RETERR(dns_dnssecsignstats_create(mctx, &dnssecsignstats));
|
2019-06-21 10:30:05 +02:00
|
|
|
RETERR(dns_dnssecsignstats_create(mctx, &dnssecrefreshstats));
|
2008-04-03 05:55:52 +00:00
|
|
|
}
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setrequeststats(zone, zoneqrystats);
|
2012-11-14 12:44:15 -06:00
|
|
|
dns_zone_setrcvquerystats(zone, rcvquerystats);
|
2019-06-19 16:02:50 +02:00
|
|
|
dns_zone_setdnssecsignstats(zone, dnssecsignstats);
|
2019-06-21 10:30:05 +02:00
|
|
|
dns_zone_setdnssecrefreshstats(zone, dnssecrefreshstats);
|
2012-11-14 12:44:15 -06:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (zoneqrystats != NULL) {
|
2009-01-27 22:30:00 +00:00
|
|
|
isc_stats_detach(&zoneqrystats);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-11-07 23:49:42 +00:00
|
|
|
|
2020-02-13 21:48:23 +01:00
|
|
|
if (rcvquerystats != NULL) {
|
2012-11-14 12:44:15 -06:00
|
|
|
dns_stats_detach(&rcvquerystats);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-11-14 12:44:15 -06:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
if (dnssecsignstats != NULL) {
|
2019-06-19 16:02:50 +02:00
|
|
|
dns_stats_detach(&dnssecsignstats);
|
|
|
|
}
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
if (dnssecrefreshstats != NULL) {
|
2019-06-21 10:30:05 +02:00
|
|
|
dns_stats_detach(&dnssecrefreshstats);
|
|
|
|
}
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure master functionality. This applies
|
|
|
|
* to primary masters (type "master") and slaves
|
|
|
|
* acting as masters (type "slave"), but not to stubs.
|
|
|
|
*/
|
2011-02-23 03:08:11 +00:00
|
|
|
if (ztype != dns_zone_stub && ztype != dns_zone_staticstub &&
|
2020-02-13 14:44:37 -08:00
|
|
|
ztype != dns_zone_redirect)
|
|
|
|
{
|
2019-09-03 11:42:10 +02:00
|
|
|
obj = NULL;
|
2019-11-05 17:22:35 +01:00
|
|
|
result = named_config_get(maps, "dnssec-policy", &obj);
|
2019-09-03 11:42:10 +02:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
kaspname = cfg_obj_asstring(obj);
|
2019-11-05 17:22:35 +01:00
|
|
|
if (strcmp(kaspname, "none") != 0) {
|
|
|
|
result = dns_kasplist_find(kasplist, kaspname,
|
|
|
|
&kasp);
|
|
|
|
if (result != ISC_R_SUCCESS) {
|
|
|
|
cfg_obj_log(obj, named_g_lctx,
|
|
|
|
ISC_LOG_ERROR,
|
|
|
|
"'dnssec-policy '%s' not "
|
2020-02-12 13:59:18 +01:00
|
|
|
"found ",
|
|
|
|
kaspname);
|
2019-11-05 17:22:35 +01:00
|
|
|
RETERR(result);
|
|
|
|
}
|
|
|
|
dns_zone_setkasp(zone, kasp);
|
2019-09-03 11:42:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "notify", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-03-04 21:21:39 +00:00
|
|
|
if (cfg_obj_isboolean(obj)) {
|
2020-02-13 21:48:23 +01:00
|
|
|
if (cfg_obj_asboolean(obj)) {
|
2001-03-04 21:21:39 +00:00
|
|
|
notifytype = dns_notifytype_yes;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
notifytype = dns_notifytype_no;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
} else {
|
2005-08-23 02:36:11 +00:00
|
|
|
const char *notifystr = cfg_obj_asstring(obj);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(notifystr, "explicit") == 0) {
|
2001-03-04 21:21:39 +00:00
|
|
|
notifytype = dns_notifytype_explicit;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(notifystr, "master-only") == 0) {
|
2004-03-30 02:13:45 +00:00
|
|
|
notifytype = dns_notifytype_masteronly;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2001-03-04 21:21:39 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
}
|
2020-02-13 14:44:37 -08:00
|
|
|
notifytype = process_notifytype(notifytype, ztype, zname,
|
|
|
|
nodefault);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setnotifytype(raw, dns_notifytype_no);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-07-24 22:59:44 +00:00
|
|
|
dns_zone_setnotifytype(zone, notifytype);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "also-notify", &obj);
|
2014-01-20 15:53:51 -08:00
|
|
|
if (result == ISC_R_SUCCESS &&
|
|
|
|
(notifytype == dns_notifytype_yes ||
|
|
|
|
notifytype == dns_notifytype_explicit ||
|
|
|
|
(notifytype == dns_notifytype_masteronly &&
|
2020-02-13 14:44:37 -08:00
|
|
|
ztype == dns_zone_master)))
|
|
|
|
{
|
2016-05-26 21:23:19 +02:00
|
|
|
dns_ipkeylist_t ipkl;
|
2016-06-22 10:49:25 +02:00
|
|
|
dns_ipkeylist_init(&ipkl);
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
RETERR(named_config_getipandkeylist(config, obj, mctx,
|
2020-02-12 13:59:18 +01:00
|
|
|
&ipkl));
|
|
|
|
result = dns_zone_setalsonotifydscpkeys(
|
|
|
|
zone, ipkl.addrs, ipkl.dscps, ipkl.keys,
|
|
|
|
ipkl.count);
|
2016-05-26 21:23:19 +02:00
|
|
|
dns_ipkeylist_clear(mctx, &ipkl);
|
2011-05-06 21:23:51 +00:00
|
|
|
RETERR(result);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2000-05-25 19:27:48 +00:00
|
|
|
RETERR(dns_zone_setalsonotify(zone, NULL, 0));
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "notify-source", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-11-30 01:59:49 +00:00
|
|
|
RETERR(dns_zone_setnotifysrc4(zone, cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setnotifysrc4dscp(zone, dscp));
|
2017-09-08 13:39:09 -07:00
|
|
|
named_add_reserved_dispatch(named_g_server,
|
|
|
|
cfg_obj_assockaddr(obj));
|
2000-11-25 02:43:56 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "notify-source-v6", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-11-30 01:59:49 +00:00
|
|
|
RETERR(dns_zone_setnotifysrc6(zone, cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setnotifysrc6dscp(zone, dscp));
|
2017-09-08 13:39:09 -07:00
|
|
|
named_add_reserved_dispatch(named_g_server,
|
|
|
|
cfg_obj_assockaddr(obj));
|
2000-11-25 02:43:56 +00:00
|
|
|
|
2007-09-18 00:22:31 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "notify-to-soa", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2007-09-18 00:22:31 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_NOTIFYTOSOA,
|
|
|
|
cfg_obj_asboolean(obj));
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
dns_zone_setisself(zone, isself, named_g_server->interfacemgr);
|
2005-02-10 05:53:43 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(configure_zone_acl(
|
|
|
|
zconfig, vconfig, config, allow_transfer, ac, zone,
|
|
|
|
dns_zone_setxfracl, dns_zone_clearxfracl));
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-transfer-time-out", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-06-04 21:51:27 +00:00
|
|
|
dns_zone_setmaxxfrout(zone, cfg_obj_asuint32(obj) * 60);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-transfer-idle-out", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2001-06-04 21:51:27 +00:00
|
|
|
dns_zone_setidleout(zone, cfg_obj_asuint32(obj) * 60);
|
2001-08-30 05:23:00 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-journal-size", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setjournalsize(raw, -1);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-09-01 01:43:24 +00:00
|
|
|
dns_zone_setjournalsize(zone, -1);
|
|
|
|
if (cfg_obj_isstring(obj)) {
|
|
|
|
const char *str = cfg_obj_asstring(obj);
|
2017-05-02 13:23:08 -07:00
|
|
|
if (strcasecmp(str, "unlimited") == 0) {
|
|
|
|
journal_size = DNS_JOURNAL_SIZE_MAX;
|
|
|
|
} else {
|
|
|
|
INSIST(strcasecmp(str, "default") == 0);
|
|
|
|
journal_size = -1;
|
|
|
|
}
|
2001-09-01 01:43:24 +00:00
|
|
|
} else {
|
|
|
|
isc_resourcevalue_t value;
|
|
|
|
value = cfg_obj_asuint64(obj);
|
2017-05-02 13:23:08 -07:00
|
|
|
if (value > DNS_JOURNAL_SIZE_MAX) {
|
2020-02-12 13:59:18 +01:00
|
|
|
cfg_obj_log(obj, named_g_lctx, ISC_LOG_ERROR,
|
2001-09-01 01:43:24 +00:00
|
|
|
"'max-journal-size "
|
2018-03-28 14:56:40 +02:00
|
|
|
"%" PRId64 "' "
|
2001-09-04 19:20:54 +00:00
|
|
|
"is too large",
|
2001-09-01 01:43:24 +00:00
|
|
|
value);
|
|
|
|
RETERR(ISC_R_RANGE);
|
2001-08-30 05:23:00 +00:00
|
|
|
}
|
2018-03-28 14:19:37 +02:00
|
|
|
journal_size = (uint32_t)value;
|
2001-09-01 01:43:24 +00:00
|
|
|
}
|
2020-02-13 21:48:23 +01:00
|
|
|
if (raw != NULL) {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setjournalsize(raw, journal_size);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2001-09-01 01:43:24 +00:00
|
|
|
dns_zone_setjournalsize(zone, journal_size);
|
2001-09-08 00:21:49 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "ixfr-from-differences", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2017-12-15 01:47:05 -08:00
|
|
|
if (cfg_obj_isboolean(obj)) {
|
2004-10-14 00:49:34 +00:00
|
|
|
ixfrdiff = cfg_obj_asboolean(obj);
|
2020-02-12 13:59:18 +01:00
|
|
|
} else if ((strcasecmp(cfg_obj_asstring(obj), "primary") == 0 ||
|
|
|
|
strcasecmp(cfg_obj_asstring(obj), "master") == 0) &&
|
2020-02-13 14:44:37 -08:00
|
|
|
ztype == dns_zone_master)
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
ixfrdiff = true;
|
2020-02-12 13:59:18 +01:00
|
|
|
} else if ((strcasecmp(cfg_obj_asstring(obj), "secondary") ==
|
|
|
|
0 ||
|
|
|
|
strcasecmp(cfg_obj_asstring(obj), "slave") == 0) &&
|
2020-02-13 14:44:37 -08:00
|
|
|
ztype == dns_zone_slave)
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
ixfrdiff = true;
|
2017-12-15 01:47:05 -08:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
ixfrdiff = false;
|
2017-12-15 01:47:05 -08:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
if (raw != NULL) {
|
|
|
|
dns_zone_setoption(raw, DNS_ZONEOPT_IXFRFROMDIFFS,
|
2018-04-17 08:29:14 -07:00
|
|
|
true);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS,
|
2018-04-17 08:29:14 -07:00
|
|
|
false);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS,
|
|
|
|
ixfrdiff);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2004-02-27 20:41:51 +00:00
|
|
|
|
2014-08-06 11:50:40 +10:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "request-expire", &obj);
|
2014-08-06 11:50:40 +10:00
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_zone_setrequestexpire(zone, cfg_obj_asboolean(obj));
|
|
|
|
|
2011-09-06 22:29:33 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "request-ixfr", &obj);
|
2011-09-06 22:29:33 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS);
|
|
|
|
dns_zone_setrequestixfr(zone, cfg_obj_asboolean(obj));
|
|
|
|
|
2004-02-27 20:41:51 +00:00
|
|
|
checknames(ztype, maps, &obj);
|
|
|
|
INSIST(obj != NULL);
|
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = false;
|
|
|
|
check = true;
|
2004-02-27 20:41:51 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = true;
|
2004-02-27 20:41:51 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = false;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2004-02-27 20:41:51 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
if (raw != NULL) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMES, check);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(raw, DNS_ZONEOPT_CHECKNAMESFAIL,
|
|
|
|
fail);
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES, false);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL,
|
2018-04-17 08:29:14 -07:00
|
|
|
false);
|
2011-08-30 05:16:15 +00:00
|
|
|
} else {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES, check);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL,
|
|
|
|
fail);
|
|
|
|
}
|
2005-01-11 23:10:06 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "notify-delay", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2005-01-11 23:10:06 +00:00
|
|
|
dns_zone_setnotifydelay(zone, cfg_obj_asuint32(obj));
|
|
|
|
|
2005-08-24 23:54:04 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-sibling", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-01-18 23:46:58 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSIBLING,
|
2005-08-24 23:54:04 +00:00
|
|
|
cfg_obj_asboolean(obj));
|
2006-01-05 02:19:02 +00:00
|
|
|
|
2013-04-30 13:49:41 +10:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-spf", &obj);
|
2013-04-30 13:49:41 +10:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
check = true;
|
2013-04-30 13:49:41 +10:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
check = false;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2013-04-30 13:49:41 +10:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2013-04-30 13:49:41 +10:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_CHECKSPF, check);
|
|
|
|
|
2006-01-05 02:19:02 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "zero-no-soa-ttl", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2006-01-05 02:19:02 +00:00
|
|
|
dns_zone_setzeronosoattl(zone, cfg_obj_asboolean(obj));
|
2008-09-24 02:46:23 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "nsec3-test-zone", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-09-24 02:46:23 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_NSEC3TESTZONE,
|
|
|
|
cfg_obj_asboolean(obj));
|
2011-02-23 03:08:11 +00:00
|
|
|
} else if (ztype == dns_zone_redirect) {
|
|
|
|
dns_zone_setnotifytype(zone, dns_notifytype_no);
|
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-journal-size", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-02-23 03:08:11 +00:00
|
|
|
dns_zone_setjournalsize(zone, -1);
|
|
|
|
if (cfg_obj_isstring(obj)) {
|
|
|
|
const char *str = cfg_obj_asstring(obj);
|
2017-05-02 13:23:08 -07:00
|
|
|
if (strcasecmp(str, "unlimited") == 0) {
|
|
|
|
journal_size = DNS_JOURNAL_SIZE_MAX;
|
|
|
|
} else {
|
|
|
|
INSIST(strcasecmp(str, "default") == 0);
|
|
|
|
journal_size = -1;
|
|
|
|
}
|
2011-02-23 03:08:11 +00:00
|
|
|
} else {
|
|
|
|
isc_resourcevalue_t value;
|
|
|
|
value = cfg_obj_asuint64(obj);
|
2017-05-02 13:23:08 -07:00
|
|
|
if (value > DNS_JOURNAL_SIZE_MAX) {
|
2020-02-12 13:59:18 +01:00
|
|
|
cfg_obj_log(obj, named_g_lctx, ISC_LOG_ERROR,
|
2011-02-23 03:08:11 +00:00
|
|
|
"'max-journal-size "
|
2018-03-28 14:56:40 +02:00
|
|
|
"%" PRId64 "' "
|
2011-02-23 03:08:11 +00:00
|
|
|
"is too large",
|
|
|
|
value);
|
|
|
|
RETERR(ISC_R_RANGE);
|
|
|
|
}
|
2018-03-28 14:19:37 +02:00
|
|
|
journal_size = (uint32_t)value;
|
2011-02-23 03:08:11 +00:00
|
|
|
}
|
|
|
|
dns_zone_setjournalsize(zone, journal_size);
|
2000-05-25 19:27:48 +00:00
|
|
|
}
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure update-related options. These apply to
|
|
|
|
* primary masters only.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
if (ztype == dns_zone_master) {
|
2000-12-01 18:22:17 +00:00
|
|
|
dns_acl_t *updateacl;
|
2009-06-10 00:27:22 +00:00
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
RETERR(configure_zone_acl(
|
|
|
|
zconfig, vconfig, config, allow_update, ac, mayberaw,
|
|
|
|
dns_zone_setupdateacl, dns_zone_clearupdateacl));
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2011-08-30 05:16:15 +00:00
|
|
|
updateacl = dns_zone_getupdateacl(mayberaw);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (updateacl != NULL && dns_acl_isinsecure(updateacl)) {
|
2017-09-08 13:39:09 -07:00
|
|
|
isc_log_write(named_g_lctx, DNS_LOGCATEGORY_SECURITY,
|
|
|
|
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
|
2016-12-27 09:49:02 +11:00
|
|
|
"zone '%s' allows unsigned updates "
|
|
|
|
"from remote hosts, which is insecure",
|
2001-03-04 21:21:39 +00:00
|
|
|
zname);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2008-01-18 23:46:58 +00:00
|
|
|
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(configure_zone_ssutable(zoptions, mayberaw, zname));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ztype == dns_zone_master || raw != NULL) {
|
2018-05-03 16:43:15 +10:00
|
|
|
const cfg_obj_t *validity, *resign;
|
2020-02-13 14:44:37 -08:00
|
|
|
bool allow = false, maint = false;
|
|
|
|
bool sigvalinsecs;
|
2001-03-04 21:21:39 +00:00
|
|
|
|
2019-10-17 11:38:56 +02:00
|
|
|
if (kasp) {
|
2020-02-12 13:59:18 +01:00
|
|
|
seconds = (uint32_t)dns_kasp_sigvalidity_dnskey(kasp);
|
2019-10-17 11:38:56 +02:00
|
|
|
} else {
|
|
|
|
obj = NULL;
|
|
|
|
result = named_config_get(maps, "dnskey-sig-validity",
|
|
|
|
&obj);
|
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
seconds = cfg_obj_asuint32(obj) * 86400;
|
|
|
|
}
|
2018-03-12 22:14:26 -07:00
|
|
|
dns_zone_setkeyvalidityinterval(zone, seconds);
|
|
|
|
|
2019-10-17 11:38:56 +02:00
|
|
|
if (kasp) {
|
2020-02-12 13:59:18 +01:00
|
|
|
seconds = (uint32_t)dns_kasp_sigvalidity(kasp);
|
2019-10-17 11:38:56 +02:00
|
|
|
dns_zone_setsigvalidityinterval(zone, seconds);
|
2020-02-12 13:59:18 +01:00
|
|
|
seconds = (uint32_t)dns_kasp_sigrefresh(kasp);
|
2019-10-17 11:38:56 +02:00
|
|
|
dns_zone_setsigresigninginterval(zone, seconds);
|
|
|
|
} else {
|
|
|
|
obj = NULL;
|
|
|
|
result = named_config_get(maps, "sig-validity-interval",
|
2020-02-12 13:59:18 +01:00
|
|
|
&obj);
|
2019-10-17 11:38:56 +02:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
|
2020-02-12 13:59:18 +01:00
|
|
|
sigvalinsecs = ns_server_getoption(
|
|
|
|
named_g_server->sctx, NS_SERVER_SIGVALINSECS);
|
2019-10-17 11:38:56 +02:00
|
|
|
validity = cfg_tuple_get(obj, "validity");
|
|
|
|
seconds = cfg_obj_asuint32(validity);
|
|
|
|
if (!sigvalinsecs) {
|
|
|
|
seconds *= 86400;
|
|
|
|
}
|
|
|
|
dns_zone_setsigvalidityinterval(zone, seconds);
|
|
|
|
|
|
|
|
resign = cfg_tuple_get(obj, "re-sign");
|
|
|
|
if (cfg_obj_isvoid(resign)) {
|
|
|
|
seconds /= 4;
|
|
|
|
} else if (!sigvalinsecs) {
|
|
|
|
seconds = cfg_obj_asuint32(resign);
|
|
|
|
if (seconds > 7 * 86400) {
|
|
|
|
seconds *= 86400;
|
|
|
|
} else {
|
|
|
|
seconds *= 3600;
|
|
|
|
}
|
2008-04-02 02:37:42 +00:00
|
|
|
} else {
|
2019-10-17 11:38:56 +02:00
|
|
|
seconds = cfg_obj_asuint32(resign);
|
2008-04-02 02:37:42 +00:00
|
|
|
}
|
2019-10-17 11:38:56 +02:00
|
|
|
dns_zone_setsigresigninginterval(zone, seconds);
|
2008-04-02 02:37:42 +00:00
|
|
|
}
|
2002-01-21 11:00:25 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "key-directory", &obj);
|
2002-01-21 11:00:25 +00:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
filename = cfg_obj_asstring(obj);
|
|
|
|
RETERR(dns_zone_setkeydirectory(zone, filename));
|
|
|
|
}
|
2005-05-19 04:59:05 +00:00
|
|
|
|
2008-04-02 02:37:42 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "sig-signing-signatures", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-04-02 02:37:42 +00:00
|
|
|
dns_zone_setsignatures(zone, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "sig-signing-nodes", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-04-02 02:37:42 +00:00
|
|
|
dns_zone_setnodes(zone, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "sig-signing-type", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-04-02 02:37:42 +00:00
|
|
|
dns_zone_setprivatetype(zone, cfg_obj_asuint32(obj));
|
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "update-check-ksk", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2008-04-02 02:37:42 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_UPDATECHECKKSK,
|
|
|
|
cfg_obj_asboolean(obj));
|
2019-10-17 11:38:56 +02:00
|
|
|
/*
|
|
|
|
* This setting will be ignored if dnssec-policy is used.
|
|
|
|
* named-checkconf will error if both are configured.
|
|
|
|
*/
|
2008-04-02 02:37:42 +00:00
|
|
|
|
2009-10-10 01:48:00 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "dnssec-dnskey-kskonly", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2009-10-10 01:48:00 +00:00
|
|
|
dns_zone_setoption(zone, DNS_ZONEOPT_DNSKEYKSKONLY,
|
|
|
|
cfg_obj_asboolean(obj));
|
2019-10-17 11:38:56 +02:00
|
|
|
/*
|
|
|
|
* This setting will be ignored if dnssec-policy is used.
|
|
|
|
* named-checkconf will error if both are configured.
|
|
|
|
*/
|
2011-04-29 21:37:15 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "dnssec-loadkeys-interval",
|
|
|
|
&obj);
|
2011-04-29 21:37:15 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
RETERR(dns_zone_setrefreshkeyinterval(zone,
|
|
|
|
cfg_obj_asuint32(obj)));
|
2011-08-30 05:16:15 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "auto-dnssec", &obj);
|
2019-10-17 11:38:56 +02:00
|
|
|
if (dns_zone_getkasp(zone) != NULL) {
|
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, true);
|
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, true);
|
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, true);
|
|
|
|
} else if (result == ISC_R_SUCCESS) {
|
2011-08-30 05:16:15 +00:00
|
|
|
const char *arg = cfg_obj_asstring(obj);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(arg, "allow") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
allow = true;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(arg, "maintain") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
allow = maint = true;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(arg, "off") == 0) {
|
|
|
|
} else {
|
2011-08-30 05:16:15 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_ALLOW, allow);
|
2019-10-17 11:38:56 +02:00
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_CREATE, false);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_MAINTAIN, maint);
|
|
|
|
}
|
2011-08-30 23:46:53 +00:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
|
2018-10-09 10:54:51 +02:00
|
|
|
if (ztype == dns_zone_slave || ztype == dns_zone_mirror) {
|
2008-04-02 02:37:42 +00:00
|
|
|
RETERR(configure_zone_acl(zconfig, vconfig, config,
|
2020-02-12 13:59:18 +01:00
|
|
|
allow_update_forwarding, ac, mayberaw,
|
|
|
|
dns_zone_setforwardacl,
|
2008-04-02 02:37:42 +00:00
|
|
|
dns_zone_clearforwardacl));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*%
|
|
|
|
* Primary master functionality.
|
|
|
|
*/
|
|
|
|
if (ztype == dns_zone_master) {
|
2005-01-09 23:40:04 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-wildcard", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2005-01-09 23:40:04 +00:00
|
|
|
check = cfg_obj_asboolean(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
check = false;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKWILDCARD, check);
|
2005-05-19 04:59:05 +00:00
|
|
|
|
2012-06-20 14:13:12 -05:00
|
|
|
/*
|
2013-01-24 14:20:48 -08:00
|
|
|
* With map files, the default is ignore duplicate
|
2012-06-20 14:13:12 -05:00
|
|
|
* records. With other master formats, the default is
|
|
|
|
* taken from the global configuration.
|
|
|
|
*/
|
2009-12-04 21:09:34 +00:00
|
|
|
obj = NULL;
|
2013-01-24 14:20:48 -08:00
|
|
|
if (masterformat != dns_masterformat_map) {
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-dup-records",
|
|
|
|
&obj);
|
2012-06-20 14:13:12 -05:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
dupcheck = cfg_obj_asstring(obj);
|
|
|
|
} else {
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(nodefault,
|
2020-02-12 13:59:18 +01:00
|
|
|
"check-dup-records", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2012-06-20 14:13:12 -05:00
|
|
|
dupcheck = cfg_obj_asstring(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2012-06-20 14:13:12 -05:00
|
|
|
dupcheck = "ignore";
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-06-20 14:13:12 -05:00
|
|
|
}
|
|
|
|
if (strcasecmp(dupcheck, "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = false;
|
|
|
|
check = true;
|
2012-06-20 14:13:12 -05:00
|
|
|
} else if (strcasecmp(dupcheck, "fail") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = true;
|
2012-06-20 14:13:12 -05:00
|
|
|
} else if (strcasecmp(dupcheck, "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = false;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2009-12-04 21:09:34 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRR, check);
|
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKDUPRRFAIL, fail);
|
2009-12-04 21:09:34 +00:00
|
|
|
|
2005-05-19 04:59:05 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-mx", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2005-05-19 04:59:05 +00:00
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = false;
|
|
|
|
check = true;
|
2005-05-19 04:59:05 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = true;
|
2005-05-19 04:59:05 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
fail = check = false;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2005-05-19 04:59:05 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMX, check);
|
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKMXFAIL, fail);
|
2005-05-19 04:59:05 +00:00
|
|
|
|
2012-06-20 14:13:12 -05:00
|
|
|
/*
|
2013-01-24 14:20:48 -08:00
|
|
|
* With map files, the default is *not* to check
|
2012-06-20 14:13:12 -05:00
|
|
|
* integrity. With other master formats, the default is
|
|
|
|
* taken from the global configuration.
|
|
|
|
*/
|
2005-05-19 04:59:05 +00:00
|
|
|
obj = NULL;
|
2013-01-24 14:20:48 -08:00
|
|
|
if (masterformat != dns_masterformat_map) {
|
2020-02-13 14:44:37 -08:00
|
|
|
result = named_config_get(maps, "check-integrity",
|
|
|
|
&obj);
|
2012-06-20 14:13:12 -05:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
|
|
|
|
cfg_obj_asboolean(obj));
|
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
check = false;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(nodefault, "check-integrity",
|
2020-02-12 13:59:18 +01:00
|
|
|
&obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result == ISC_R_SUCCESS) {
|
2012-06-20 14:13:12 -05:00
|
|
|
check = cfg_obj_asboolean(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-06-20 14:13:12 -05:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_CHECKINTEGRITY,
|
|
|
|
check);
|
|
|
|
}
|
2006-01-05 23:45:34 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-mx-cname", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2006-01-05 23:45:34 +00:00
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = true;
|
|
|
|
ignore = false;
|
2006-01-05 23:45:34 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = ignore = false;
|
2006-01-05 23:45:34 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = ignore = true;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2006-01-05 23:45:34 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNMXCNAME, warn);
|
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNOREMXCNAME, ignore);
|
2006-01-05 23:45:34 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "check-srv-cname", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2006-01-05 23:45:34 +00:00
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = true;
|
|
|
|
ignore = false;
|
2006-01-05 23:45:34 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = ignore = false;
|
2006-01-05 23:45:34 +00:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) {
|
2018-04-17 08:29:14 -07:00
|
|
|
warn = ignore = true;
|
2018-11-07 15:00:07 +07:00
|
|
|
} else {
|
2006-01-05 23:45:34 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_WARNSRVCNAME, warn);
|
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_IGNORESRVCNAME,
|
|
|
|
ignore);
|
2009-10-08 23:13:07 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "dnssec-secure-to-insecure",
|
|
|
|
&obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_SECURETOINSECURE,
|
2009-10-08 23:13:07 +00:00
|
|
|
cfg_obj_asboolean(obj));
|
2009-10-12 20:48:12 +00:00
|
|
|
|
2011-05-23 20:10:03 +00:00
|
|
|
obj = NULL;
|
|
|
|
result = cfg_map_get(zoptions, "dnssec-update-mode", &obj);
|
|
|
|
if (result == ISC_R_SUCCESS) {
|
|
|
|
const char *arg = cfg_obj_asstring(obj);
|
2018-11-07 15:00:07 +07:00
|
|
|
if (strcasecmp(arg, "no-resign") == 0) {
|
2011-05-23 20:10:03 +00:00
|
|
|
dns_zone_setkeyopt(zone, DNS_ZONEKEY_NORESIGN,
|
2018-04-17 08:29:14 -07:00
|
|
|
true);
|
2018-11-07 15:00:07 +07:00
|
|
|
} else if (strcasecmp(arg, "maintain") == 0) {
|
|
|
|
} else {
|
2011-05-23 20:10:03 +00:00
|
|
|
INSIST(0);
|
2018-11-07 15:00:07 +07:00
|
|
|
ISC_UNREACHABLE();
|
|
|
|
}
|
2009-10-12 23:48:02 +00:00
|
|
|
}
|
2011-07-01 02:25:48 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "serial-update-method", &obj);
|
2011-07-01 02:25:48 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (strcasecmp(cfg_obj_asstring(obj), "unixtime") == 0) {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setserialupdatemethod(
|
|
|
|
zone, dns_updatemethod_unixtime);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else if (strcasecmp(cfg_obj_asstring(obj), "date") == 0) {
|
2014-04-17 16:05:50 -07:00
|
|
|
dns_zone_setserialupdatemethod(zone,
|
|
|
|
dns_updatemethod_date);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2020-02-12 13:59:18 +01:00
|
|
|
dns_zone_setserialupdatemethod(
|
|
|
|
zone, dns_updatemethod_increment);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-25 19:27:48 +00:00
|
|
|
}
|
2000-03-06 19:06:07 +00:00
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
/*
|
|
|
|
* Configure slave functionality.
|
|
|
|
*/
|
2001-03-04 21:21:39 +00:00
|
|
|
switch (ztype) {
|
2018-10-09 10:54:51 +02:00
|
|
|
case dns_zone_mirror:
|
2018-10-09 10:54:51 +02:00
|
|
|
/*
|
|
|
|
* Disable outgoing zone transfers for mirror zones unless they
|
|
|
|
* are explicitly enabled by zone configuration.
|
|
|
|
*/
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(zoptions, "allow-transfer", &obj);
|
|
|
|
if (obj == NULL) {
|
|
|
|
dns_acl_t *none;
|
|
|
|
RETERR(dns_acl_none(mctx, &none));
|
|
|
|
dns_zone_setxfracl(zone, none);
|
|
|
|
dns_acl_detach(&none);
|
|
|
|
}
|
2020-02-13 21:48:23 +01:00
|
|
|
/* FALLTHROUGH */
|
2018-10-09 10:54:51 +02:00
|
|
|
case dns_zone_slave:
|
2001-03-04 21:21:39 +00:00
|
|
|
case dns_zone_stub:
|
2011-02-23 03:08:11 +00:00
|
|
|
case dns_zone_redirect:
|
2005-11-30 03:33:49 +00:00
|
|
|
count = 0;
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2011-03-11 06:11:27 +00:00
|
|
|
(void)cfg_map_get(zoptions, "masters", &obj);
|
2018-10-09 10:54:51 +02:00
|
|
|
/*
|
|
|
|
* Use the built-in master server list if one was not
|
|
|
|
* explicitly specified and this is a root zone mirror.
|
|
|
|
*/
|
|
|
|
if (obj == NULL && ztype == dns_zone_mirror &&
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_name_equal(dns_zone_getorigin(zone), dns_rootname))
|
|
|
|
{
|
2020-02-12 13:59:18 +01:00
|
|
|
result = named_config_getmastersdef(
|
|
|
|
named_g_config, DEFAULT_IANA_ROOT_ZONE_MASTERS,
|
|
|
|
&obj);
|
2018-10-09 10:54:51 +02:00
|
|
|
RETERR(result);
|
|
|
|
}
|
2001-03-04 21:21:39 +00:00
|
|
|
if (obj != NULL) {
|
2016-05-26 21:23:19 +02:00
|
|
|
dns_ipkeylist_t ipkl;
|
2016-06-22 10:49:25 +02:00
|
|
|
dns_ipkeylist_init(&ipkl);
|
|
|
|
|
2017-09-08 13:39:09 -07:00
|
|
|
RETERR(named_config_getipandkeylist(config, obj, mctx,
|
2020-02-12 13:59:18 +01:00
|
|
|
&ipkl));
|
|
|
|
result = dns_zone_setmasterswithkeys(
|
|
|
|
mayberaw, ipkl.addrs, ipkl.keys, ipkl.count);
|
2018-02-15 14:56:13 +11:00
|
|
|
count = ipkl.count;
|
2016-05-26 21:23:19 +02:00
|
|
|
dns_ipkeylist_clear(mctx, &ipkl);
|
|
|
|
RETERR(result);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2011-08-30 05:16:15 +00:00
|
|
|
result = dns_zone_setmasters(mayberaw, NULL, 0);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2000-05-25 19:27:48 +00:00
|
|
|
RETERR(result);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
multi = false;
|
2002-07-29 06:58:46 +00:00
|
|
|
if (count > 1) {
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "multi-master", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2002-07-29 06:58:46 +00:00
|
|
|
multi = cfg_obj_asboolean(obj);
|
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_MULTIMASTER, multi);
|
2002-07-29 06:58:46 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-transfer-time-in", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setmaxxfrin(mayberaw, cfg_obj_asuint32(obj) * 60);
|
2000-01-31 19:53:14 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-transfer-idle-in", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setidlein(mayberaw, cfg_obj_asuint32(obj) * 60);
|
1999-12-16 23:11:07 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-refresh-time", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setmaxrefreshtime(mayberaw, cfg_obj_asuint32(obj));
|
2000-08-02 22:29:16 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "min-refresh-time", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setminrefreshtime(mayberaw, cfg_obj_asuint32(obj));
|
2000-08-02 22:29:16 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "max-retry-time", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setmaxretrytime(mayberaw, cfg_obj_asuint32(obj));
|
2000-08-02 22:29:16 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "min-retry-time", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setminretrytime(mayberaw, cfg_obj_asuint32(obj));
|
2000-08-02 22:29:16 +00:00
|
|
|
|
2001-10-11 01:55:03 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "transfer-source", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(dns_zone_setxfrsource4(mayberaw,
|
|
|
|
cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setxfrsource4dscp(mayberaw, dscp));
|
2017-09-08 13:39:09 -07:00
|
|
|
named_add_reserved_dispatch(named_g_server,
|
|
|
|
cfg_obj_assockaddr(obj));
|
2001-10-11 01:55:03 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "transfer-source-v6", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(dns_zone_setxfrsource6(mayberaw,
|
|
|
|
cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setxfrsource6dscp(mayberaw, dscp));
|
2017-09-08 13:39:09 -07:00
|
|
|
named_add_reserved_dispatch(named_g_server,
|
|
|
|
cfg_obj_assockaddr(obj));
|
2001-10-11 01:55:03 +00:00
|
|
|
|
2003-02-26 23:29:00 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "alt-transfer-source", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(dns_zone_setaltxfrsource4(mayberaw,
|
2011-08-30 23:46:53 +00:00
|
|
|
cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setaltxfrsource4dscp(mayberaw, dscp));
|
2003-02-26 23:29:00 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
result = named_config_get(maps, "alt-transfer-source-v6", &obj);
|
2011-03-11 06:11:27 +00:00
|
|
|
INSIST(result == ISC_R_SUCCESS && obj != NULL);
|
2011-08-30 05:16:15 +00:00
|
|
|
RETERR(dns_zone_setaltxfrsource6(mayberaw,
|
2011-08-30 23:46:53 +00:00
|
|
|
cfg_obj_assockaddr(obj)));
|
2013-03-22 12:27:54 -07:00
|
|
|
dscp = cfg_obj_getdscp(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (dscp == -1) {
|
2017-09-08 13:39:09 -07:00
|
|
|
dscp = named_g_dscp;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2013-03-22 12:27:54 -07:00
|
|
|
RETERR(dns_zone_setaltxfrsource6dscp(mayberaw, dscp));
|
2003-02-26 23:29:00 +00:00
|
|
|
|
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
(void)named_config_get(maps, "use-alt-transfer-source", &obj);
|
2003-02-26 23:29:00 +00:00
|
|
|
if (obj == NULL) {
|
|
|
|
/*
|
|
|
|
* Default off when views are in use otherwise
|
2003-08-08 22:46:37 +00:00
|
|
|
* on for BIND 8 compatibility.
|
2003-02-26 23:29:00 +00:00
|
|
|
*/
|
|
|
|
view = dns_zone_getview(zone);
|
2020-02-13 14:44:37 -08:00
|
|
|
if (view != NULL && strcmp(view->name, "_default") == 0)
|
|
|
|
{
|
2018-04-17 08:29:14 -07:00
|
|
|
alt = true;
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2018-04-17 08:29:14 -07:00
|
|
|
alt = false;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
|
|
|
} else {
|
2003-02-26 23:29:00 +00:00
|
|
|
alt = cfg_obj_asboolean(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_USEALTXFRSRC, alt);
|
2003-02-26 23:29:00 +00:00
|
|
|
|
2006-06-04 23:17:07 +00:00
|
|
|
obj = NULL;
|
2017-09-08 13:39:09 -07:00
|
|
|
(void)named_config_get(maps, "try-tcp-refresh", &obj);
|
2011-08-30 05:16:15 +00:00
|
|
|
dns_zone_setoption(mayberaw, DNS_ZONEOPT_TRYTCPREFRESH,
|
2006-06-04 23:17:07 +00:00
|
|
|
cfg_obj_asboolean(obj));
|
1999-12-16 23:11:07 +00:00
|
|
|
break;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
case dns_zone_staticstub:
|
|
|
|
RETERR(configure_staticstub(zoptions, zone, zname,
|
|
|
|
default_dbtype));
|
|
|
|
break;
|
|
|
|
|
2000-05-25 19:27:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2000-04-06 22:03:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
1999-12-16 23:11:07 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 01:56:23 +00:00
|
|
|
/*
|
|
|
|
* Set up a DLZ zone as writeable
|
|
|
|
*/
|
|
|
|
isc_result_t
|
2020-02-12 13:59:18 +01:00
|
|
|
named_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone,
|
2020-02-13 14:44:37 -08:00
|
|
|
dns_rdataclass_t rdclass, dns_name_t *name) {
|
|
|
|
dns_db_t *db = NULL;
|
|
|
|
isc_time_t now;
|
2010-12-18 01:56:23 +00:00
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
TIME_NOW(&now);
|
|
|
|
|
|
|
|
dns_zone_settype(zone, dns_zone_dlz);
|
|
|
|
result = dns_sdlz_setdb(dlzdatabase, rdclass, name, &db);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (result != ISC_R_SUCCESS) {
|
2011-10-11 00:09:03 +00:00
|
|
|
return (result);
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2010-12-18 01:56:23 +00:00
|
|
|
result = dns_zone_dlzpostload(zone, db);
|
|
|
|
dns_db_detach(&db);
|
2011-10-11 00:09:03 +00:00
|
|
|
return (result);
|
2010-12-18 01:56:23 +00:00
|
|
|
}
|
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
bool
|
2020-02-13 14:44:37 -08:00
|
|
|
named_zone_reusable(dns_zone_t *zone, const cfg_obj_t *zconfig) {
|
2006-02-28 02:39:52 +00:00
|
|
|
const cfg_obj_t *zoptions = NULL;
|
|
|
|
const cfg_obj_t *obj = NULL;
|
2020-02-13 14:44:37 -08:00
|
|
|
const char *cfilename;
|
|
|
|
const char *zfilename;
|
|
|
|
dns_zone_t *raw = NULL;
|
|
|
|
bool has_raw;
|
|
|
|
dns_zonetype_t ztype;
|
2000-01-21 19:22:35 +00:00
|
|
|
|
2001-03-04 21:21:39 +00:00
|
|
|
zoptions = cfg_tuple_get(zconfig, "options");
|
|
|
|
|
2010-12-16 09:51:30 +00:00
|
|
|
/*
|
|
|
|
* We always reconfigure a static-stub zone for simplicity, assuming
|
2010-12-16 23:47:08 +00:00
|
|
|
* the amount of data to be loaded is small.
|
2010-12-16 09:51:30 +00:00
|
|
|
*/
|
2012-01-31 01:13:10 +00:00
|
|
|
if (zonetype_fromconfig(zoptions) == dns_zone_staticstub) {
|
|
|
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
|
|
|
"not reusable: staticstub");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2012-01-31 01:13:10 +00:00
|
|
|
}
|
2011-08-30 05:16:15 +00:00
|
|
|
|
2012-01-31 01:13:10 +00:00
|
|
|
/* If there's a raw zone, use that for filename and type comparison */
|
2011-10-12 00:10:20 +00:00
|
|
|
dns_zone_getraw(zone, &raw);
|
|
|
|
if (raw != NULL) {
|
2012-01-31 01:13:10 +00:00
|
|
|
zfilename = dns_zone_getfile(raw);
|
|
|
|
ztype = dns_zone_gettype(raw);
|
2011-10-12 00:10:20 +00:00
|
|
|
dns_zone_detach(&raw);
|
2018-04-17 08:29:14 -07:00
|
|
|
has_raw = true;
|
2012-01-31 01:13:10 +00:00
|
|
|
} else {
|
|
|
|
zfilename = dns_zone_getfile(zone);
|
|
|
|
ztype = dns_zone_gettype(zone);
|
2018-04-17 08:29:14 -07:00
|
|
|
has_raw = false;
|
2012-01-31 01:13:10 +00:00
|
|
|
}
|
2011-10-12 00:10:20 +00:00
|
|
|
|
2011-08-30 05:16:15 +00:00
|
|
|
obj = NULL;
|
2011-10-12 00:10:20 +00:00
|
|
|
(void)cfg_map_get(zoptions, "inline-signing", &obj);
|
2012-01-31 01:13:10 +00:00
|
|
|
if ((obj == NULL || !cfg_obj_asboolean(obj)) && has_raw) {
|
|
|
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
|
|
|
"not reusable: old zone was inline-signing");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2012-01-31 01:13:10 +00:00
|
|
|
} else if ((obj != NULL && cfg_obj_asboolean(obj)) && !has_raw) {
|
|
|
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
|
|
|
"not reusable: old zone was not inline-signing");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2012-01-31 01:13:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (zonetype_fromconfig(zoptions) != ztype) {
|
|
|
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
|
|
|
"not reusable: type mismatch");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2012-01-31 01:13:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
obj = NULL;
|
|
|
|
(void)cfg_map_get(zoptions, "file", &obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
if (obj != NULL) {
|
2012-01-31 01:13:10 +00:00
|
|
|
cfilename = cfg_obj_asstring(obj);
|
2020-02-13 21:48:23 +01:00
|
|
|
} else {
|
2012-01-31 01:13:10 +00:00
|
|
|
cfilename = NULL;
|
2020-02-13 21:48:23 +01:00
|
|
|
}
|
2012-01-31 01:13:10 +00:00
|
|
|
if (!((cfilename == NULL && zfilename == NULL) ||
|
|
|
|
(cfilename != NULL && zfilename != NULL &&
|
2020-02-13 14:44:37 -08:00
|
|
|
strcmp(cfilename, zfilename) == 0)))
|
|
|
|
{
|
2012-01-31 01:13:10 +00:00
|
|
|
dns_zone_log(zone, ISC_LOG_DEBUG(1),
|
|
|
|
"not reusable: filename mismatch");
|
2018-04-17 08:29:14 -07:00
|
|
|
return (false);
|
2012-01-31 01:13:10 +00:00
|
|
|
}
|
2000-01-21 19:22:35 +00:00
|
|
|
|
2018-04-17 08:29:14 -07:00
|
|
|
return (true);
|
2000-01-21 19:22:35 +00:00
|
|
|
}
|