in a easily parsable format (-D and -o).
+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
accept out of range ADDRESSFAMILY values. [RT# 9979]
* 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 <isc/buffer.h>
#include <isc/log.h>
#include <isc/region.h>
+#include <isc/stdio.h>
#include <isc/types.h>
#include <dns/fixedname.h>
dns_zone_detach(&zone);
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);
+}
* 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
#define CHECK_TOOL_H
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
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 isc_boolean_t nomerge;
extern unsigned int zone_options;
* 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>
static isc_mem_t *mctx = NULL;
dns_zone_t *zone = NULL;
dns_zonetype_t zonetype = dns_zone_master;
+static int dumpzone = 0;
+static const char *output_filename;
#define ERRRET(result, function) \
do { \
static void
usage(void) {
fprintf(stderr,
- "usage: named-checkzone [-djqv] [-c class] [-t directory] "
- "[-w directory] zonename filename\n");
+ "usage: named-checkzone [-djqvD] [-c class] [-o output] "
+ "[-t directory] [-w directory] zonename filename\n");
exit(1);
}
char *classname = classname_in;
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) {
case 'c':
classname = isc_commandline_argument;
}
break;
+ case 'o':
+ output_filename = isc_commandline_argument;
+ break;
+
case 'v':
printf(VERSION "\n");
exit(0);
workdir = isc_commandline_argument;
break;
+ case 'D':
+ dumpzone++;
+ break;
+
default:
usage();
}
origin = argv[isc_commandline_index++];
filename = argv[isc_commandline_index++];
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)
fprintf(stdout, "OK\n");
destroy();
- 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>
<refentryinfo>
<arg><option>-v</option></arg>
<arg><option>-c <replaceable class="parameter">class</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>-w <replaceable class="parameter">directory</replaceable></option></arg>
+ <arg><option>-D</option></arg>
<arg choice="req">zonename</arg>
<arg choice="req">filename</arg>
</cmdsynopsis>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-o <replaceable class="parameter">filename</replaceable></term>
+ <listitem>
+ <para>
+ Write zone output to <filename>directory</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>-t <replaceable class="parameter">directory</replaceable></term>
<listitem>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>-D</term>
+ <listitem>
+ <para>
+ Dump zone file in canonical format.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>zonename</term>
<listitem>
* 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
#define DNS_MASTERDUMP_H 1
*/
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
* record line, never using $TTL statements. The TTL has a tab
* 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
#define DNS_ZONE_H 1
* '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
dns_zone_maintenance(dns_zone_t *zone);
/*
* 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>
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
dns_master_style_explicitttl = {
DNS_STYLEFLAG_OMIT_OWNER |
* 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>
return (result);
}
-isc_result_t
-dns_zone_dumptostream(dns_zone_t *zone, FILE *fd) {
+static isc_result_t
+dumptostream(dns_zone_t *zone, FILE *fd, const dns_master_style_t *style) {
isc_result_t result;
dns_dbversion_t *version = NULL;
dns_db_t *db = NULL;
return (DNS_R_NOTLOADED);
dns_db_currentversion(db, &version);
- result = dns_master_dumptostream(zone->mctx, db, version,
- &dns_master_style_default, fd);
+ result = dns_master_dumptostream(zone->mctx, db, version, style, fd);
dns_db_closeversion(db, &version, ISC_FALSE);
dns_db_detach(&db);
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
dns_zone_unload(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));