Bug 58334 - Entries with glob character match old logfiles
Entries with glob character match old logfiles
Product: Red Hat Linux
Classification: Retired
Component: logrotate (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Elliot Lee
Aaron Brown
Depends On:
  Show dependency treegraph
Reported: 2002-01-14 11:21 EST by Vladimir Pastukhov
Modified: 2007-04-18 12:39 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-01-14 11:21:11 EST
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 Vladimir Pastukhov 2002-01-14 11:21:05 EST
Description of problem:
Configuration entries with glob (like /var/log/httpd/*) will match old 
(.n, .n.gz) files on 2nd and subsequent rotations.

How reproducible:

Steps to Reproduce:
1. /var/log/httpd initially has two files:
access_log and error_log

2. logrotate config entry looks like this:
/var/log/httpd/* {
    rotate 8
    ... other options ...

Actual Results:
First rotation:
access_log => access_log.1
error_log => error_log.1
access_log and error_log are empty.

Second rotation:
access_log.1 => access_log.2
access_log => access_log.1
access_log.1 => access_log.1.1
error_log.1 => error_log.2
error_log => error_log.1
error_log.1 => error_log.1.1
access_log, error_log, access_log.1 and error_log.1 are empty.

Expected Results:
.n files should be skipped from second rotation

Proposed solution: before returning from readConfigFile(), inspect all log 
entries and remove unneccessary items from log->files list (this cannot be done 
right after glob() because corresponding extension and compressext options are 
not read yet)
Comment 1 Elliot Lee 2002-01-29 14:14:40 EST
The main problem is that now you are asking to filter out files that match
'\.[0-9]+(\.gz)?$' (regex, not glob), which could possible include some files
that people really want rotated. It's better for logrotate to behave as
instructed, even if it is little "dumber".

The right solution is to just list the files that you actually want rotated, e.g.
/var/log/httpd/access_log /var/log/httpd/agent_log /var/log/httpd/error_log
/var/log/httpd/referer_log {

This is the way the Red Hat /etc/logrotate.d/apache file does it, and it solves
the problem you describe.

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