andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From cd76af1ec2581cf4eaf57c3a92c17a57b5afcef8 Mon Sep 17 00:00:00 2001
dc8c34
From: Rich Megginson <rmeggins@redhat.com>
dc8c34
Date: Fri, 31 Jan 2014 16:49:58 -0700
dc8c34
Subject: [PATCH 160/225] Ticket #471 logconv.pl tool removes the access logs
dc8c34
 contents if "-M" is not correctly used
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/471
dc8c34
Reviewed by: nhosoi (Thanks!)
dc8c34
Branch: 389-ds-base-1.2.11
dc8c34
Fix Description: Do not call new_stats_block() until we verify that it is safe
dc8c34
to call it.  It will wipe out the file.
dc8c34
Platforms tested: RHEL6 x86_64
dc8c34
Flag Day: no
dc8c34
Doc impact: no
dc8c34
(cherry picked from commit 7447050f572fb8865145d020e9eab64032f667be)
dc8c34
(cherry picked from commit cfbda421535451d99d3ee774a49fc099cfb902f0)
dc8c34
(cherry picked from commit 811300f30264a82b6cd9d0e1d7594a066458912c)
dc8c34
(cherry picked from commit af85853d0a9bf429a365a2c1723ac0758046899a)
dc8c34
(cherry picked from commit fd065f1a2b5cc4bad4aecb14135943dbca8296d8)
dc8c34
---
dc8c34
 ldap/admin/src/logconv.pl | 19 +++++++++++++++----
dc8c34
 1 file changed, 15 insertions(+), 4 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
dc8c34
index e7d7507..99e0efd 100755
dc8c34
--- a/ldap/admin/src/logconv.pl
dc8c34
+++ b/ldap/admin/src/logconv.pl
dc8c34
@@ -104,6 +104,8 @@ my $reportBinds = "no";
dc8c34
 my $rootDN = "";
dc8c34
 my $needCleanup = 0;
dc8c34
 my @scopeTxt = ("0 (base)", "1 (one)", "2 (subtree)");
dc8c34
+my $reportStatsSecFile;
dc8c34
+my $reportStatsMinFile;
dc8c34
 
dc8c34
 GetOptions(
dc8c34
 	'd|rootDN=s' => \$rootDN,
dc8c34
@@ -115,8 +117,8 @@ GetOptions(
dc8c34
 	'S|startTime=s' => \$startTime,
dc8c34
 	'E|endTime=s' => \$endTime,
dc8c34
 	'B|bind=s' => sub { $reportBinds = "yes"; $bindReportDN=($_[1]) },
dc8c34
-	'm|reportFileSecs=s' => sub { my ($opt,$value) = @_; $s_stats = new_stats_block($value); $reportStats = "-m";},
dc8c34
-	'M|reportFileMins=s' =>  sub { my ($opt,$value) = @_; $m_stats = new_stats_block($value); $reportStats = "-M";},
dc8c34
+	'm|reportFileSecs=s' => \$reportStatsSecFile,
dc8c34
+	'M|reportFileMins=s' =>  \$reportStatsMinFile,
dc8c34
 	'h|help' => sub { displayUsage() },
dc8c34
 	# usage options '-efcibaltnxgjuiryp'
dc8c34
 	'e' => sub { $usage = $usage . "e"; },
dc8c34
@@ -169,14 +171,23 @@ while($arg_count <= $#ARGV){
dc8c34
 }
dc8c34
 
dc8c34
 if($file_count == 0){
dc8c34
-	if($reportStats){
dc8c34
-		print "Usage error for option $reportStats, either the output file or access log is missing!\n\n";
dc8c34
+	if($reportStatsSecFile or $reportStatsMinFile){
dc8c34
+		print "Usage error for option -m or -M, either the output file or access log is missing!\n\n";
dc8c34
 	} else {
dc8c34
 		print "There are no access logs specified!\n\n";
dc8c34
 	}
dc8c34
 	exit 1;
dc8c34
 }
dc8c34
 
dc8c34
+if ($reportStatsSecFile) {
dc8c34
+	$s_stats = new_stats_block($reportStatsSecFile);
dc8c34
+	$reportStats = "-m";
dc8c34
+}
dc8c34
+if ($reportStatsMinFile) {
dc8c34
+	$m_stats = new_stats_block($reportStatsMinFile);
dc8c34
+	$reportStats = "-M";
dc8c34
+}
dc8c34
+
dc8c34
 if ($sizeCount eq "all"){$sizeCount = "100000";}
dc8c34
 
dc8c34
 #######################################
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34