Bug 827570 - logrotate fails to find the file to mail, with the "mailfirst" and "delaycompress" options
logrotate fails to find the file to mail, with the "mailfirst" and "delaycomp...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: logrotate (Show other bugs)
6.2
x86_64 Linux
unspecified Severity medium
: rc
: ---
Assigned To: Jan Kaluža
qe-baseos-daemons
:
Depends On:
Blocks: 828095 855675
  Show dependency treegraph
 
Reported: 2012-06-01 15:08 EDT by Karen Etheridge
Modified: 2012-09-09 17:11 EDT (History)
4 users (show)

See Also:
Fixed In Version: logrotate-3.7.8-16.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 828095 855675 (view as bug list)
Environment:
Last Closed: 2012-08-15 12:05:59 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch from debian (985 bytes, text/plain)
2012-06-01 15:08 EDT, Karen Etheridge
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Debian BTS 504079 None None None 2012-06-01 15:08:19 EDT

  None (edit)
Description Karen Etheridge 2012-06-01 15:08:19 EDT
Created attachment 588564 [details]
Patch from debian

Description of problem:

logrotate fails to find the correct file to mail, when using "mailfirst" in combination with "delaycompress".  This is the same issue as described at: 

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504079
http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg582133.html

I have contacted the author, Paul Martin, and he informs me that this has been fixed in Debian for years, but Red Hat has not yet taken the patch.

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

"logrotate -v" reports:
logrotate 3.8.1 - Copyright (C) 1995-2001 Red Hat, Inc.

The contents of my /etc/redhat-release file is:
CentOS release 6.2 (Final)

uname -a is:
Linux host.domain.com 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux


How reproducible: always

Steps to Reproduce:

Use a config file like this:

    /home/foo/log/* {
        daily
        rotate 999
        compress
        dateext
        ifempty
        create 0755 foo users
        delaycompress
        olddir /home/foo/baklog

        mailfirst
        mail me@corp.com
    }

run 'logrotate --force -d <config file>'.


Actual results:

This can be seen in the output when running logrotate --force -d <config file>:

    rotating pattern: /home/foo/log/*  forced from command line (999 rotations)
    olddir is /home/foo/baklog, empty log files are rotated, old logs mailed to
me@corp.com
    considering log /home/foo/log/warning.log
      log needs rotating
    rotating log /home/foo/log/warning.log, log->rotateCount is 999
    dateext suffix '-20120531'
    glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
    glob finding logs to compress failed
    renaming /home/foo/log/warning.log to /home/foo/baklog/warning.log-20120531
    creating new /home/foo/log/warning.log mode = 0755 uid = 1823 gid = 100
    error: failed to open /home/foo/baklog/warning.log-20120531.gz for mailing:
No such file or directory

Expected results:

    The contents /home/foo/log/warning.log should be mailed, and the file rotated to /home/foo/baklog/warning.log-<date> (the latter does work correctly).

Additional info:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504079
http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg582133.html

I have contacted the author, Paul Martin, and he informs me that this has been fixed in Debian for years, but Red Hat has not yet taken the patch.

In addition, he provides the working patch (also attached):

    Fixes #504079.

    If you configure logrotate with mailfirst option with dateext and
    delaycompress, logrotate doesn't send the log to the specific email
    address, because it looks at for a .gz file, which doesn't exist (It
    hasn't been compressed yet).

    Index: logrotate-3.8.1/logrotate.c
    ===================================================================
    --- logrotate-3.8.1.orig/logrotate.c    2011-12-05 16:40:06.688440279 +0000
    +++ logrotate-3.8.1/logrotate.c 2011-12-05 16:40:09.932530558 +0000
    @@ -1072,7 +1072,8 @@
            }
            /* firstRotated is most recently created/compressed rotated log */
            sprintf(rotNames->firstRotated, "%s/%s%s%s%s",
    -               rotNames->dirName, rotNames->baseName, dext_str, fileext, compext);
    +               rotNames->dirName, rotNames->baseName, dext_str, fileext,
    +               (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext);
            globfree(&globResult);
            free(glob_pattern);
         } else {
Comment 2 Jan Kaluža 2012-06-04 04:45:08 EDT
Thanks for the report, I've fixed this bug upstream and added test for it:

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

I will check other debian patches too.
Comment 12 errata-xmlrpc 2012-08-15 12:05:59 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-1172.html

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