]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Allow named-journalprint to compact journals at a given serial
authorMark Andrews <marka@isc.org>
Tue, 4 May 2021 07:20:26 +0000 (17:20 +1000)
committerMark Andrews <marka@isc.org>
Wed, 5 May 2021 13:36:06 +0000 (23:36 +1000)
(cherry picked from commit 71df4fb84c98cc0916539c6e3daef46fc0539ae2)

bin/tools/named-journalprint.c
bin/tools/named-journalprint.rst
doc/man/named-journalprint.8in

index cea855e4c6700a3808b866c9c8959d770ca26aa1..74b7227059c0cf6c8d388a4a4c05e62e5664d082 100644 (file)
@@ -68,12 +68,24 @@ main(int argc, char **argv) {
        isc_log_t *lctx = NULL;
        uint32_t flags = 0U;
        int ch;
+       bool compact = false;
        bool downgrade = false;
        bool upgrade = false;
+       unsigned int serial = 0;
+       char *endp = NULL;
 
        progname = argv[0];
-       while ((ch = isc_commandline_parse(argc, argv, "dux")) != -1) {
+       while ((ch = isc_commandline_parse(argc, argv, "c:dux")) != -1) {
                switch (ch) {
+               case 'c':
+                       compact = true;
+                       serial = strtoul(isc_commandline_argument, &endp, 0);
+                       if (endp == isc_commandline_argument || *endp != 0) {
+                               fprintf(stderr, "invalid serial: %s\n",
+                                       isc_commandline_argument);
+                               exit(1);
+                       }
+                       break;
                case 'd':
                        downgrade = true;
                        break;
@@ -105,6 +117,9 @@ main(int argc, char **argv) {
        } else if (downgrade) {
                flags = DNS_JOURNAL_COMPACTALL | DNS_JOURNAL_VERSION1;
                result = dns_journal_compact(mctx, file, 0, flags, 0);
+       } else if (compact) {
+               flags = 0;
+               result = dns_journal_compact(mctx, file, serial, flags, 0);
        } else {
                result = dns_journal_print(mctx, flags, file, stdout);
                if (result == DNS_R_NOJOURNAL) {
index 633bcb628b91fe95b2b5a22024c34b083f9cc191..974afe39d9ebbbb00b5edab6560d472a6dcd7569 100644 (file)
@@ -29,7 +29,7 @@ named-journalprint - print zone journal in human-readable form
 Synopsis
 ~~~~~~~~
 
-:program:`named-journalprint` [**-dux**] {journal}
+:program:`named-journalprint` [-c serial] [**-dux**] {journal}
 
 Description
 ~~~~~~~~~~~
@@ -51,6 +51,11 @@ into a human-readable text format. Each line begins with ``add`` or ``del``,
 to indicate whether the record was added or deleted, and continues with
 the resource record in master-file format.
 
+The ``-c`` option provides a mechanism to compact the journal starting
+with the specified serial. Note this option *must not* be used while
+``named`` is running and can cause data loss if the the zone file does
+not contain the data that is being remove.  Use with extreme caution.
+
 The ``-x`` option causes additional data about the journal file to be
 printed at the beginning of the output and before each group of changes.
 
index 769b9eb9deb8665900d6d4d57b92865573868a84..0c75780baf6f97b38155a266087d516860fc1c35 100644 (file)
@@ -32,7 +32,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
 ..
 .SH SYNOPSIS
 .sp
-\fBnamed\-journalprint\fP [\fB\-dux\fP] {journal}
+\fBnamed\-journalprint\fP [\-c serial] [\fB\-dux\fP] {journal}
 .SH DESCRIPTION
 .sp
 \fBnamed\-journalprint\fP scans the contents of a zone journal file,
@@ -52,6 +52,11 @@ into a human\-readable text format. Each line begins with \fBadd\fP or \fBdel\fP
 to indicate whether the record was added or deleted, and continues with
 the resource record in master\-file format.
 .sp
+The \fB\-c\fP option provides a mechanism to compact the journal starting
+with the specified serial. Note this option \fImust not\fP be used while
+\fBnamed\fP is running and can cause data loss if the the zone file does
+not contain the data that is being remove.  Use with extreme caution.
+.sp
 The \fB\-x\fP option causes additional data about the journal file to be
 printed at the beginning of the output and before each group of changes.
 .sp