andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0027-Ticket-47910-logconv.pl-check-that-the-end-time-is-g.patch

a2f18f
From 422028f6589250523c8a8669827bd0cccc347090 Mon Sep 17 00:00:00 2001
a2f18f
From: Mark Reynolds <mreynolds@redhat.com>
a2f18f
Date: Mon, 20 Jul 2015 11:18:12 -0400
a2f18f
Subject: [PATCH 27/30] Ticket 47910 - logconv.pl - check that the end time is
a2f18f
 greater than the start time
a2f18f
a2f18f
Bug Description:  There is no check if the end time is greater than the start time.
a2f18f
                  This leads to an empty report being generated, when an error
a2f18f
                  should be returned instead.
a2f18f
a2f18f
Fix Description:  If start and end time are used, validate that the end time is
a2f18f
                  greater than the start time.
a2f18f
a2f18f
                  Also, improved an error message when the tool options are not
a2f18f
                  correctly used.
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/47910
a2f18f
a2f18f
Reviewed by: nhosoi(Thanks!)
a2f18f
a2f18f
(cherry picked from commit 34ffa6c44734b99c252e7585bb499089ac8e6a67)
a2f18f
(cherry picked from commit 16b95b12d26fb293d68be154c602398798353bb8)
a2f18f
---
a2f18f
 ldap/admin/src/logconv.pl | 22 +++++++++++++++++-----
a2f18f
 1 file changed, 17 insertions(+), 5 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
a2f18f
index d26e91e..0038a03 100755
a2f18f
--- a/ldap/admin/src/logconv.pl
a2f18f
+++ b/ldap/admin/src/logconv.pl
a2f18f
@@ -148,14 +148,13 @@ while($arg_count <= $#ARGV){
a2f18f
 }
a2f18f
 
a2f18f
 if($file_count == 0){
a2f18f
-	if($reportStatsSecFile or $reportStatsMinFile){
a2f18f
-		print "Usage error for option -m or -M, either the output file or access log is missing!\n\n";
a2f18f
-	} else {
a2f18f
-		print "There are no access logs specified!\n\n";
a2f18f
-	}
a2f18f
+	print "There are no access logs specified, or the tool options have not been used correctly!\n";
a2f18f
 	exit 1;
a2f18f
 }
a2f18f
 
a2f18f
+#
a2f18f
+# Initialize the statistic blocks
a2f18f
+#
a2f18f
 if ($reportStatsSecFile) {
a2f18f
 	$s_stats = new_stats_block($reportStatsSecFile);
a2f18f
 	$reportStats = "-m";
a2f18f
@@ -357,6 +356,19 @@ my %monthname = (
a2f18f
 
a2f18f
 );
a2f18f
 
a2f18f
+#
a2f18f
+# Validate start/end times (if specified)
a2f18f
+#
a2f18f
+if ($startTime and $endTime){
a2f18f
+	# Make sure the end time is not earlier than the start time
a2f18f
+	my $testStart = convertTimeToSeconds($startTime);
a2f18f
+	my $testEnd = convertTimeToSeconds($endTime);
a2f18f
+	if ($testStart > $testEnd){
a2f18f
+		print "Start time ($startTime) is greater than end time ($endTime)!\n";
a2f18f
+		exit 1;
a2f18f
+	}
a2f18f
+}
a2f18f
+
a2f18f
 my $linesProcessed;
a2f18f
 my $lineBlockCount;
a2f18f
 my $cursize = 0;
a2f18f
-- 
a2f18f
1.9.3
a2f18f