Bug 65655 - Small error in /etc/log.d/scripts/logfiles/xferlog/applydate
Summary: Small error in /etc/log.d/scripts/logfiles/xferlog/applydate
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: logwatch   
(Show other bugs)
Version: 7.3
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Elliot Lee
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2002-05-29 15:57 UTC by Mathieu Chouquet-Stringer
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-05-29 15:57:16 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Mathieu Chouquet-Stringer 2002-05-29 15:57:11 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 Galeon/1.2.3 (X11; Linux i686; U;) Gecko/20020523

Description of problem:
Applydate in the version of logwatch shipped with RH 7.3 doesn't work properly.
Applydate is a filter written in perl which is just supposed to grep for
specific dates from it's standard output (which is /var/log/xferlog).
When the program was run every night it never reported any ftp traffic  which
was plainly wrong. 
So here it why. If you're looking for transfers made yesterday (which the
default in the cron job), the script does this:
$SearchYear = `/bin/date -d "1 day ago" +"%Y"`;

Which sounds correct but when you try to match a line from STDIN with this:
if ($ThisLine =~ m/^... $SearchDate ..:..:.. $SearchYear/o)
it doesn't work because $SearchYear has a "\n" at its end.

The funny thing is that the trailing "\n" was removed from $SearchDate but not
from $SearchYear (with a chomp()).

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. logwatch --service ftpd-xferlog --range yesterday --print outputs nothing
because $SearchYear == "2002\n"
2. logwatch --service ftpd-xferlog --range all --print works perfectly because
$SearchYear == "...."

	

Actual Results:  Nothing happened because perl couldn't match any line.

So my fix was just to add this line:
chomp($SearchYear);

Additional info:

Comment 1 Elliot Lee 2002-06-27 10:54:22 UTC
chomp added in 2.6-5


Note You need to log in before you can comment on or make changes to this bug.