Red Hat Bugzilla – Bug 65655
Small error in /etc/log.d/scripts/logfiles/xferlog/applydate
Last modified: 2008-05-01 11:38:02 EDT
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):
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 added in 2.6-5