mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
3701. [func] named-checkconf can now suppress the printing of
shared secrets by specifying '-x'. [RT #34465]
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
3701. [func] named-checkconf can now suppress the printing of
|
||||||
|
shared secrets by specifying '-x'. [RT #34465]
|
||||||
|
|
||||||
3700. [func] Allow access to subgroups of XML statistics via
|
3700. [func] Allow access to subgroups of XML statistics via
|
||||||
special URLs http://<server>:<port>/xml/v3/server,
|
special URLs http://<server>:<port>/xml/v3/server,
|
||||||
/zones, /net, /tasks, /mem, and /status. [RT #35115]
|
/zones, /net, /tasks, /mem, and /status. [RT #35115]
|
||||||
|
@@ -482,10 +482,11 @@ main(int argc, char **argv) {
|
|||||||
isc_entropy_t *ectx = NULL;
|
isc_entropy_t *ectx = NULL;
|
||||||
isc_boolean_t load_zones = ISC_FALSE;
|
isc_boolean_t load_zones = ISC_FALSE;
|
||||||
isc_boolean_t print = ISC_FALSE;
|
isc_boolean_t print = ISC_FALSE;
|
||||||
|
unsigned int flags = 0;
|
||||||
|
|
||||||
isc_commandline_errprint = ISC_FALSE;
|
isc_commandline_errprint = ISC_FALSE;
|
||||||
|
|
||||||
while ((c = isc_commandline_parse(argc, argv, "dhjt:pvz")) != EOF) {
|
while ((c = isc_commandline_parse(argc, argv, "dhjt:pvxz")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'd':
|
case 'd':
|
||||||
debug++;
|
debug++;
|
||||||
@@ -512,6 +513,10 @@ main(int argc, char **argv) {
|
|||||||
printf(VERSION "\n");
|
printf(VERSION "\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
|
case 'x':
|
||||||
|
flags |= CFG_PRINTER_XKEY;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'z':
|
case 'z':
|
||||||
load_zones = ISC_TRUE;
|
load_zones = ISC_TRUE;
|
||||||
docheckmx = ISC_FALSE;
|
docheckmx = ISC_FALSE;
|
||||||
@@ -534,6 +539,11 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (((flags & CFG_PRINTER_XKEY) != 0) && !print) {
|
||||||
|
fprintf(stderr, "%s: -x cannot be used without -p\n", program);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (isc_commandline_index + 1 < argc)
|
if (isc_commandline_index + 1 < argc)
|
||||||
usage();
|
usage();
|
||||||
if (argv[isc_commandline_index] != NULL)
|
if (argv[isc_commandline_index] != NULL)
|
||||||
@@ -574,7 +584,7 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (print && exit_status == 0)
|
if (print && exit_status == 0)
|
||||||
cfg_print(config, output, NULL);
|
cfg_printx(config, flags, output, NULL);
|
||||||
cfg_obj_destroy(parser, &config);
|
cfg_obj_destroy(parser, &config);
|
||||||
|
|
||||||
cfg_parser_destroy(&parser);
|
cfg_parser_destroy(&parser);
|
||||||
|
@@ -60,6 +60,7 @@
|
|||||||
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
|
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
|
||||||
<arg choice="req">filename</arg>
|
<arg choice="req">filename</arg>
|
||||||
<arg><option>-p</option></arg>
|
<arg><option>-p</option></arg>
|
||||||
|
<arg><option>-x</option></arg>
|
||||||
<arg><option>-z</option></arg>
|
<arg><option>-z</option></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
@@ -129,6 +130,21 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>-x</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
When printing the configuration files in canonical
|
||||||
|
form, obscure shared secrets by replacing them with
|
||||||
|
strings of question marks ('?'). This allows the
|
||||||
|
contents of <filename>named.conf</filename> and related
|
||||||
|
files to be shared — for example, when submitting
|
||||||
|
bug reports — without compromising private data.
|
||||||
|
This option cannot be used without <option>-p</option>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>-z</term>
|
<term>-z</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@@ -126,3 +126,7 @@ view "third" {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
key "mykey" {
|
||||||
|
algorithm "hmac-md5";
|
||||||
|
secret "qwertyuiopasdfgh";
|
||||||
|
};
|
||||||
|
@@ -34,6 +34,16 @@ cmp good.conf.in good.conf.out || ret=1
|
|||||||
if [ $ret != 0 ]; then echo "I:failed"; fi
|
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||||
status=`expr $status + $ret`
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
|
echo "I: checking that named-checkconf -x removes secrets"
|
||||||
|
ret=0
|
||||||
|
# ensure there is a secret and that it is not the check string.
|
||||||
|
grep 'secret "' good.conf.in > /dev/null || ret=1
|
||||||
|
grep 'secret "????????????????"' good.conf.in > /dev/null 2>&1 && ret=1
|
||||||
|
$CHECKCONF -p -x good.conf.in | grep -v '^good.conf.in:' > good.conf.out 2>&1 || ret=1
|
||||||
|
grep 'secret "????????????????"' good.conf.out > /dev/null 2>&1 || ret=1
|
||||||
|
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||||
|
status=`expr $status + $ret`
|
||||||
|
|
||||||
for bad in bad*.conf
|
for bad in bad*.conf
|
||||||
do
|
do
|
||||||
ret=0
|
ret=0
|
||||||
|
@@ -406,10 +406,20 @@ void
|
|||||||
cfg_print(const cfg_obj_t *obj,
|
cfg_print(const cfg_obj_t *obj,
|
||||||
void (*f)(void *closure, const char *text, int textlen),
|
void (*f)(void *closure, const char *text, int textlen),
|
||||||
void *closure);
|
void *closure);
|
||||||
|
void
|
||||||
|
cfg_printx(const cfg_obj_t *obj, unsigned int flags,
|
||||||
|
void (*f)(void *closure, const char *text, int textlen),
|
||||||
|
void *closure);
|
||||||
|
|
||||||
|
#define CFG_PRINTER_XKEY 0x1 /* '?' out shared keys. */
|
||||||
|
|
||||||
/*%<
|
/*%<
|
||||||
* Print the configuration object 'obj' by repeatedly calling the
|
* Print the configuration object 'obj' by repeatedly calling the
|
||||||
* function 'f', passing 'closure' and a region of text starting
|
* function 'f', passing 'closure' and a region of text starting
|
||||||
* at 'text' and comprising 'textlen' characters.
|
* at 'text' and comprising 'textlen' characters.
|
||||||
|
*
|
||||||
|
* If CFG_PRINTER_XKEY the contents of shared keys will be obscured
|
||||||
|
* by replacing them with question marks ('?')
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -86,6 +86,7 @@ struct cfg_printer {
|
|||||||
void (*f)(void *closure, const char *text, int textlen);
|
void (*f)(void *closure, const char *text, int textlen);
|
||||||
void *closure;
|
void *closure;
|
||||||
int indent;
|
int indent;
|
||||||
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*% A clause definition. */
|
/*% A clause definition. */
|
||||||
@@ -271,6 +272,7 @@ LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_uint64;
|
|||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_qstring;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_qstring;
|
||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_astring;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_astring;
|
||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_ustring;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_ustring;
|
||||||
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sstring;
|
||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sockaddr;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sockaddr;
|
||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sockaddrdscp;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_sockaddrdscp;
|
||||||
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_netaddr;
|
LIBISCCFG_EXTERNAL_DATA extern cfg_type_t cfg_type_netaddr;
|
||||||
@@ -319,6 +321,9 @@ cfg_print_ustring(cfg_printer_t *pctx, const cfg_obj_t *obj);
|
|||||||
isc_result_t
|
isc_result_t
|
||||||
cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
|
cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
cfg_parse_sstring(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret);
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
cfg_parse_rawaddr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na);
|
cfg_parse_rawaddr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na);
|
||||||
|
|
||||||
|
@@ -1773,7 +1773,7 @@ static cfg_type_t cfg_type_dynamically_loadable_zones_opts = {
|
|||||||
static cfg_clausedef_t
|
static cfg_clausedef_t
|
||||||
key_clauses[] = {
|
key_clauses[] = {
|
||||||
{ "algorithm", &cfg_type_astring, 0 },
|
{ "algorithm", &cfg_type_astring, 0 },
|
||||||
{ "secret", &cfg_type_astring, 0 },
|
{ "secret", &cfg_type_sstring, 0 },
|
||||||
{ NULL, NULL, 0 }
|
{ NULL, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -182,15 +182,23 @@ void
|
|||||||
cfg_print(const cfg_obj_t *obj,
|
cfg_print(const cfg_obj_t *obj,
|
||||||
void (*f)(void *closure, const char *text, int textlen),
|
void (*f)(void *closure, const char *text, int textlen),
|
||||||
void *closure)
|
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;
|
cfg_printer_t pctx;
|
||||||
pctx.f = f;
|
pctx.f = f;
|
||||||
pctx.closure = closure;
|
pctx.closure = closure;
|
||||||
pctx.indent = 0;
|
pctx.indent = 0;
|
||||||
|
pctx.flags = flags;
|
||||||
obj->type->print(&pctx, obj);
|
obj->type->print(&pctx, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Tuples. */
|
/* Tuples. */
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
@@ -762,6 +770,22 @@ cfg_parse_astring(cfg_parser_t *pctx, const cfg_type_t *type,
|
|||||||
return (result);
|
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
|
isc_boolean_t
|
||||||
cfg_is_enum(const char *s, const char *const *enums) {
|
cfg_is_enum(const char *s, const char *const *enums) {
|
||||||
const char * const *p;
|
const char * const *p;
|
||||||
@@ -818,6 +842,18 @@ print_qstring(cfg_printer_t *pctx, const cfg_obj_t *obj) {
|
|||||||
cfg_print_chars(pctx, "\"", 1);
|
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
|
static void
|
||||||
free_string(cfg_parser_t *pctx, cfg_obj_t *obj) {
|
free_string(cfg_parser_t *pctx, cfg_obj_t *obj) {
|
||||||
isc_mem_put(pctx->mctx, obj->value.string.base,
|
isc_mem_put(pctx->mctx, obj->value.string.base,
|
||||||
@@ -854,6 +890,15 @@ cfg_type_t cfg_type_astring = {
|
|||||||
&cfg_rep_string, NULL
|
&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
|
* Booleans
|
||||||
*/
|
*/
|
||||||
@@ -2555,5 +2600,6 @@ cfg_print_grammar(const cfg_type_t *type,
|
|||||||
pctx.f = f;
|
pctx.f = f;
|
||||||
pctx.closure = closure;
|
pctx.closure = closure;
|
||||||
pctx.indent = 0;
|
pctx.indent = 0;
|
||||||
|
pctx.flags = 0;
|
||||||
cfg_doc_obj(&pctx, type);
|
cfg_doc_obj(&pctx, type);
|
||||||
}
|
}
|
||||||
|
@@ -44,6 +44,7 @@ cfg_parser_create
|
|||||||
cfg_parser_destroy
|
cfg_parser_destroy
|
||||||
cfg_parser_setcallback
|
cfg_parser_setcallback
|
||||||
cfg_print
|
cfg_print
|
||||||
|
cfg_printx
|
||||||
cfg_tuple_get
|
cfg_tuple_get
|
||||||
|
|
||||||
; Exported Data
|
; Exported Data
|
||||||
|
Reference in New Issue
Block a user