2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

3701. [func] named-checkconf can now suppress the printing of

shared secrets by specifying '-x'. [RT #34465]
This commit is contained in:
Mark Andrews
2014-01-10 16:56:36 +11:00
parent 57a46f4b19
commit ff6de396a9
10 changed files with 109 additions and 4 deletions

View File

@@ -182,15 +182,23 @@ void
cfg_print(const cfg_obj_t *obj,
void (*f)(void *closure, const char *text, int textlen),
void *closure)
{
cfg_printx(obj, 0, f, closure);
}
void
cfg_printx(const cfg_obj_t *obj, unsigned int flags,
void (*f)(void *closure, const char *text, int textlen),
void *closure)
{
cfg_printer_t pctx;
pctx.f = f;
pctx.closure = closure;
pctx.indent = 0;
pctx.flags = flags;
obj->type->print(&pctx, obj);
}
/* Tuples. */
isc_result_t
@@ -762,6 +770,22 @@ cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type,
return (result);
}
isc_result_t
cfg_parse_sstring(cfg_parser_t *pctx, const cfg_type_t *type,
cfg_obj_t **ret)
{
isc_result_t result;
UNUSED(type);
CHECK(cfg_getstringtoken(pctx));
return (create_string(pctx,
TOKEN_STRING(pctx),
&cfg_type_sstring,
ret));
cleanup:
return (result);
}
isc_boolean_t
cfg_is_enum(const char *s, const char *const *enums) {
const char * const *p;
@@ -818,6 +842,18 @@ print_qstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
cfg_print_chars(pctx, "\"", 1);
}
static void
print_sstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
cfg_print_chars(pctx, "\"", 1);
if ((pctx->flags & CFG_PRINTER_XKEY) != 0) {
unsigned int len = obj->value.string.length;
while (len-- > 0)
cfg_print_chars(pctx, "?", 1);
} else
cfg_print_ustring(pctx, obj);
cfg_print_chars(pctx, "\"", 1);
}
static void
free_string(cfg_parser_t *pctx, cfg_obj_t *obj) {
isc_mem_put(pctx->mctx, obj->value.string.base,
@@ -854,6 +890,15 @@ cfg_type_t cfg_type_astring = {
&cfg_rep_string, NULL
};
/*
* Any string (quoted or unquoted); printed with quotes.
* If CFG_PRINTER_XKEY is set when printing the string will be '?' out.
*/
cfg_type_t cfg_type_sstring = {
"string", cfg_parse_sstring, print_sstring, cfg_doc_terminal,
&cfg_rep_string, NULL
};
/*
* Booleans
*/
@@ -2555,5 +2600,6 @@ cfg_print_grammar(const cfg_type_t *type,
pctx.f = f;
pctx.closure = closure;
pctx.indent = 0;
pctx.flags = 0;
cfg_doc_obj(&pctx, type);
}