Bug 65655 - Small error in /etc/log.d/scripts/logfiles/xferlog/applydate
Small error in /etc/log.d/scripts/logfiles/xferlog/applydate
Product: Red Hat Linux
Classification: Retired
Component: logwatch (Show other bugs)
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Elliot Lee
Depends On:
  Show dependency treegraph
Reported: 2002-05-29 11:57 EDT by Mathieu Chouquet-Stringer
Modified: 2008-05-01 11:38 EDT (History)
0 users

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

Attachments (Terms of Use)

  None (edit)
Description Mathieu Chouquet-Stringer 2002-05-29 11:57:11 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):

How reproducible:

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:

Additional info:
Comment 1 Elliot Lee 2002-06-27 06:54:22 EDT
chomp added in 2.6-5

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