diff --git a/SOURCES/logrotate-3.8.6-monthly-dst.patch b/SOURCES/logrotate-3.8.6-monthly-dst.patch new file mode 100644 index 0000000..4d8cdf6 --- /dev/null +++ b/SOURCES/logrotate-3.8.6-monthly-dst.patch @@ -0,0 +1,163 @@ +From 24a473e10883cf61278eb8a64876ebf9e2cfbdc4 Mon Sep 17 00:00:00 2001 +From: jkaluza +Date: Wed, 15 Oct 2014 13:22:23 +0000 +Subject: [PATCH] Backport debian manpage and mktime patches + +Upstream-commit: 9c68d75c729b926e2c70bc579a12e58e472abf57 +Signed-off-by: Kamil Dudka +--- + logrotate.8 | 40 ++++++++++++++++++++++------------------ + logrotate.c | 2 ++ + 2 files changed, 24 insertions(+), 18 deletions(-) + +diff --git a/logrotate.8 b/logrotate.8 +index e48dd0b..7d93eb9 100644 +--- a/logrotate.8 ++++ b/logrotate.8 +@@ -11,8 +11,8 @@ removal, and mailing of log files. Each log file may be handled daily, + weekly, monthly, or when it grows too large. + .P + Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify +-a log multiple times in one day unless the criterion for that log is +-based on the log's size and \fBlogrotate\fR is being run multiple times ++a log more than once in one day unless the criterion for that log is ++based on the log's size and \fBlogrotate\fR is being run more than once + each day, or unless the \fB\-f\fR or \fB\-\-force\fR option is used. + .P + Any number of config files may be given on the command line. Later config +@@ -68,7 +68,7 @@ Prints a short usage message. + + .TP + +\fB\-v\fR, \fB\-\-verbose\fR +-Turns on verbose mode. ++Turns on verbose mode, ie. display messages during rotation. + + .SH CONFIGURATION FILE + +@@ -120,9 +120,9 @@ compress + The first few lines set global options; in the example, logs are + compressed after they are rotated. Note that comments may appear + anywhere in the config file as long as the first non-whitespace +-character on the line is a #. ++character on the line is a \fB#\fR. + +-The next section of the config files defined how to handle the log file ++The next section of the config file defines how to handle the log file + \fI/var/log/messages\fR. The log will go through five weekly rotations before + being removed. After the log file has been rotated (but before the old + version of the log has been compressed), the command +@@ -130,14 +130,15 @@ version of the log has been compressed), the command + + The next section defines the parameters for both + \fI/var/log/httpd/access.log\fR and \fI/var/log/httpd/error.log\fR. +-They are rotated whenever it grows over 100k in size, and the old logs ++Each is rotated whenever it grows over 100k in size, and the old logs + files are mailed (uncompressed) to www@my.org after going through 5 + rotations, rather than being removed. The \fBsharedscripts\fR means that + the \fBpostrotate\fR script will only be run once (after the old logs have +-been compressed), not once for each log which is rotated. Note that the double +-quotes around the first filename at the beginning of this section allows +-logrotate to rotate logs with spaces in the name. Normal shell quoting rules +-apply, with ', ", and \\ characters supported. ++been compressed), not once for each log which is rotated. ++Note that log file names may be enclosed in ++quotes (and that quotes are required if the name contains spaces). ++Normal shell quoting rules apply, with \fB'\fR, \fB"\fR, and \fB\\\fR ++characters supported. + + The next section defines the parameters for all of the files in + \fI/var/log/news\fR. Each file is rotated on a monthly basis. This is +@@ -163,12 +164,12 @@ Old versions of log files are compressed with \fBgzip\fR(1) by default. See also + .TP + \fBcompresscmd\fR + Specifies which command to use to compress log files. The default is +-\fBgzip\fR. See also \fBcompress\fR. ++\fBgzip\fR(1). See also \fBcompress\fR. + + .TP + \fBuncompresscmd\fR + Specifies which command to use to uncompress log files. The default is +-\fBgunzip\fR. ++\fBgunzip\fR(1). + + .TP + \fBcompressext\fR +@@ -195,7 +196,7 @@ as the old log file stays in place. + + .TP + \fBcopytruncate\fR +-Truncate the original log file in place after creating a copy, ++Truncate the original log file to zero size in place after creating a copy, + instead of moving the old log file and optionally creating a new one. + It can be used when some program cannot be told to close its logfile + and thus might continue writing (appending) to the previous log file forever. +@@ -266,7 +267,7 @@ and thus might continue writing to the previous log file for some time. + .TP + \fBextension \fIext\fR + Log files with \fIext\fR extension can keep it after the rotation. +-If compression is used, the compression extension (normally \fB.gz\fR) ++If compression is used, the compression extension (normally \fI.gz\fR) + appears after \fIext\fR. For example you have a logfile named mylog.foo + and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz. + +@@ -293,7 +294,7 @@ the taboo extensions, as specified by the \fBtabooext\fR directive. + + .TP + \fBmail \fIaddress\fR +-When a log is rotated out-of-existence, it is mailed to \fIaddress\fR. If ++When a log is rotated out of existence, it is mailed to \fIaddress\fR. If + no mail should be generated by a particular log, the \fBnomail\fR directive + may be used. + +@@ -377,7 +378,7 @@ Do not archive old versions of log files with date extension + + .TP + \fBnomail\fR +-Don't mail old log files to any address. ++Do not mail old log files to any address. + + .TP + \fBnomissingok\fR +@@ -385,7 +386,7 @@ If a log file does not exist, issue an error. This is the default. + + .TP + \fBnoolddir\fR +-Logs are rotated in the same directory the log normally resides in (this ++Logs are rotated in the directory they normally reside in (this + overrides the \fBolddir\fR option). + + .TP +@@ -515,7 +516,10 @@ number of times specified with the \fBrotate\fR directive. + \fBsu \fIuser\fR \fIgroup\fR + Rotate log files set under this user and group instead of using default + user/group (usually root). \fIuser\fR specifies the user name used for +-rotation and \fIgroup\fR specifies the group used for rotation. ++rotation and \fIgroup\fR specifies the group used for rotation. If the ++user/group you specify here does not have sufficient privilege to make ++files with the ownership you've specified in a \fIcreate\fR instruction, ++it will cause an error. + + .TP + \fBtabooext\fR [+] \fIlist\fR +diff --git a/logrotate.c b/logrotate.c +index e056ccd..fabfde9 100644 +--- a/logrotate.c ++++ b/logrotate.c +@@ -2279,12 +2279,14 @@ static int readState(char *stateFilename) + return 1; + } + ++ memset(&st->lastRotated, 0, sizeof(st->lastRotated)); + st->lastRotated.tm_year = year; + st->lastRotated.tm_mon = month; + st->lastRotated.tm_mday = day; + st->lastRotated.tm_hour = hour; + st->lastRotated.tm_min = minute; + st->lastRotated.tm_sec = second; ++ st->lastRotated.tm_isdst = -1; + + /* fill in the rest of the st->lastRotated fields */ + lr_time = mktime(&st->lastRotated); +-- +2.14.3 + diff --git a/SOURCES/logrotate-3.8.6-unlink-on-failure.patch b/SOURCES/logrotate-3.8.6-unlink-on-failure.patch new file mode 100644 index 0000000..48a87ed --- /dev/null +++ b/SOURCES/logrotate-3.8.6-unlink-on-failure.patch @@ -0,0 +1,43 @@ +From 733a43731739ecf2b8b405eab6868e7912d779a9 Mon Sep 17 00:00:00 2001 +From: Jan Kaluza +Date: Mon, 25 Jan 2016 11:04:05 +0100 +Subject: [PATCH] Remove half-rotated files when rotation of particular log + file is skipped because of an error during copy or compression. + +Upstream-commit: e349752ccbbfa9ae8480ca504ded3af87e718298 +Signed-off-by: Kamil Dudka +--- + logrotate.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/logrotate.c b/logrotate.c +index fabfde9..f13d140 100644 +--- a/logrotate.c ++++ b/logrotate.c +@@ -633,6 +633,7 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb) + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + message(MESS_ERROR, "failed to compress log %s\n", name); + close(inFile); ++ unlink(compressedName); + return 1; + } + +@@ -805,6 +806,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb, + saveLog, strerror(errno)); + close(fdcurr); + close(fdsave); ++ unlink(saveLog); + return 1; + } + } +@@ -813,6 +815,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb, + currLog, strerror(errno)); + close(fdcurr); + close(fdsave); ++ unlink(saveLog); + return 1; + } + } +-- +2.14.4 + diff --git a/SPECS/logrotate.spec b/SPECS/logrotate.spec index c22af07..1c61f5d 100644 --- a/SPECS/logrotate.spec +++ b/SPECS/logrotate.spec @@ -1,7 +1,7 @@ Summary: Rotates, compresses, removes and mails system log files Name: logrotate Version: 3.8.6 -Release: 15%{?dist} +Release: 17%{?dist} License: GPL+ Group: System Environment/Base URL: https://github.com/logrotate/logrotate @@ -48,6 +48,12 @@ Patch17: logrotate-3.8.6-config-mode-err.patch # fix #1483800 - update references to project page Patch18: logrotate-3.8.6-upstream-url.patch +# fix #1556993 - premature monthly rotation due to DST switch +Patch19: logrotate-3.8.6-monthly-dst.patch + +# fix #1374550 - unlink destination file when rotation fails +Patch20: logrotate-3.8.6-unlink-on-failure.patch + Requires: coreutils >= 5.92 popt BuildRequires: libselinux-devel popt-devel libacl-devel acl BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -84,6 +90,8 @@ log files on your system. %patch16 -p1 %patch17 -p1 %patch18 -p1 +%patch19 -p1 +%patch20 -p1 %build make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes WITH_ACL=yes @@ -132,6 +140,12 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) %{_sysconfdir}/rwtab.d/logrotate %changelog +* Fri Jun 15 2018 Kamil Dudka - 3.8.6-17 +- fix #1374550 - unlink destination file when rotation fails + +* Tue Mar 20 2018 Kamil Dudka - 3.8.6-16 +- fix #1556993 - premature monthly rotation due to DST switch + * Mon Sep 25 2017 Kamil Dudka - 3.8.6-15 - fix #1483800 - update references to project page - fix #1472984 - improve the error message for bad config file mode