Blob Blame Raw
From 7dc5c28a3beeeb90cdae084ae6d1fa338c09c50f Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Fri, 31 Jan 2014 16:49:58 -0700
Subject: [PATCH 87/87] Ticket #471 logconv.pl tool removes the access logs
 contents if "-M" is not correctly used

https://fedorahosted.org/389/ticket/471
Reviewed by: nhosoi (Thanks!)
Branch: rhel-7.0
Fix Description: Do not call new_stats_block() until we verify that it is safe
to call it.  It will wipe out the file.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 7447050f572fb8865145d020e9eab64032f667be)
(cherry picked from commit cfbda421535451d99d3ee774a49fc099cfb902f0)
(cherry picked from commit 811300f30264a82b6cd9d0e1d7594a066458912c)
---
 ldap/admin/src/logconv.pl | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index e7d7507..99e0efd 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -104,6 +104,8 @@ my $reportBinds = "no";
 my $rootDN = "";
 my $needCleanup = 0;
 my @scopeTxt = ("0 (base)", "1 (one)", "2 (subtree)");
+my $reportStatsSecFile;
+my $reportStatsMinFile;
 
 GetOptions(
 	'd|rootDN=s' => \$rootDN,
@@ -115,8 +117,8 @@ GetOptions(
 	'S|startTime=s' => \$startTime,
 	'E|endTime=s' => \$endTime,
 	'B|bind=s' => sub { $reportBinds = "yes"; $bindReportDN=($_[1]) },
-	'm|reportFileSecs=s' => sub { my ($opt,$value) = @_; $s_stats = new_stats_block($value); $reportStats = "-m";},
-	'M|reportFileMins=s' =>  sub { my ($opt,$value) = @_; $m_stats = new_stats_block($value); $reportStats = "-M";},
+	'm|reportFileSecs=s' => \$reportStatsSecFile,
+	'M|reportFileMins=s' =>  \$reportStatsMinFile,
 	'h|help' => sub { displayUsage() },
 	# usage options '-efcibaltnxgjuiryp'
 	'e' => sub { $usage = $usage . "e"; },
@@ -169,14 +171,23 @@ while($arg_count <= $#ARGV){
 }
 
 if($file_count == 0){
-	if($reportStats){
-		print "Usage error for option $reportStats, either the output file or access log is missing!\n\n";
+	if($reportStatsSecFile or $reportStatsMinFile){
+		print "Usage error for option -m or -M, either the output file or access log is missing!\n\n";
 	} else {
 		print "There are no access logs specified!\n\n";
 	}
 	exit 1;
 }
 
+if ($reportStatsSecFile) {
+	$s_stats = new_stats_block($reportStatsSecFile);
+	$reportStats = "-m";
+}
+if ($reportStatsMinFile) {
+	$m_stats = new_stats_block($reportStatsMinFile);
+	$reportStats = "-M";
+}
+
 if ($sizeCount eq "all"){$sizeCount = "100000";}
 
 #######################################
-- 
1.8.1.4