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 } 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 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 {
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.
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