Bug 948778

Summary: pre and post scripts run for all wildcarded logs
Product: [Fedora] Fedora Reporter: Luke Campbell <judd_goat>
Component: logrotateAssignee: Jan Kaluža <jkaluza>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 19CC: jkaluza, tsmetana
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: logrotate-3.8.4-1.fc19 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-22 03:09:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luke Campbell 2013-04-05 12:15:23 UTC
Description of problem:
I am not sure if this is a bug, but according to the man page for logrotate, pre/post scripts should only be run for log files that WILL be rotated. If you use wildcards (or list multiple files) the scripts are run even if the log is not rotated.

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

How reproducible:
Always

Steps to Reproduce:
1. Create logrotate configuration with pre/post script(s), that uses a wildcard (or multiple file listings) to match file names.
2. Run logrotate with the configuration.
  
Actual results:
Pre/Post scripts are executed for ALL files.

Expected results:
Pre/Post scripts only executed on files that are rotated.

Additional info:
Example:

/tmp/logs/test*.log {
    rotate 2
    daily
    size=4k
    copytruncate
    missingok
    compress
    nosharedscripts
    prerotate
        echo $1
    endscript
    postrotate
        echo $1
    endscript
}

/tmp/logs contains 4 files:
test1.log = 2K
test2.log = 3K
test3.log = 4K
test4.log = 5K

Executing `logrotate test.cfg`, pre and post scripts will be run for ALL test*.log, not just test3 and test4.

Comment 1 Jan Kaluža 2013-04-09 11:24:15 UTC
I think this is bug in logrotate, I have fixed it upstream in this commit:

https://fedorahosted.org/logrotate/changeset/403

However, I don't presume to fix this in Fedora 17. I will probably fix it in F19.

Comment 2 Fedora Update System 2013-04-30 09:18:00 UTC
logrotate-3.8.4-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/logrotate-3.8.4-1.fc19

Comment 3 Fedora Update System 2013-04-30 19:57:55 UTC
Package logrotate-3.8.4-1.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing logrotate-3.8.4-1.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-7029/logrotate-3.8.4-1.fc19
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2013-05-22 03:09:44 UTC
logrotate-3.8.4-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.