[master] add -J option to checkzone/compilezone
3459. [func] Added -J option to named-checkzone/named-compilezone to specify the path to the journal file. [RT #30958]
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
||||
3459. [func] Added -J option to named-checkzone/named-compilezone
|
||||
to specify the path to the journal file. [RT #30958]
|
||||
|
||||
3458. [bug] Return FORMERR when presented with a overly long
|
||||
domain named in a request. [RT #29682]
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
static const char *dbtype[] = { "rbt" };
|
||||
|
||||
int debug = 0;
|
||||
const char *journal = NULL;
|
||||
isc_boolean_t nomerge = ISC_TRUE;
|
||||
#if CHECK_LOCAL
|
||||
isc_boolean_t docheckmx = ISC_TRUE;
|
||||
@@ -608,6 +609,8 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
|
||||
CHECK(dns_zone_setorigin(zone, origin));
|
||||
CHECK(dns_zone_setdbtype(zone, 1, (const char * const *) dbtype));
|
||||
CHECK(dns_zone_setfile2(zone, filename, fileformat));
|
||||
if (journal != NULL)
|
||||
CHECK(dns_zone_setjournal(zone, journal));
|
||||
|
||||
DE_CONST(classname, region.base);
|
||||
region.length = strlen(classname);
|
||||
|
||||
@@ -50,6 +50,7 @@ void DestroySockets(void);
|
||||
#endif
|
||||
|
||||
extern int debug;
|
||||
extern const char *journal;
|
||||
extern isc_boolean_t nomerge;
|
||||
extern isc_boolean_t docheckmx;
|
||||
extern isc_boolean_t docheckns;
|
||||
|
||||
@@ -78,7 +78,7 @@ static void
|
||||
usage(void) {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-djqvD] [-c class] "
|
||||
"[-f inputformat] [-F outputformat] "
|
||||
"[-f inputformat] [-F outputformat] [-J filename] "
|
||||
"[-t directory] [-w directory] [-k (ignore|warn|fail)] "
|
||||
"[-n (ignore|warn|fail)] [-m (ignore|warn|fail)] "
|
||||
"[-r (ignore|warn|fail)] "
|
||||
@@ -167,7 +167,7 @@ main(int argc, char **argv) {
|
||||
isc_commandline_errprint = ISC_FALSE;
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv,
|
||||
"c:df:hi:jk:L:m:n:qr:s:t:o:vw:DF:M:S:W:"))
|
||||
"c:df:hi:jJ:k:L:m:n:qr:s:t:o:vw:DF:M:S:W:"))
|
||||
!= EOF) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
@@ -228,6 +228,11 @@ main(int argc, char **argv) {
|
||||
nomerge = ISC_FALSE;
|
||||
break;
|
||||
|
||||
case 'J':
|
||||
journal = isc_commandline_argument;
|
||||
nomerge = ISC_FALSE;
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
if (ARGCMP("warn")) {
|
||||
zone_options |= DNS_ZONEOPT_CHECKNAMES;
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<arg><option>-c <replaceable class="parameter">class</replaceable></option></arg>
|
||||
<arg><option>-f <replaceable class="parameter">format</replaceable></option></arg>
|
||||
<arg><option>-F <replaceable class="parameter">format</replaceable></option></arg>
|
||||
<arg><option>-J <replaceable class="parameter">filename</replaceable></option></arg>
|
||||
<arg><option>-i <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
<arg><option>-k <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
<arg><option>-m <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
@@ -94,6 +95,7 @@
|
||||
<arg><option>-C <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
<arg><option>-f <replaceable class="parameter">format</replaceable></option></arg>
|
||||
<arg><option>-F <replaceable class="parameter">format</replaceable></option></arg>
|
||||
<arg><option>-J <replaceable class="parameter">filename</replaceable></option></arg>
|
||||
<arg><option>-i <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
<arg><option>-k <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
<arg><option>-m <replaceable class="parameter">mode</replaceable></option></arg>
|
||||
@@ -177,7 +179,19 @@
|
||||
<term>-j</term>
|
||||
<listitem>
|
||||
<para>
|
||||
When loading the zone file read the journal if it exists.
|
||||
When loading a zone file, read the journal if it exists.
|
||||
The journal file name is assumed to be the zone file name
|
||||
appended with the string <filename>.jnl</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>-J <replaceable class="parameter">filename</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
When loading the zone file read the journal from the given
|
||||
file, if it exists. (Implies -j.)
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@@ -46,9 +46,10 @@ SUBDIRS = atomic db dst master mem hashes names net rbt resolver \
|
||||
|
||||
# Test programs that are built by default:
|
||||
# cfg_test is needed for regenerating doc/misc/options
|
||||
# makejournal is needed by system tests
|
||||
|
||||
# Alphabetically
|
||||
TARGETS = cfg_test@EXEEXT@
|
||||
TARGETS = cfg_test@EXEEXT@ makejournal@EXEEXT@
|
||||
|
||||
# All the other tests are optional and not built by default.
|
||||
|
||||
@@ -92,7 +93,7 @@ XTARGETS = adb_test@EXEEXT@ \
|
||||
zone_test@EXEEXT@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = cfg_test.c ${XSRCS}
|
||||
SRCS = cfg_test.c makejournal.c ${XSRCS}
|
||||
|
||||
XSRCS = adb_test.c \
|
||||
byaddr_test.c \
|
||||
@@ -310,6 +311,10 @@ cfg_test@EXEEXT@: cfg_test.@O@ ${ISCCFGDEPLIBS} ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ cfg_test.@O@ \
|
||||
${ISCCFGLIBS} ${DNSLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
makejournal@EXEEXT@: makejournal.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ makejournal.@O@ \
|
||||
${DNSLIBS} ${ISCLIBS} ${LIBS}
|
||||
|
||||
distclean::
|
||||
rm -f headerdep_test.sh
|
||||
|
||||
|
||||
171
bin/tests/makejournal.c
Normal file
171
bin/tests/makejournal.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
#include <config.h>
|
||||
|
||||
#include <isc/entropy.h>
|
||||
#include <isc/hash.h>
|
||||
#include <isc/log.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <dns/db.h>
|
||||
#include <dns/fixedname.h>
|
||||
#include <dns/journal.h>
|
||||
#include <dns/log.h>
|
||||
#include <dns/name.h>
|
||||
#include <dns/result.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_entropy_t *ectx = NULL;
|
||||
|
||||
static isc_boolean_t hash_active = ISC_FALSE, dst_active = ISC_FALSE;
|
||||
|
||||
/*
|
||||
* Logging categories: this needs to match the list in bin/named/log.c.
|
||||
*/
|
||||
static isc_logcategory_t categories[] = {
|
||||
{ "", 0 },
|
||||
{ "client", 0 },
|
||||
{ "network", 0 },
|
||||
{ "update", 0 },
|
||||
{ "queries", 0 },
|
||||
{ "unmatched", 0 },
|
||||
{ "update-security", 0 },
|
||||
{ "query-errors", 0 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static isc_result_t
|
||||
loadzone(dns_db_t **db, const char *origin, const char *filename) {
|
||||
isc_result_t result;
|
||||
dns_fixedname_t fixed;
|
||||
dns_name_t *name;
|
||||
|
||||
dns_fixedname_init(&fixed);
|
||||
name = dns_fixedname_name(&fixed);
|
||||
|
||||
result = dns_name_fromstring(name, origin, 0, NULL);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return(result);
|
||||
|
||||
result = dns_db_create(mctx, "rbt", name, dns_dbtype_zone,
|
||||
dns_rdataclass_in, 0, NULL, db);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
|
||||
result = dns_db_load(*db, filename);
|
||||
return (result);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
isc_result_t result;
|
||||
char *origin, *file1, *file2, *journal;
|
||||
dns_db_t *old = NULL, *new = NULL;
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
if (argc != 5) {
|
||||
printf("usage: %s origin file1 file2 journal\n", argv[0]);
|
||||
return (1);
|
||||
}
|
||||
|
||||
origin = argv[1];
|
||||
file1 = argv[2];
|
||||
file2 = argv[3];
|
||||
journal = argv[4];
|
||||
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
CHECK(isc_mem_create(0, 0, &mctx));
|
||||
CHECK(isc_entropy_create(mctx, &ectx));
|
||||
|
||||
CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
||||
hash_active = ISC_TRUE;
|
||||
|
||||
CHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING));
|
||||
dst_active = ISC_TRUE;
|
||||
|
||||
CHECK(isc_log_create(mctx, &lctx, &logconfig));
|
||||
isc_log_registercategories(lctx, categories);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
destination.file.maximum_size = 0;
|
||||
CHECK(isc_log_createchannel(logconfig, "stderr",
|
||||
ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC,
|
||||
&destination, 0));
|
||||
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
|
||||
|
||||
dns_result_register();
|
||||
|
||||
result = loadzone(&old, origin, file1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Couldn't load %s: ", file1);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = loadzone(&new, origin, file2);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Couldn't load %s: ", file2);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = dns_db_diff(mctx, new, NULL, old, NULL, journal);
|
||||
|
||||
cleanup:
|
||||
if (result != ISC_R_SUCCESS)
|
||||
fprintf(stderr, "%s\n", isc_result_totext(result));
|
||||
|
||||
if (new != NULL)
|
||||
dns_db_detach(&new);
|
||||
if (old != NULL)
|
||||
dns_db_detach(&old);
|
||||
|
||||
if (lctx != NULL)
|
||||
isc_log_destroy(&lctx);
|
||||
if (dst_active) {
|
||||
dst_lib_destroy();
|
||||
dst_active = ISC_FALSE;
|
||||
}
|
||||
if (hash_active) {
|
||||
isc_hash_destroy();
|
||||
hash_active = ISC_FALSE;
|
||||
}
|
||||
if (ectx != NULL)
|
||||
isc_entropy_detach(&ectx);
|
||||
if (mctx != NULL)
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
return(result != ISC_R_SUCCESS ? 1 : 0);
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
|
||||
# $Id: clean.sh,v 1.2 2011/03/02 04:20:33 marka Exp $
|
||||
|
||||
rm -f test.out.*
|
||||
rm -f test.*
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: tests.sh,v 1.2 2011/03/02 04:20:33 marka Exp $
|
||||
|
||||
SYSTEMTESTTOP=..
|
||||
. $SYSTEMTESTTOP/conf.sh
|
||||
|
||||
@@ -30,4 +28,19 @@ do
|
||||
status=`expr $status + $ret`
|
||||
done
|
||||
|
||||
echo "I:checking with journal file ($n)"
|
||||
ret=0
|
||||
$CHECKZONE -D -o test.orig.db test zones/test1.db > /dev/null 2>&1 || ret=1
|
||||
$CHECKZONE -D -o test.changed.db test zones/test2.db > /dev/null 2>&1 || ret=1
|
||||
../../makejournal test test.orig.db test.changed.db test.orig.db.jnl 2>&1 || ret=1
|
||||
jlines=`$JOURNALPRINT test.orig.db.jnl | wc -l`
|
||||
[ $jlines = 3 ] || ret=1
|
||||
$CHECKZONE -D -j -o test.out1.db test test.orig.db > /dev/null 2>&1 || ret=1
|
||||
cmp -s test.changed.db test.out1.db || ret=1
|
||||
mv -f test.orig.db.jnl test.journal
|
||||
$CHECKZONE -D -J test.journal -o test.out2.db test test.orig.db > /dev/null 2>&1 || ret=1
|
||||
cmp -s test.changed.db test.out2.db || ret=1
|
||||
if [ $ret != 0 ]; then echo "I:failed"; fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
exit $status
|
||||
|
||||
21
bin/tests/system/checkzone/zones/test1.db
Normal file
21
bin/tests/system/checkzone/zones/test1.db
Normal file
@@ -0,0 +1,21 @@
|
||||
; Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
;
|
||||
; Permission to use, copy, modify, and/or distribute this software for any
|
||||
; purpose with or without fee is hereby granted, provided that the above
|
||||
; copyright notice and this permission notice appear in all copies.
|
||||
;
|
||||
; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
; AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
; PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
$TTL 600
|
||||
@ SOA ns hostmaster 2012010901 3600 1200 604800 1200
|
||||
NS ns
|
||||
ns A 192.0.2.1
|
||||
|
||||
addr1 A 10.53.0.1
|
||||
22
bin/tests/system/checkzone/zones/test2.db
Normal file
22
bin/tests/system/checkzone/zones/test2.db
Normal file
@@ -0,0 +1,22 @@
|
||||
; Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
||||
;
|
||||
; Permission to use, copy, modify, and/or distribute this software for any
|
||||
; purpose with or without fee is hereby granted, provided that the above
|
||||
; copyright notice and this permission notice appear in all copies.
|
||||
;
|
||||
; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
; AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
; PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
$TTL 600
|
||||
@ SOA ns hostmaster 2012010902 3600 1200 604800 1200
|
||||
NS ns
|
||||
ns A 192.0.2.1
|
||||
|
||||
addr1 A 10.53.0.1
|
||||
addr2 A 10.53.0.2
|
||||
Reference in New Issue
Block a user