rndc addzone type forward

Tony Finch dot at dotat.at
Thu Nov 17 10:38:02 UTC 2016


> Unfortunately that's not currently possible. The configuration syntax is
> misleading here. You configure forwarding in a view by putting a "zone"
> statement in named.conf, but it doesn't actually build a zone *object*,
> the way type "master" or "slave" does; it tells the server to set up a
> different data structure entirely.  The addzone command is focused on
> zone objects and doesn't know what to do with this.

Oh, so I guess it's failing at
https://source.isc.org/cgi-bin/gitweb.cgi?p=bind9.git;a=blob;f=bin/named/server.c;hb=v9_11_0_P1#l2163

i.e. after calling zone_configure it looks for the zone object and finds
there isn't one, so the forwarding has been configured but it fails to
write the configuration to the nzf.

Perhaps there should be a type check in newzone_parse()?

Tony.
-- 
f.anthony.n.finch  <dot at dotat.at>  http://dotat.at/  -  I xn--zr8h punycode
Southeast Iceland: Northerly 4 or 5, increasing 6 to gale 8, occasionally
severe gale 9 later. Very rough or high, occasionally rough. Thundery, wintry
showers. Good, occasionally poor.


---
 bin/named/server.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/bin/named/server.c b/bin/named/server.c
index 6cff5a9..e2a8ab0 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -11270,11 +11270,13 @@ newzone_parse(ns_server_t *server, char *command, dns_view_t **viewp,
 	cfg_obj_t *zoneconf = NULL;
 	const cfg_obj_t *zlist = NULL;
 	const cfg_obj_t *zoneobj = NULL;
+	const cfg_obj_t *zoneopt = NULL;
 	const cfg_obj_t *obj = NULL;
 	const char *viewname = NULL;
 	dns_rdataclass_t rdclass;
 	dns_view_t *view = NULL;
 	const char *bn;
+	const char *zt;

 	REQUIRE(viewp != NULL && *viewp == NULL);

@@ -11305,6 +11307,38 @@ newzone_parse(ns_server_t *server, char *command, dns_view_t **viewp,
 	/* For now we only support adding one zone at a time */
 	zoneobj = cfg_listelt_value(cfg_list_first(zlist));

+	/* Check zone is of an acceptable type */
+	zoneopt = cfg_tuple_get(zoneobj, "options");
+	(void)cfg_map_get(zoneopt, "in-view", &obj);
+	if (obj != NULL) {
+		(void) putstr(text, "you can't ");
+		(void) putstr(text, bn);
+		(void) putstr(text, " an in-view zone");
+		result = ISC_R_NOTIMPLEMENTED;
+		goto cleanup;
+	}
+	(void)cfg_map_get(zoneopt, "type", &obj);
+	if (obj == NULL) {
+		(void) putstr(text, "zone type not specified");
+		result = ISC_R_FAILURE;
+		goto cleanup;
+	} else {
+		zt = cfg_obj_asstring(obj);
+		if (strcasecmp(zt, "master") != 0 &&
+		    strcasecmp(zt, "redirect") != 0 &&
+		    strcasecmp(zt, "slave") != 0 &&
+		    strcasecmp(zt, "static-stub") != 0 &&
+		    strcasecmp(zt, "stub")) {
+			(void) putstr(text, "you can't ");
+			(void) putstr(text, bn);
+			(void) putstr(text, " a type ");
+			(void) putstr(text, zt);
+			(void) putstr(text, " zone");
+			result = ISC_R_NOTIMPLEMENTED;
+			goto cleanup;
+		}
+	}
+
 	/* Make sense of optional class argument */
 	obj = cfg_tuple_get(zoneobj, "class");
 	CHECK(ns_config_getclass(obj, dns_rdataclass_in, &rdclass));
-- 
2.1.4



More information about the bind-users mailing list