Preserve mtime/atime on compression. (Closes: #286957) --- logrotate.c | 9 +++++++++ 1 file changed, 9 insertions(+) Index: logrotate-3.7.1/logrotate.c =================================================================== --- logrotate-3.7.1.orig/logrotate.c +++ logrotate-3.7.1/logrotate.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #ifdef WITH_SELINUX #include @@ -120,6 +122,7 @@ static int removeLogFile(char * name) { static int compressLogFile(char * name, logInfo * log, struct stat *sb) { char * compressedName; const char ** fullCommand; + struct utimbuf utim; int inFile; int outFile; int i; @@ -190,6 +193,12 @@ static int compressLogFile(char * name, message(MESS_ERROR, "failed to compress log %s\n", name); return 1; } + + utim.actime = sb->st_atime; + utim.modtime = sb->st_mtime; + utime(compressedName,&utim); + /* If we can't change atime/mtime, it's not a disaster. + It might possibly fail under SELinux. */ unlink(name);