Commit c38d989f authored by Evan Hunt's avatar Evan Hunt
Browse files

[master] error on bad parameter to 'rndc dumpdb'

4433.	[cleanup]	Report an error when passing an invalid option or
			view name to "rndc dumpdb". [RT #42958]
parent 7a76be36
4433. [placeholder] 4433. [cleanup] Report an error when passing an invalid option or
view name to "rndc dumpdb". [RT #42958]
4432. [test] Hide rndc output on expected failures in logfileconfig 4432. [test] Hide rndc output on expected failures in logfileconfig
system test. [RT #27996] system test. [RT #27996]
......
...@@ -207,7 +207,7 @@ ns_control_docommand(isccc_sexpr_t *message, isc_boolean_t readonly, ...@@ -207,7 +207,7 @@ ns_control_docommand(isccc_sexpr_t *message, isc_boolean_t readonly,
} else if (command_compare(command, NS_COMMAND_QUERYLOG)) { } else if (command_compare(command, NS_COMMAND_QUERYLOG)) {
result = ns_server_togglequerylog(ns_g_server, lex); result = ns_server_togglequerylog(ns_g_server, lex);
} else if (command_compare(command, NS_COMMAND_DUMPDB)) { } else if (command_compare(command, NS_COMMAND_DUMPDB)) {
ns_server_dumpdb(ns_g_server, lex); ns_server_dumpdb(ns_g_server, lex, text);
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
} else if (command_compare(command, NS_COMMAND_SECROOTS)) { } else if (command_compare(command, NS_COMMAND_SECROOTS)) {
result = ns_server_dumpsecroots(ns_g_server, lex, text); result = ns_server_dumpsecroots(ns_g_server, lex, text);
......
...@@ -596,7 +596,7 @@ ns_server_dumpstats(ns_server_t *server); ...@@ -596,7 +596,7 @@ ns_server_dumpstats(ns_server_t *server);
* Dump the current cache to the dump file. * Dump the current cache to the dump file.
*/ */
isc_result_t isc_result_t
ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex); ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text);
/*% /*%
* Dump the current security roots to the secroots file. * Dump the current security roots to the secroots file.
......
...@@ -9478,12 +9478,13 @@ dumpdone(void *arg, isc_result_t result) { ...@@ -9478,12 +9478,13 @@ dumpdone(void *arg, isc_result_t result) {
} }
isc_result_t isc_result_t
ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex) { ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
struct dumpcontext *dctx = NULL; struct dumpcontext *dctx = NULL;
dns_view_t *view; dns_view_t *view;
isc_result_t result; isc_result_t result;
char *ptr; char *ptr;
const char *sep; const char *sep;
isc_boolean_t found;
/* Skip the command name. */ /* Skip the command name. */
ptr = next_token(lex, NULL); ptr = next_token(lex, NULL);
...@@ -9557,15 +9558,26 @@ ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex) { ...@@ -9557,15 +9558,26 @@ ns_server_dumpdb(ns_server_t *server, isc_lex_t *lex) {
} }
nextview: nextview:
found = ISC_FALSE;
for (view = ISC_LIST_HEAD(server->viewlist); for (view = ISC_LIST_HEAD(server->viewlist);
view != NULL; view != NULL;
view = ISC_LIST_NEXT(view, link)) view = ISC_LIST_NEXT(view, link))
{ {
if (ptr != NULL && strcmp(view->name, ptr) != 0) if (ptr != NULL && strcmp(view->name, ptr) != 0)
continue; continue;
found = ISC_TRUE;
CHECK(add_view_tolist(dctx, view)); CHECK(add_view_tolist(dctx, view));
} }
if (ptr != NULL) { if (ptr != NULL) {
if (!found) {
putstr(text, "view '");
putstr(text, ptr);
putstr(text, "' not found");
putnull(text);
result = ISC_R_NOTFOUND;
dumpdone(dctx, result);
return (result);
}
ptr = next_token(lex, NULL); ptr = next_token(lex, NULL);
if (ptr != NULL) if (ptr != NULL)
goto nextview; goto nextview;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment