Blame SOURCES/0006-Issue-50572-After-running-cl-dump-dbdir-cldb-ldif.do.patch

a3727e
From d8935139d377ad75be4242db7d3194f3706dc44a Mon Sep 17 00:00:00 2001
a3727e
From: Simon Pichugin <spichugi@redhat.com>
a3727e
Date: Thu, 29 Aug 2019 15:51:56 +0200
a3727e
Subject: [PATCH] Issue 50572 - After running cl-dump dbdir/cldb/*ldif.done are
a3727e
 not deleted
a3727e
a3727e
Description: By default, remove ldif.done files after running cl-dump.
a3727e
Add an option '-l' which allows keep the files.
a3727e
Update man files.
a3727e
a3727e
https://pagure.io/389-ds-base/issue/50572
a3727e
a3727e
Reviewed by: firstyear, mreynolds (Thanks!)
a3727e
---
a3727e
 ldap/admin/src/scripts/cl-dump.pl | 23 +++++++++++++++--------
a3727e
 man/man1/cl-dump.1                | 11 +++++++----
a3727e
 2 files changed, 22 insertions(+), 12 deletions(-)
a3727e
a3727e
diff --git a/ldap/admin/src/scripts/cl-dump.pl b/ldap/admin/src/scripts/cl-dump.pl
a3727e
index f4ad5dd33..2e7f20413 100755
a3727e
--- a/ldap/admin/src/scripts/cl-dump.pl
a3727e
+++ b/ldap/admin/src/scripts/cl-dump.pl
a3727e
@@ -5,7 +5,7 @@
a3727e
 # All rights reserved.
a3727e
 #
a3727e
 # License: GPL (version 3 or any later version).
a3727e
-# See LICENSE for details. 
a3727e
+# See LICENSE for details.
a3727e
 # END COPYRIGHT BLOCK
a3727e
 ###################################################################################
a3727e
 #
a3727e
@@ -13,7 +13,7 @@
a3727e
 #
a3727e
 # SYNOPSIS:
a3727e
 #  cl-dump.pl [-h host] [-p port] [-D bind-dn] -w bind-password | -P bind-cert
a3727e
-#       [-r replica-roots] [-o output-file] [-c] [-v]
a3727e
+#       [-r replica-roots] [-o output-file] [-c] [-l] [-v]
a3727e
 #
a3727e
 #  cl-dump.pl -i changelog-ldif-file-with-base64encoding [-o output-file] [-c]
a3727e
 #
a3727e
@@ -22,7 +22,7 @@
a3727e
 #
a3727e
 # OPTIONS:
a3727e
 #    -c Dump and interpret CSN only. This option can be used with or
a3727e
-#       without -i option. 
a3727e
+#       without -i option.
a3727e
 #
a3727e
 #    -D bind-dn
a3727e
 #       Directory server's bind DN. Default to "cn=Directory Manager" if
a3727e
@@ -32,6 +32,8 @@
a3727e
 #       Directory server's host. Default to the server where the script
a3727e
 #       is running.
a3727e
 #
a3727e
+#    -l Preserve generated ldif.done files from changelogdir
a3727e
+#
a3727e
 #    -i changelog-ldif-file-with-base64encoding
a3727e
 #       If you already have a ldif-like changelog, but the changes
a3727e
 #       in that file are encoded, you may use this option to
a3727e
@@ -68,7 +70,7 @@
a3727e
 # all of this nonsense can be omitted if the mozldapsdk and perldap are
a3727e
 # installed in the operating system locations (e.g. /usr/lib /usr/lib/perl5)
a3727e
 
a3727e
-$usage="Usage: $0 [-h host] [-p port] [-D bind-dn] [-w bind-password | -P bind-cert] [-r replica-roots] [-o output-file] [-c] [-v]\n\n       $0 -i changelog-ldif-file-with-base64encoding [-o output-file] [-c]\n";
a3727e
+$usage="Usage: $0 [-h host] [-p port] [-D bind-dn] [-w bind-password | -P bind-cert] [-r replica-roots] [-o output-file] [-c] [-l] [-v]\n\n       $0 -i changelog-ldif-file-with-base64encoding [-o output-file] [-c]\n";
a3727e
 
a3727e
 use Getopt::Std;			# Parse command line arguments
a3727e
 use Mozilla::LDAP::Conn;		# LDAP module for Perl
a3727e
@@ -86,7 +88,7 @@ $version = "Directory Server Changelog Dump - Version 1.0";
a3727e
 	$| = 1;
a3727e
 
a3727e
 	# Check for legal options
a3727e
-	if (!getopts('h:p:D:w:P:r:o:cvi:')) {
a3727e
+	if (!getopts('h:p:D:w:P:r:o:clvi:')) {
a3727e
 		print $usage;
a3727e
 		exit -1;
a3727e
 	}
a3727e
@@ -123,7 +125,7 @@ sub validateArgs
a3727e
 	if ($opt_o && ! open (OUTPUT, ">$opt_o")) {
a3727e
 		print "Can't create output file $opt_o\n";
a3727e
 		$rc = -1;
a3727e
-	} 
a3727e
+	}
a3727e
 	# Open STDOUT if option -o is missing
a3727e
 	open (OUTPUT, ">-") if !$opt_o;
a3727e
 
a3727e
@@ -194,10 +196,15 @@ sub cl_dump_and_decode
a3727e
 			else {
a3727e
 				&cl_decode ($_);
a3727e
 			}
a3727e
-			# Test op -M doesn't work well so we use rename
a3727e
+			# Test op -M doesn't work well so we use rename/remove
a3727e
 			# here to avoid reading the same ldif file more
a3727e
 			# than once.
a3727e
-			rename ($ldif, "$ldif.done");
a3727e
+			if ($opt_l) {
a3727e
+				rename ($ldif, "$ldif.done");
a3727e
+			} else {
a3727e
+				# Remove the file - default behaviou when '-l' is not specified
a3727e
+				unlink ($ldif)
a3727e
+			}
a3727e
 		}
a3727e
 		&print_header ($replica, "Not Found") if !$gotldif;
a3727e
 	}
a3727e
diff --git a/man/man1/cl-dump.1 b/man/man1/cl-dump.1
a3727e
index db736aca9..fbb836a72 100644
a3727e
--- a/man/man1/cl-dump.1
a3727e
+++ b/man/man1/cl-dump.1
a3727e
@@ -20,7 +20,7 @@ cl-dump \- Dump and decode Directory Server replication change log
a3727e
 .SH SYNOPSIS
a3727e
 .B cl\-dump
a3727e
 [\fI\-h host\fR] [\fI\-p port\fR] [\fI\-D bind\(hydn\fR] \-w bind\(hypassword | \-P bind\(hycert
a3727e
-       [\fI\-r replica\(hyroots\fR] [\fI\-o output\(hyfile\fR] [\fI\-c\fR] [\fI\-v\fR]
a3727e
+       [\fI\-r replica\(hyroots\fR] [\fI\-o output\(hyfile\fR] [\fI\-c\fR] [\fI\-l\fR] [\fI\-v\fR]
a3727e
 
a3727e
 .PP
a3727e
 .B cl\-dump
a3727e
@@ -30,12 +30,12 @@ cl-dump \- Dump and decode Directory Server replication change log
a3727e
 Dump and decode Directory Server replication change log
a3727e
 .PP
a3727e
 .\" TeX users may be more comfortable with the \fB<whatever>\fP and
a3727e
-.\" \fI<whatever>\fP escape sequences to invode bold face and italics, 
a3727e
+.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
a3727e
 .\" respectively.
a3727e
 .SH OPTIONS
a3727e
 A summary of options is included below.
a3727e
 .TP
a3727e
-.B \-c 
a3727e
+.B \-c
a3727e
 Dump and interpret CSN only. This option can be used with or
a3727e
 without \-i option.
a3727e
 .TP
a3727e
@@ -47,6 +47,9 @@ the option is omitted.
a3727e
 Directory server's host. Default to the server where the script
a3727e
 is running.
a3727e
 .TP
a3727e
+.B \-l
a3727e
+Preserve generated ldif.done files from changelogdir
a3727e
+.TP
a3727e
 .B \-i changelog\(hyldif\(hyfile\(hywith\(hybase64encoding
a3727e
 If you already have a ldif-like changelog, but the changes
a3727e
 in that file are encoded, you may use this option to
a3727e
@@ -66,7 +69,7 @@ Specify replica roots whose changelog you want to dump. The replica
a3727e
 roots may be separated by comma. All the replica roots would be
a3727e
 dumped if the option is omitted.
a3727e
 .TP
a3727e
-.B \-v 
a3727e
+.B \-v
a3727e
 Print the version of this script.
a3727e
 .TP
a3727e
 .B \-w bind\(hypassword
a3727e
-- 
a3727e
2.21.0
a3727e