return (view == myview);
}
+/*%
+ * 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,
+ const char *zname, const cfg_obj_t **maps)
+{
+ 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 "
+ "'%s'", zname);
+ }
+
+ return (dns_notifytype_explicit);
+}
isc_result_t
named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
else
INSIST(0);
}
+ notifytype = process_notifytype(notifytype, ztype, zname,
+ nodefault);
if (raw != NULL)
dns_zone_setnotifytype(raw, dns_notifytype_no);
dns_zone_setnotifytype(zone, notifytype);
dns_zone_setxfracl(zone, none);
dns_acl_detach(&none);
}
- /*
- * Only allow "also-notify".
- */
- notifytype = dns_notifytype_explicit;
- dns_zone_setnotifytype(zone, notifytype);
/* FALLTHROUGH */
case dns_zone_slave:
case dns_zone_stub:
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * 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/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+zone "." {
+ type mirror;
+ masters { 127.0.0.1; };
+ notify yes;
+};
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * 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/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+options {
+ notify yes;
+};
+
+zone "." {
+ type mirror;
+ masters { 127.0.0.1; };
+};
return (result);
}
+/*%
+ * Check whether NOTIFY configuration at the zone level is acceptable for a
+ * mirror zone. Return true if it is; return false otherwise.
+ */
+static bool
+check_mirror_zone_notify(const cfg_obj_t *zoptions, const char *znamestr,
+ isc_log_t *logctx)
+{
+ bool notify_configuration_ok = true;
+ const cfg_obj_t *obj = NULL;
+
+ (void)cfg_map_get(zoptions, "notify", &obj);
+ if (obj == NULL) {
+ /*
+ * "notify" not set at zone level. This is fine.
+ */
+ return (true);
+ }
+
+ if (cfg_obj_isboolean(obj)) {
+ if (cfg_obj_asboolean(obj)) {
+ /*
+ * "notify yes;" set at zone level. This is an error.
+ */
+ notify_configuration_ok = false;
+ }
+ } else {
+ const char *notifystr = cfg_obj_asstring(obj);
+ if (strcasecmp(notifystr, "explicit") != 0) {
+ /*
+ * Something else than "notify explicit;" set at zone
+ * level. This is an error.
+ */
+ notify_configuration_ok = false;
+ }
+ }
+
+ if (!notify_configuration_ok) {
+ cfg_obj_log(zoptions, logctx, ISC_LOG_ERROR,
+ "zone '%s': mirror zones can only be used with "
+ "'notify no;' or 'notify explicit;'", znamestr);
+ }
+
+ return (notify_configuration_ok);
+}
+
static isc_result_t
check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
const cfg_obj_t *config, isc_symtab_t *symtab,
}
}
+ /*
+ * Only a limited subset of all possible "notify" settings can be used
+ * at the zone level for mirror zones.
+ */
+ if (ztype == CFG_ZONE_MIRROR &&
+ !check_mirror_zone_notify(zoptions, znamestr, logctx))
+ {
+ result = ISC_R_FAILURE;
+ }
+
/*
* Master, slave, and mirror zones may have an "also-notify" field, but
* shouldn't if notify is disabled.
./bin/tests/system/checkconf/bad-maxcachettl.conf CONF-C 2018
./bin/tests/system/checkconf/bad-maxncachettl.conf CONF-C 2018
./bin/tests/system/checkconf/bad-maxttlmap.conf CONF-C 2014,2016,2018
+./bin/tests/system/checkconf/bad-mirror-explicit-notify-yes.conf CONF-C 2018
./bin/tests/system/checkconf/bad-noddns.conf CONF-C 2014,2016,2018
./bin/tests/system/checkconf/bad-options-also-notify.conf CONF-C 2016,2018
./bin/tests/system/checkconf/bad-printtime.conf CONF-C 2016,2018
./bin/tests/system/checkconf/good-lmdb-mapsize-smallest.conf CONF-C 2017,2018
./bin/tests/system/checkconf/good-maxcachettl.conf CONF-C 2018
./bin/tests/system/checkconf/good-maxncachettl.conf CONF-C 2018
+./bin/tests/system/checkconf/good-mirror-inherited-notify-yes.conf CONF-C 2018
./bin/tests/system/checkconf/good-nested.conf CONF-C 2015,2016,2018
./bin/tests/system/checkconf/good-options-also-notify.conf CONF-C 2016,2018
./bin/tests/system/checkconf/good-printtime.conf CONF-C 2016,2018