mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
1549. [func] named-checkzone can now write out the zone contents
in a easily parsable format (-D and -o).
This commit is contained in:
parent
93a90ddd6b
commit
d0aebc5a55
3
CHANGES
3
CHANGES
@ -1,3 +1,6 @@
|
|||||||
|
1549. [func] named-checkzone can now write out the zone contents
|
||||||
|
in a easily parsable format (-D and -o).
|
||||||
|
|
||||||
1548. [bug] When parsing APL records it was possible to silently
|
1548. [bug] When parsing APL records it was possible to silently
|
||||||
accept out of range ADDRESSFAMILY values. [RT# 9979]
|
accept out of range ADDRESSFAMILY values. [RT# 9979]
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: check-tool.c,v 1.8 2002/07/19 02:34:57 marka Exp $ */
|
/* $Id: check-tool.c,v 1.9 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -28,6 +28,7 @@
|
|||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/log.h>
|
#include <isc/log.h>
|
||||||
#include <isc/region.h>
|
#include <isc/region.h>
|
||||||
|
#include <isc/stdio.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
|
|
||||||
#include <dns/fixedname.h>
|
#include <dns/fixedname.h>
|
||||||
@ -124,3 +125,35 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
|||||||
dns_zone_detach(&zone);
|
dns_zone_detach(&zone);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dump_zone(const char *zonename, dns_zone_t *zone, const char *filename)
|
||||||
|
{
|
||||||
|
isc_result_t result;
|
||||||
|
FILE *output = stdout;
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
if (filename != NULL)
|
||||||
|
fprintf(stderr, "dumping \"%s\" to \"%s\"\n",
|
||||||
|
zonename, filename);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "dumping \"%s\"\n", zonename);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filename != NULL) {
|
||||||
|
result = isc_stdio_open(filename, "w+", &output);
|
||||||
|
|
||||||
|
if (result != ISC_R_SUCCESS) {
|
||||||
|
fprintf(stderr, "could not open output "
|
||||||
|
"file \"%s\" for writing\n", filename);
|
||||||
|
return (ISC_R_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result = dns_zone_fulldumptostream(zone, output);
|
||||||
|
|
||||||
|
if (filename != NULL)
|
||||||
|
(void)isc_stdio_close(output);
|
||||||
|
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: check-tool.h,v 1.5 2002/07/19 02:34:58 marka Exp $ */
|
/* $Id: check-tool.h,v 1.6 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#ifndef CHECK_TOOL_H
|
#ifndef CHECK_TOOL_H
|
||||||
#define CHECK_TOOL_H
|
#define CHECK_TOOL_H
|
||||||
@ -34,6 +34,9 @@ isc_result_t
|
|||||||
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
||||||
const char *classname, dns_zone_t **zonep);
|
const char *classname, dns_zone_t **zonep);
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dump_zone(const char *zonename, dns_zone_t *zone, const char *filename);
|
||||||
|
|
||||||
extern int debug;
|
extern int debug;
|
||||||
extern isc_boolean_t nomerge;
|
extern isc_boolean_t nomerge;
|
||||||
extern unsigned int zone_options;
|
extern unsigned int zone_options;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: named-checkzone.c,v 1.26 2003/10/17 03:46:41 marka Exp $ */
|
/* $Id: named-checkzone.c,v 1.27 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -46,6 +46,8 @@ static int quiet = 0;
|
|||||||
static isc_mem_t *mctx = NULL;
|
static isc_mem_t *mctx = NULL;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
dns_zonetype_t zonetype = dns_zone_master;
|
dns_zonetype_t zonetype = dns_zone_master;
|
||||||
|
static int dumpzone = 0;
|
||||||
|
static const char *output_filename;
|
||||||
|
|
||||||
#define ERRRET(result, function) \
|
#define ERRRET(result, function) \
|
||||||
do { \
|
do { \
|
||||||
@ -60,8 +62,8 @@ dns_zonetype_t zonetype = dns_zone_master;
|
|||||||
static void
|
static void
|
||||||
usage(void) {
|
usage(void) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: named-checkzone [-djqv] [-c class] [-t directory] "
|
"usage: named-checkzone [-djqvD] [-c class] [-o output] "
|
||||||
"[-w directory] zonename filename\n");
|
"[-t directory] [-w directory] zonename filename\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +84,7 @@ main(int argc, char **argv) {
|
|||||||
char *classname = classname_in;
|
char *classname = classname_in;
|
||||||
const char *workdir = NULL;
|
const char *workdir = NULL;
|
||||||
|
|
||||||
while ((c = isc_commandline_parse(argc, argv, "c:dijn:qst:vw:")) != EOF) {
|
while ((c = isc_commandline_parse(argc, argv, "c:dijn:qst:o:vw:D")) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
classname = isc_commandline_argument;
|
classname = isc_commandline_argument;
|
||||||
@ -128,6 +130,10 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'o':
|
||||||
|
output_filename = isc_commandline_argument;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
printf(VERSION "\n");
|
printf(VERSION "\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -136,6 +142,10 @@ main(int argc, char **argv) {
|
|||||||
workdir = isc_commandline_argument;
|
workdir = isc_commandline_argument;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'D':
|
||||||
|
dumpzone++;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
@ -165,6 +175,11 @@ main(int argc, char **argv) {
|
|||||||
origin = argv[isc_commandline_index++];
|
origin = argv[isc_commandline_index++];
|
||||||
filename = argv[isc_commandline_index++];
|
filename = argv[isc_commandline_index++];
|
||||||
result = load_zone(mctx, origin, filename, classname, &zone);
|
result = load_zone(mctx, origin, filename, classname, &zone);
|
||||||
|
|
||||||
|
if (result == ISC_R_SUCCESS && dumpzone) {
|
||||||
|
result = dump_zone(origin, zone, output_filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (!quiet && result == ISC_R_SUCCESS)
|
if (!quiet && result == ISC_R_SUCCESS)
|
||||||
fprintf(stdout, "OK\n");
|
fprintf(stdout, "OK\n");
|
||||||
destroy();
|
destroy();
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
- WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
- WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- $Id: named-checkzone.docbook,v 1.8 2002/07/19 02:34:58 marka Exp $ -->
|
<!-- $Id: named-checkzone.docbook,v 1.9 2004/01/07 05:27:17 marka Exp $ -->
|
||||||
|
|
||||||
<refentry>
|
<refentry>
|
||||||
<refentryinfo>
|
<refentryinfo>
|
||||||
@ -43,8 +43,10 @@
|
|||||||
<arg><option>-v</option></arg>
|
<arg><option>-v</option></arg>
|
||||||
<arg><option>-c <replaceable class="parameter">class</replaceable></option></arg>
|
<arg><option>-c <replaceable class="parameter">class</replaceable></option></arg>
|
||||||
<arg><option>-n <replaceable class="parameter">mode</replaceable></option></arg>
|
<arg><option>-n <replaceable class="parameter">mode</replaceable></option></arg>
|
||||||
|
<arg><option>-o <replaceable class="parameter">filename</replaceable></option></arg>
|
||||||
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
|
<arg><option>-t <replaceable class="parameter">directory</replaceable></option></arg>
|
||||||
<arg><option>-w <replaceable class="parameter">directory</replaceable></option></arg>
|
<arg><option>-w <replaceable class="parameter">directory</replaceable></option></arg>
|
||||||
|
<arg><option>-D</option></arg>
|
||||||
<arg choice="req">zonename</arg>
|
<arg choice="req">zonename</arg>
|
||||||
<arg choice="req">filename</arg>
|
<arg choice="req">filename</arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
@ -122,6 +124,15 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>-o <replaceable class="parameter">filename</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Write zone output to <filename>directory</filename>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>-t <replaceable class="parameter">directory</replaceable></term>
|
<term>-t <replaceable class="parameter">directory</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
@ -145,6 +156,15 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>-D</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Dump zone file in canonical format.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>zonename</term>
|
<term>zonename</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: masterdump.h,v 1.28 2002/05/21 06:12:45 marka Exp $ */
|
/* $Id: masterdump.h,v 1.29 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#ifndef DNS_MASTERDUMP_H
|
#ifndef DNS_MASTERDUMP_H
|
||||||
#define DNS_MASTERDUMP_H 1
|
#define DNS_MASTERDUMP_H 1
|
||||||
@ -110,6 +110,12 @@ ISC_LANG_BEGINDECLS
|
|||||||
*/
|
*/
|
||||||
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
|
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_default;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A master file style that dumps zones to a very generic format easily
|
||||||
|
* imported/checked with external tools.
|
||||||
|
*/
|
||||||
|
LIBDNS_EXTERNAL_DATA extern const dns_master_style_t dns_master_style_full;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A master file style that prints explicit TTL values on each
|
* A master file style that prints explicit TTL values on each
|
||||||
* record line, never using $TTL statements. The TTL has a tab
|
* record line, never using $TTL statements. The TTL has a tab
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.h,v 1.123 2003/02/26 23:28:59 marka Exp $ */
|
/* $Id: zone.h,v 1.124 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#ifndef DNS_ZONE_H
|
#ifndef DNS_ZONE_H
|
||||||
#define DNS_ZONE_H 1
|
#define DNS_ZONE_H 1
|
||||||
@ -390,6 +390,17 @@ dns_zone_dumptostream(dns_zone_t *zone, FILE *fd);
|
|||||||
* 'fd' to be a stream open for writing.
|
* 'fd' to be a stream open for writing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd);
|
||||||
|
/*
|
||||||
|
* The same as dns_zone_dumptostream, but dumps the zone with
|
||||||
|
* different dump settings (dns_master_style_full).
|
||||||
|
*
|
||||||
|
* Require:
|
||||||
|
* 'zone' to be a valid zone.
|
||||||
|
* 'fd' to be a stream open for writing.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_zone_maintenance(dns_zone_t *zone);
|
dns_zone_maintenance(dns_zone_t *zone);
|
||||||
/*
|
/*
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: masterdump.c,v 1.71 2003/10/26 21:33:47 marka Exp $ */
|
/* $Id: masterdump.c,v 1.72 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -100,6 +100,12 @@ dns_master_style_default = {
|
|||||||
24, 24, 24, 32, 80, 8
|
24, 24, 24, 32, 80, 8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LIBDNS_EXTERNAL_DATA const dns_master_style_t
|
||||||
|
dns_master_style_full = {
|
||||||
|
DNS_STYLEFLAG_COMMENT,
|
||||||
|
46, 46, 46, 64, 120, 8
|
||||||
|
};
|
||||||
|
|
||||||
LIBDNS_EXTERNAL_DATA const dns_master_style_t
|
LIBDNS_EXTERNAL_DATA const dns_master_style_t
|
||||||
dns_master_style_explicitttl = {
|
dns_master_style_explicitttl = {
|
||||||
DNS_STYLEFLAG_OMIT_OWNER |
|
DNS_STYLEFLAG_OMIT_OWNER |
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: zone.c,v 1.403 2004/01/05 04:21:30 marka Exp $ */
|
/* $Id: zone.c,v 1.404 2004/01/07 05:27:17 marka Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
@ -2465,8 +2465,8 @@ zone_dump(dns_zone_t *zone, isc_boolean_t compact) {
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_result_t
|
static isc_result_t
|
||||||
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
|
dumptostream(dns_zone_t *zone, FILE *fd, const dns_master_style_t *style) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
dns_dbversion_t *version = NULL;
|
dns_dbversion_t *version = NULL;
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
@ -2481,13 +2481,22 @@ dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
|
|||||||
return (DNS_R_NOTLOADED);
|
return (DNS_R_NOTLOADED);
|
||||||
|
|
||||||
dns_db_currentversion(db, &version);
|
dns_db_currentversion(db, &version);
|
||||||
result = dns_master_dumptostream(zone->mctx, db, version,
|
result = dns_master_dumptostream(zone->mctx, db, version, style, fd);
|
||||||
&dns_master_style_default, fd);
|
|
||||||
dns_db_closeversion(db, &version, ISC_FALSE);
|
dns_db_closeversion(db, &version, ISC_FALSE);
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
|
||||||
|
return dumptostream(zone, fd, &dns_master_style_default);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_zone_fulldumptostream(dns_zone_t *zone, FILE *fd) {
|
||||||
|
return dumptostream(zone, fd, &dns_master_style_full);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_zone_unload(dns_zone_t *zone) {
|
dns_zone_unload(dns_zone_t *zone) {
|
||||||
REQUIRE(DNS_ZONE_VALID(zone));
|
REQUIRE(DNS_ZONE_VALID(zone));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user