]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a few cosmetic issues with `rndc managed-keys`
authorTony Finch <dot@dotat.at>
Fri, 11 Jan 2019 15:17:04 +0000 (15:17 +0000)
committerEvan Hunt <each@isc.org>
Tue, 15 Jan 2019 00:16:29 +0000 (16:16 -0800)
The handling of class and view arguments was broken, because the code
didn't realise that next_token() would overwrite the class name when
it parsed the view name. The code was trying to implement a syntax
like `refresh [[class] view]`, but it was documented to have a syntax
like `refresh [class [view]]`. The latter is consistent with other rndc
commands, so that is how I have fixed it.

Before:

$ rndc managed-keys refresh in rec
rndc: 'managed-keys' failed: unknown class/type
unknown class 'rec'

After:

$ rndc managed-keys refresh in rec
refreshing managed keys for 'rec'

There were missing newlines in the output from `rndc managed-keys
refresh` and `rndc managed-keys destroy`.

Before:

$ rndc managed-keys refresh
refreshing managed keys for 'rec'refreshing managed keys for 'auth'

After:

$ rndc managed-keys refresh
refreshing managed keys for 'rec'
refreshing managed keys for 'auth'

(cherry picked from commit 6a3b851f72929802fc10a51f17b170db54988021)

bin/named/server.c

index a6f413b6e66818675ec32d43dc1a4bb94cdc1e46..0a8a49e6b9f0cc10089df64c276cb16ec4bfa6d4 100644 (file)
@@ -14930,29 +14930,17 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
        /* Look for the optional class name. */
        classtxt = next_token(lex, text);
        if (classtxt != NULL) {
-               /* Look for the optional view name. */
-               viewtxt = next_token(lex, text);
-       }
-
-       if (classtxt == NULL) {
-               rdclass = dns_rdataclass_in;
-       } else {
                isc_textregion_t r;
                r.base = classtxt;
                r.length = strlen(classtxt);
                result = dns_rdataclass_fromtext(&rdclass, &r);
                if (result != ISC_R_SUCCESS) {
-                       if (viewtxt == NULL) {
-                               rdclass = dns_rdataclass_in;
-                               viewtxt = classtxt;
-                               result = ISC_R_SUCCESS;
-                       } else {
-                               snprintf(msg, sizeof(msg),
-                                        "unknown class '%s'", classtxt);
-                               (void) putstr(text, msg);
-                               goto cleanup;
-                       }
+                       snprintf(msg, sizeof(msg),
+                                "unknown class '%s'", classtxt);
+                       (void) putstr(text, msg);
+                       goto cleanup;
                }
+               viewtxt = next_token(lex, text);
        }
 
        for (view = ISC_LIST_HEAD(server->viewlist);
@@ -14981,6 +14969,9 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
 
                switch (opt) {
                case REFRESH:
+                       if (!first) {
+                               CHECK(putstr(text, "\n"));
+                       }
                        CHECK(mkey_refresh(view, text));
                        break;
                case STATUS:
@@ -14988,12 +14979,14 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
                                CHECK(putstr(text, "\n\n"));
                        }
                        CHECK(mkey_status(view, text));
-                       first = false;
                        break;
                case SYNC:
                        CHECK(dns_zone_flush(view->managed_keys));
                        break;
                case DESTROY:
+                       if (!first) {
+                               CHECK(putstr(text, "\n"));
+                       }
                        CHECK(mkey_destroy(server, view, text));
                        break;
                default:
@@ -15004,6 +14997,7 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
                if (viewtxt != NULL) {
                        break;
                }
+               first = false;
        }
 
        if (!found) {