mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
3062. [func] Made several changes to enhance human readability
of DNSSEC data in dig output and in generated zone files: - DNSKEY record comments are more verbose, no longer used in multiline mode only - multiline RRSIG records reformatted - multiline output mode for NSEC3PARAM records - "dig +norrcomments" suppresses DNSKEY comments - "dig +split=X" breaks hex/base64 records into fields of width X; "dig +nosplit" disables this. [RT #22820]
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: dig.c,v 1.239 2011/03/01 23:48:05 tbox Exp $ */
|
||||
/* $Id: dig.c,v 1.240 2011/03/05 19:39:06 each Exp $ */
|
||||
|
||||
/*! \file */
|
||||
|
||||
@@ -67,7 +67,8 @@ static char domainopt[DNS_NAME_MAXTEXT];
|
||||
static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
|
||||
ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
|
||||
multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
|
||||
onesoa = ISC_FALSE;
|
||||
onesoa = ISC_FALSE, rrcomments = ISC_FALSE;
|
||||
static isc_uint32_t splitwidth = 0xffffffff;
|
||||
|
||||
/*% opcode text */
|
||||
static const char * const opcodetext[] = {
|
||||
@@ -201,6 +202,8 @@ help(void) {
|
||||
" +[no]cl (Control display of class in records)\n"
|
||||
" +[no]cmd (Control display of command line)\n"
|
||||
" +[no]comments (Control display of comment lines)\n"
|
||||
" +[no]rrcomments (Control display of per-record "
|
||||
"comments)\n"
|
||||
" +[no]question (Control display of question)\n"
|
||||
" +[no]answer (Control display of answer)\n"
|
||||
" +[no]authority (Control display of authority)\n"
|
||||
@@ -223,6 +226,7 @@ help(void) {
|
||||
" +[no]topdown (Do DNSSEC validation top down mode)\n"
|
||||
#endif
|
||||
#endif
|
||||
" +[no]split=## (Split hex/base64 fields into chunks)\n"
|
||||
" +[no]multiline (Print records in an expanded format)\n"
|
||||
" +[no]onesoa (AXFR prints only one soa record)\n"
|
||||
" global d-opts and servers (before host name) affect all queries.\n"
|
||||
@@ -391,6 +395,8 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
|
||||
styleflags |= DNS_STYLEFLAG_NO_TTL;
|
||||
if (noclass)
|
||||
styleflags |= DNS_STYLEFLAG_NO_CLASS;
|
||||
if (rrcomments)
|
||||
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
|
||||
if (multiline) {
|
||||
styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
|
||||
styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
|
||||
@@ -399,16 +405,21 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
|
||||
styleflags |= DNS_STYLEFLAG_TTL;
|
||||
styleflags |= DNS_STYLEFLAG_MULTILINE;
|
||||
styleflags |= DNS_STYLEFLAG_COMMENT;
|
||||
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
|
||||
}
|
||||
|
||||
if (multiline || (nottl && noclass))
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 24, 24, 32, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 24, 24, 32, 80, 8,
|
||||
splitwidth, mctx);
|
||||
else if (nottl || noclass)
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 24, 32, 40, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 24, 32, 40, 80, 8,
|
||||
splitwidth, mctx);
|
||||
else
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 32, 40, 48, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 32, 40, 48, 80, 8,
|
||||
splitwidth, mctx);
|
||||
check_result(result, "dns_master_stylecreate");
|
||||
|
||||
result = dns_master_rdatasettotext(owner_name, rdataset, style, target);
|
||||
@@ -433,6 +444,10 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
||||
unsigned int styleflags = 0;
|
||||
|
||||
styleflags |= DNS_STYLEFLAG_REL_OWNER;
|
||||
if (query->lookup->comments)
|
||||
styleflags |= DNS_STYLEFLAG_COMMENT;
|
||||
if (rrcomments)
|
||||
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
|
||||
if (nottl)
|
||||
styleflags |= DNS_STYLEFLAG_NO_TTL;
|
||||
if (noclass)
|
||||
@@ -444,17 +459,20 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
|
||||
styleflags |= DNS_STYLEFLAG_OMIT_TTL;
|
||||
styleflags |= DNS_STYLEFLAG_TTL;
|
||||
styleflags |= DNS_STYLEFLAG_MULTILINE;
|
||||
styleflags |= DNS_STYLEFLAG_COMMENT;
|
||||
styleflags |= DNS_STYLEFLAG_RRCOMMENT;
|
||||
}
|
||||
if (multiline || (nottl && noclass))
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 24, 24, 32, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 24, 24, 32, 80, 8,
|
||||
splitwidth, mctx);
|
||||
else if (nottl || noclass)
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 24, 32, 40, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 24, 32, 40, 80, 8,
|
||||
splitwidth, mctx);
|
||||
else
|
||||
result = dns_master_stylecreate(&style, styleflags,
|
||||
24, 32, 40, 48, 80, 8, mctx);
|
||||
result = dns_master_stylecreate2(&style, styleflags,
|
||||
24, 32, 40, 48, 80, 8,
|
||||
splitwidth, mctx);
|
||||
check_result(result, "dns_master_stylecreate");
|
||||
|
||||
if (query->lookup->cmdline[0] != 0) {
|
||||
@@ -756,6 +774,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
lookup->section_answer = state;
|
||||
lookup->section_additional = state;
|
||||
lookup->comments = state;
|
||||
rrcomments = state;
|
||||
lookup->stats = state;
|
||||
printcmd = state;
|
||||
break;
|
||||
@@ -914,6 +933,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
lookup->identify = ISC_TRUE;
|
||||
lookup->stats = ISC_FALSE;
|
||||
lookup->comments = ISC_FALSE;
|
||||
rrcomments = ISC_FALSE;
|
||||
lookup->section_additional = ISC_FALSE;
|
||||
lookup->section_authority = ISC_FALSE;
|
||||
lookup->section_question = ISC_FALSE;
|
||||
@@ -973,6 +993,10 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
default:
|
||||
goto invalid_option;
|
||||
}
|
||||
break;
|
||||
case 'r': /* rrcomments */
|
||||
FULLCHECK("rrcomments");
|
||||
rrcomments = state;
|
||||
break;
|
||||
default:
|
||||
goto invalid_option;
|
||||
@@ -1000,6 +1024,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
lookup->section_authority = ISC_FALSE;
|
||||
lookup->section_question = ISC_FALSE;
|
||||
lookup->comments = ISC_FALSE;
|
||||
rrcomments = ISC_FALSE;
|
||||
lookup->stats = ISC_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -1022,6 +1047,36 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
lookup->dnssec = ISC_TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'p': /* split */
|
||||
FULLCHECK("split");
|
||||
if (value != NULL && !state)
|
||||
goto invalid_option;
|
||||
if (!state) {
|
||||
splitwidth = 0;
|
||||
break;
|
||||
} else if (value == NULL)
|
||||
break;
|
||||
|
||||
result = parse_uint(&splitwidth, value,
|
||||
1023, "split");
|
||||
if (splitwidth % 4 != 0) {
|
||||
splitwidth = ((splitwidth + 3) / 4) * 4;
|
||||
fprintf(stderr, ";; Warning, split must be "
|
||||
"a multiple of 4; adjusting "
|
||||
"to %d\n", splitwidth);
|
||||
}
|
||||
/*
|
||||
* There is an adjustment done in the
|
||||
* totext_<rrtype>() functions which causes
|
||||
* splitwidth to shrink. This is okay when we're
|
||||
* using the default width but incorrect in this
|
||||
* case, so we correct for it
|
||||
*/
|
||||
if (splitwidth)
|
||||
splitwidth += 3;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fatal("Couldn't parse retries");
|
||||
break;
|
||||
case 't': /* stats */
|
||||
FULLCHECK("stats");
|
||||
lookup->stats = state;
|
||||
@@ -1066,6 +1121,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
lookup->recurse = ISC_FALSE;
|
||||
lookup->identify = ISC_TRUE;
|
||||
lookup->comments = ISC_FALSE;
|
||||
rrcomments = ISC_FALSE;
|
||||
lookup->stats = ISC_FALSE;
|
||||
lookup->section_additional = ISC_FALSE;
|
||||
lookup->section_authority = ISC_TRUE;
|
||||
|
Reference in New Issue
Block a user