]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make rndc showzone print a message when allow-new-zones is not configured (#40009)
authorMukund Sivaraman <muks@isc.org>
Tue, 21 Jul 2015 03:59:50 +0000 (09:29 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 21 Jul 2015 06:49:24 +0000 (12:19 +0530)
Squashed commit of the following:

commit 77f12b02cf4e81f13e10db3cfac90e9de0b53928
Author: Mukund Sivaraman <muks@isc.org>
Date:   Mon Jul 13 05:28:13 2015 +0530

    Some tweaks

commit 9c521020b03c2fe7293ec4c970225fff479efd40
Author: Tony Finch <dot@dotat.at>
Date:   Thu Jul 9 15:36:15 2015 +0100

    rndc addzone error reporting improvements

    Clearer error messages from rndc addzone and modzone when the view is not
    known or when allow-new-zones is off.

    Also, remove a spurious newline from the delzone response.

CHANGES
bin/named/server.c

diff --git a/CHANGES b/CHANGES
index 6a6c9dc0df550ea817418b74a94d78e8831c77fc..bf9c49720aaacfbc3efd01da939c1f1f7ce47d58 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+4156.  [func]          Print informative output from rndc showzone when
+                       allow-new-zones is not enabled for a view. Thanks to
+                       Tony Finch for submitting a patch. [RT #40009]
+
 4165.  [security]      A failure to reset a value to NULL in tkey.c could
                        result in an assertion failure. (CVE-2015-5477)
                        [RT #40046]
index 91bc8209bfd7e68556e0c585eed2cca586db6c6a..a6a2c15470616437b17bf277e65ec98bb5dcf0fa 100644 (file)
@@ -9392,7 +9392,8 @@ nzf_append(FILE *fp, const char *viewname, const cfg_obj_t *zconfig) {
 
 static isc_result_t
 newzone_parse(ns_server_t *server, char *args, dns_view_t **viewp,
-             cfg_obj_t **zoneconfp, const cfg_obj_t **zoneobjp)
+             cfg_obj_t **zoneconfp, const cfg_obj_t **zoneobjp,
+             isc_buffer_t **text)
 {
        isc_result_t result;
        isc_buffer_t argbuf;
@@ -9444,7 +9445,16 @@ newzone_parse(ns_server_t *server, char *args, dns_view_t **viewp,
                viewname = cfg_obj_asstring(obj);
        if (viewname == NULL || *viewname == '\0')
                viewname = "_default";
-       CHECK(dns_viewlist_find(&server->viewlist, viewname, rdclass, &view));
+       result = dns_viewlist_find(&server->viewlist, viewname, rdclass,
+                                  &view);
+       if (result == ISC_R_NOTFOUND) {
+               (void) putstr(text, "no matching view found for '");
+               (void) putstr(text, viewname);
+               (void) putstr(text, "'");
+               goto cleanup;
+       } else if (result != ISC_R_SUCCESS) {
+               goto cleanup;
+       }
 
        *viewp = view;
        *zoneobjp = zoneobj;
@@ -9750,13 +9760,18 @@ ns_server_changezone(ns_server_t *server, char *args, isc_buffer_t **text) {
 
        if (strncasecmp(args, "add", 3) == 0)
                addzone = ISC_TRUE;
-       else
+       else {
+               INSIST(strncasecmp(args, "mod", 3) == 0);
                addzone = ISC_FALSE;
+       }
 
-       CHECK(newzone_parse(server, args, &view, &zoneconf, &zoneobj));
+       CHECK(newzone_parse(server, args, &view, &zoneconf, &zoneobj, text));
 
        /* Are we accepting new zones in this view? */
        if (view->new_zone_file == NULL) {
+               (void) putstr(text, "Not allowing new zones in view '");
+               (void) putstr(text, view->name);
+               (void) putstr(text, "'");
                result = ISC_R_NOPERM;
                goto cleanup;
        }
@@ -9930,7 +9945,7 @@ ns_server_delzone(ns_server_t *server, char *args, isc_buffer_t **text) {
 
                TCHECK(putstr(text, "zone '"));
                TCHECK(putstr(text, zonename));
-               TCHECK(putstr(text, "' was deleted.\n"));
+               TCHECK(putstr(text, "' was deleted."));
 
                file = dns_zone_getfile(mayberaw);
                first = inuse(file, ISC_TRUE, text);