result = cfg_map_get(zoptions, "dlz", &obj);
if (result == ISC_R_SUCCESS) {
const char *dlzname = cfg_obj_asstring(obj);
- size_t len;
-
- if (cpval != default_dbtype) {
- isc_log_write(NAMED_LOGCATEGORY_GENERAL,
- NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
- "zone '%s': both 'database' and 'dlz' "
- "specified",
- zname);
- CHECK(ISC_R_FAILURE);
- }
-
- len = strlen(dlzname) + 5;
+ size_t len = strlen(dlzname) + 5;
cpval = isc_mem_allocate(mctx, len);
snprintf(cpval, len, "dlz %s", dlzname);
}
filename = cfg_obj_asstring(obj);
}
- /*
- * Unless we're using some alternative database, a primary zone
- * will be needing a master file.
- */
- if (ztype == dns_zone_primary && cpval == default_dbtype &&
- filename == NULL)
- {
- isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
- ISC_LOG_ERROR, "zone '%s': 'file' not specified",
- zname);
- CHECK(ISC_R_FAILURE);
- }
-
if (ztype == dns_zone_secondary || ztype == dns_zone_mirror) {
masterformat = dns_masterformat_raw;
} else {
if (strcasecmp(masterformatstr, "text") == 0) {
masterformat = dns_masterformat_text;
- } else if (strcasecmp(masterformatstr, "raw") == 0) {
- masterformat = dns_masterformat_raw;
} else {
- UNREACHABLE();
+ masterformat = dns_masterformat_raw;
}
}
result = named_config_get(maps, "masterfile-style", &obj);
if (result == ISC_R_SUCCESS) {
const char *masterstylestr = cfg_obj_asstring(obj);
-
- if (masterformat != dns_masterformat_text) {
- cfg_obj_log(obj, ISC_LOG_ERROR,
- "zone '%s': 'masterfile-style' "
- "can only be used with "
- "'masterfile-format text'",
- zname);
- CHECK(ISC_R_FAILURE);
- }
-
if (strcasecmp(masterstylestr, "full") == 0) {
masterstyle = &dns_master_style_full;
- } else if (strcasecmp(masterstylestr, "relative") == 0) {
- masterstyle = &dns_master_style_default;
} else {
- UNREACHABLE();
+ masterstyle = &dns_master_style_default;
}
}
journal_size = -1;
}
} else {
- uint64_t value = cfg_obj_asuint64(obj);
- if (value > DNS_JOURNAL_SIZE_MAX) {
- cfg_obj_log(obj, ISC_LOG_ERROR,
- "'max-journal-size "
- "%" PRId64 "' "
- "is too large",
- value);
- CHECK(ISC_R_RANGE);
- }
- journal_size = (uint32_t)value;
+ journal_size = (uint32_t)cfg_obj_asuint64(obj);
}
if (raw != NULL) {
dns_zone_setjournalsize(raw, journal_size);
journal_size = -1;
}
} else {
- uint64_t value = cfg_obj_asuint64(obj);
- if (value > DNS_JOURNAL_SIZE_MAX) {
- cfg_obj_log(obj, ISC_LOG_ERROR,
- "'max-journal-size "
- "%" PRId64 "' "
- "is too large",
- value);
- CHECK(ISC_R_RANGE);
- }
- journal_size = (uint32_t)value;
+ journal_size = (uint32_t)cfg_obj_asuint64(obj);
}
dns_zone_setjournalsize(zone, journal_size);
}
cfg_obj_asuint32(cfg_tuple_get(obj, "traffic_bytes"));
uint32_t time_minutes =
cfg_obj_asuint32(cfg_tuple_get(obj, "time_minutes"));
- if (traffic_bytes == 0) {
- cfg_obj_log(obj, ISC_LOG_ERROR,
- "zone '%s': 'min-transfer-rate-in' bytes"
- "value can not be '0'",
- zname);
- CHECK(ISC_R_FAILURE);
- }
- /* Max. 28 days (in minutes). */
- const unsigned int time_minutes_max = 28 * 24 * 60;
- if (time_minutes < 1 || time_minutes > time_minutes_max) {
- cfg_obj_log(obj, ISC_LOG_ERROR,
- "zone '%s': 'min-transfer-rate-in' minutes"
- "value is out of range (1..%u)",
- zname, time_minutes_max);
- CHECK(ISC_R_FAILURE);
- }
dns_zone_setminxfrratein(mayberaw, traffic_bytes,
transferinsecs ? time_minutes
: time_minutes * 60);
#include <dns/acl.h>
#include <dns/dnstap.h>
#include <dns/fixedname.h>
+#include <dns/journal.h>
#include <dns/kasp.h>
#include <dns/keystore.h>
#include <dns/keyvalues.h>
return result;
}
+/*
+ * Try to find a zone option in one of up to three levels of options:
+ * for example, the zone, view, and global option blocks.
+ * (Fewer levels can be specified for options that aren't defined at
+ * all three levels.)
+ */
+static isc_result_t
+get_zoneopt(const cfg_obj_t *opts1, const cfg_obj_t *opts2,
+ const cfg_obj_t *opts3, const char *name, const cfg_obj_t **objp) {
+ isc_result_t result = ISC_R_NOTFOUND;
+
+ REQUIRE(*objp == NULL);
+
+ if (opts1 != NULL) {
+ result = cfg_map_get(opts1, name, objp);
+ }
+ if (*objp == NULL && opts2 != NULL) {
+ result = cfg_map_get(opts2, name, objp);
+ }
+ if (*objp == NULL && opts3 != NULL) {
+ result = cfg_map_get(opts3, name, objp);
+ }
+
+ return result;
+}
+
isc_result_t
isccfg_check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
const cfg_obj_t *config, isc_symtab_t *symtab,
* Check if a dnssec-policy is set.
*/
obj = NULL;
- (void)cfg_map_get(zoptions, "dnssec-policy", &obj);
- if (obj == NULL && voptions != NULL) {
- (void)cfg_map_get(voptions, "dnssec-policy", &obj);
- }
- if (obj == NULL && goptions != NULL) {
- (void)cfg_map_get(goptions, "dnssec-policy", &obj);
- }
+ (void)get_zoneopt(zoptions, voptions, goptions, "dnssec-policy", &obj);
if (obj != NULL) {
kaspname = cfg_obj_asstring(obj);
if (strcmp(kaspname, "default") == 0) {
* */
if (has_dnssecpolicy) {
obj = NULL;
- (void)cfg_map_get(zoptions, "max-zone-ttl", &obj);
- if (obj == NULL && voptions != NULL) {
- (void)cfg_map_get(voptions, "max-zone-ttl", &obj);
- }
- if (obj == NULL && goptions != NULL) {
- (void)cfg_map_get(goptions, "max-zone-ttl", &obj);
- }
+ (void)get_zoneopt(zoptions, voptions, goptions, "max-zone-ttl",
+ &obj);
if (obj != NULL) {
cfg_obj_log(obj, ISC_LOG_ERROR,
"zone '%s': option 'max-zone-ttl' "
bool donotify = true;
obj = NULL;
- tresult = cfg_map_get(zoptions, "notify", &obj);
- if (tresult != ISC_R_SUCCESS && voptions != NULL) {
- tresult = cfg_map_get(voptions, "notify", &obj);
- }
- if (tresult != ISC_R_SUCCESS && goptions != NULL) {
- tresult = cfg_map_get(goptions, "notify", &obj);
- }
+ tresult = get_zoneopt(zoptions, voptions, goptions, "notify",
+ &obj);
if (tresult == ISC_R_SUCCESS) {
if (cfg_obj_isboolean(obj)) {
donotify = cfg_obj_asboolean(obj);
"'notify' is disabled",
znamestr);
}
- if (tresult != ISC_R_SUCCESS && voptions != NULL) {
- tresult = cfg_map_get(voptions, "also-notify", &obj);
- }
- if (tresult != ISC_R_SUCCESS && goptions != NULL) {
- tresult = cfg_map_get(goptions, "also-notify", &obj);
+ if (tresult != ISC_R_SUCCESS) {
+ tresult = get_zoneopt(voptions, goptions, NULL,
+ "also-notify", &obj);
}
if (tresult == ISC_R_SUCCESS && donotify) {
uint32_t count;
* we should also check for allow-update at the
* view and options levels.
*/
- if (res1 != ISC_R_SUCCESS && voptions != NULL) {
- res1 = cfg_map_get(voptions, "allow-update", &au);
- }
- if (res1 != ISC_R_SUCCESS && goptions != NULL) {
- res1 = cfg_map_get(goptions, "allow-update", &au);
+ if (res1 != ISC_R_SUCCESS) {
+ res1 = get_zoneopt(voptions, goptions, NULL,
+ "allow-update", &au);
}
if (res2 == ISC_R_SUCCESS) {
*/
obj = NULL;
if (root) {
- if (voptions != NULL) {
- (void)cfg_map_get(voptions, "forwarders", &obj);
- }
- if (obj == NULL && goptions != NULL) {
- (void)cfg_map_get(goptions, "forwarders", &obj);
- }
+ (void)get_zoneopt(voptions, goptions, NULL, "forwarders", &obj);
}
if (check_forward(config, zoptions, obj) != ISC_R_SUCCESS) {
result = ISC_R_FAILURE;
/*
* Forward mode not explicitly configured.
*/
- if (voptions != NULL) {
- cfg_map_get(voptions, "forward", &obj);
- }
- if (obj == NULL && goptions != NULL) {
- cfg_map_get(goptions, "forward", &obj);
- }
+ (void)get_zoneopt(voptions, goptions, NULL, "forward",
+ &obj);
if (obj == NULL ||
strcasecmp(cfg_obj_asstring(obj), "first") == 0)
{
* Warn if key-directory doesn't exist
*/
obj = NULL;
- (void)cfg_map_get(zoptions, "key-directory", &obj);
- if (obj == NULL && voptions != NULL) {
- (void)cfg_map_get(voptions, "key-directory", &obj);
- }
- if (obj == NULL && goptions != NULL) {
- (void)cfg_map_get(goptions, "key-directory", &obj);
- }
+ (void)get_zoneopt(zoptions, voptions, goptions, "key-directory", &obj);
if (obj != NULL) {
dir = cfg_obj_asstring(obj);
cfg_obj_log(obj, ISC_LOG_WARNING,
"key-directory: '%s' %s", dir,
isc_result_totext(tresult));
- result = tresult;
+ if (result == ISC_R_SUCCESS) {
+ result = tresult;
+ }
}
}
tresult = keydirexist(zconfig, "key-directory", zname,
dir, kaspname, keydirs, mctx);
}
- if (tresult != ISC_R_SUCCESS) {
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS) {
result = tresult;
}
}
cfg_obj_log(zconfig, ISC_LOG_ERROR,
"'log-report-channel' cannot be set in "
"the root zone");
- result = ISC_R_FAILURE;
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
}
}
* Check various options.
*/
tresult = check_options(zoptions, config, false, mctx, optlevel_zone);
- if (tresult != ISC_R_SUCCESS) {
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS) {
result = tresult;
}
"zone '%s': cannot specify both 'dlz' "
"and 'database'",
znamestr);
- result = ISC_R_FAILURE;
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
} else if (!dlz &&
(tresult == ISC_R_NOTFOUND ||
(tresult == ISC_R_SUCCESS &&
cfg_obj_log(zconfig, ISC_LOG_ERROR,
"zone '%s': missing 'file' entry",
znamestr);
- result = tresult;
+ if (result == ISC_R_SUCCESS) {
+ result = tresult;
+ }
} else if (tresult == ISC_R_SUCCESS && files != NULL &&
(ztype == CFG_ZONE_SECONDARY ||
ztype == CFG_ZONE_MIRROR || ddns ||
has_dnssecpolicy))
{
tresult = fileexist(fileobj, files, true);
- if (tresult != ISC_R_SUCCESS) {
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
+ {
result = tresult;
}
} else if (tresult == ISC_R_SUCCESS && files != NULL &&
ztype == CFG_ZONE_HINT))
{
tresult = fileexist(fileobj, files, false);
- if (tresult != ISC_R_SUCCESS) {
+ if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS)
+ {
result = tresult;
}
}
}
+ /*
+ * Check that masterfile-format and masterfile-style are
+ * consistent.
+ */
+ obj = NULL;
+ tresult = get_zoneopt(zoptions, voptions, goptions, "masterfile-format",
+ &obj);
+ if (tresult == ISC_R_SUCCESS &&
+ strcasecmp(cfg_obj_asstring(obj), "raw") == 0)
+ {
+ obj = NULL;
+ tresult = get_zoneopt(zoptions, voptions, goptions,
+ "masterfile-style", &obj);
+ if (tresult == ISC_R_SUCCESS) {
+ cfg_obj_log(obj, ISC_LOG_ERROR,
+ "zone '%s': 'masterfile-style' "
+ "can only be used with "
+ "'masterfile-format text'",
+ znamestr);
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_FAILURE;
+ }
+ }
+ }
+
+ obj = NULL;
+ (void)get_zoneopt(zoptions, voptions, goptions, "max-journal-size",
+ &obj);
+ if (obj != NULL && cfg_obj_isuint64(obj)) {
+ uint64_t value = cfg_obj_asuint64(obj);
+ if (value > DNS_JOURNAL_SIZE_MAX) {
+ cfg_obj_log(obj, ISC_LOG_ERROR,
+ "'max-journal-size %" PRId64 "' "
+ "is too large",
+ value);
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_RANGE;
+ }
+ }
+ }
+
+ obj = NULL;
+ (void)get_zoneopt(zoptions, voptions, goptions, "min-transfer-rate-in",
+ &obj);
+ if (obj != NULL) {
+ uint32_t traffic_bytes =
+ cfg_obj_asuint32(cfg_tuple_get(obj, "traffic_bytes"));
+ uint32_t time_minutes =
+ cfg_obj_asuint32(cfg_tuple_get(obj, "time_minutes"));
+ if (traffic_bytes == 0) {
+ cfg_obj_log(obj, ISC_LOG_ERROR,
+ "zone '%s': 'min-transfer-rate-in' bytes "
+ "value cannot be '0'",
+ znamestr);
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_RANGE;
+ }
+ }
+ /* Max. 28 days (in minutes). */
+ const unsigned int time_minutes_max = 28 * 24 * 60;
+ if (time_minutes < 1 || time_minutes > time_minutes_max) {
+ cfg_obj_log(obj, ISC_LOG_ERROR,
+ "zone '%s': 'min-transfer-rate-in' minutes "
+ "value is out of range (1..%u)",
+ znamestr, time_minutes_max);
+ if (result == ISC_R_SUCCESS) {
+ result = ISC_R_RANGE;
+ }
+ }
+ }
+
return result;
}