Blame SOURCES/0003-logrotate-3.18.0-renamecopy-excl.patch

d9c745
From 337eb1492f8b694542d704c7a4612e3211f717e5 Mon Sep 17 00:00:00 2001
d9c745
From: Kamil Dudka <kdudka@redhat.com>
d9c745
Date: Tue, 27 Apr 2021 20:52:32 +0200
d9c745
Subject: [PATCH 2/2] make `renamecopy` and `copytruncate` override each other
d9c745
d9c745
These option cannot work together.  This rule prevents unnecessary
d9c745
rotation failure in case one of the options comes from the global
d9c745
configuration and the other one from log-specific configuration.
d9c745
d9c745
Bug: https://bugzilla.redhat.com/1934601
d9c745
d9c745
Closes: https://github.com/logrotate/logrotate/pull/386
d9c745
d9c745
Upstream-commit: fe53a0efd21c11dbe9705564f92f5d9aa6bf855e
d9c745
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d9c745
---
d9c745
 config.c               | 2 ++
d9c745
 logrotate.8.in         | 3 ++-
d9c745
 test/test-config.24.in | 3 +++
d9c745
 test/test-config.58.in | 3 +++
d9c745
 4 files changed, 10 insertions(+), 1 deletion(-)
d9c745
d9c745
diff --git a/config.c b/config.c
d9c745
index 91fd412..1bca9e4 100644
d9c745
--- a/config.c
d9c745
+++ b/config.c
d9c745
@@ -1106,10 +1106,12 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
d9c745
                         newlog->flags &= ~LOG_FLAG_SHAREDSCRIPTS;
d9c745
                     } else if (!strcmp(key, "copytruncate")) {
d9c745
                         newlog->flags |= LOG_FLAG_COPYTRUNCATE;
d9c745
+                        newlog->flags &= ~LOG_FLAG_TMPFILENAME;
d9c745
                     } else if (!strcmp(key, "nocopytruncate")) {
d9c745
                         newlog->flags &= ~LOG_FLAG_COPYTRUNCATE;
d9c745
                     } else if (!strcmp(key, "renamecopy")) {
d9c745
                         newlog->flags |= LOG_FLAG_TMPFILENAME;
d9c745
+                        newlog->flags &= ~LOG_FLAG_COPYTRUNCATE;
d9c745
                     } else if (!strcmp(key, "norenamecopy")) {
d9c745
                         newlog->flags &= ~LOG_FLAG_TMPFILENAME;
d9c745
                     } else if (!strcmp(key, "copy")) {
d9c745
diff --git a/logrotate.8.in b/logrotate.8.in
d9c745
index 8064d68..f0aa23f 100644
d9c745
--- a/logrotate.8.in
d9c745
+++ b/logrotate.8.in
d9c745
@@ -430,7 +430,7 @@ truncating it, so some logging data might be lost.
d9c745
 When this option is used, the \fBcreate\fR option will have no effect,
d9c745
 as the old log file stays in place.  The \fBcopytruncate\fR option allows
d9c745
 storing rotated log files on the different devices using \fBolddir\fR
d9c745
-directive.
d9c745
+directive.  The \fBcopytruncate\fR option implies \fBnorenamecopy\fR.
d9c745
 
d9c745
 .TP
d9c745
 \fBnocopytruncate\fR
d9c745
@@ -444,6 +444,7 @@ Log file is renamed to temporary filename in the same directory by adding
d9c745
 and log file is copied from temporary filename to final filename.  In the end,
d9c745
 temporary filename is removed.  The \fBrenamecopy\fR option allows storing
d9c745
 rotated log files on the different devices using \fBolddir\fR directive.
d9c745
+The \fBrenamecopy\fR option implies \fBnocopytruncate\fR.
d9c745
 
d9c745
 .TP
d9c745
 \fBnorenamecopy\fR
d9c745
diff --git a/test/test-config.24.in b/test/test-config.24.in
d9c745
index 35cfcd3..7a2a760 100644
d9c745
--- a/test/test-config.24.in
d9c745
+++ b/test/test-config.24.in
d9c745
@@ -1,5 +1,8 @@
d9c745
 create
d9c745
 
d9c745
+# will be overridden by copytruncate
d9c745
+renamecopy
d9c745
+
d9c745
 &DIR&/test*.log {
d9c745
     daily
d9c745
     copytruncate
d9c745
diff --git a/test/test-config.58.in b/test/test-config.58.in
d9c745
index 34906da..79058be 100644
d9c745
--- a/test/test-config.58.in
d9c745
+++ b/test/test-config.58.in
d9c745
@@ -1,5 +1,8 @@
d9c745
 create
d9c745
 
d9c745
+# will be overridden by renamecopy
d9c745
+copytruncate
d9c745
+
d9c745
 &DIR&/test.log {
d9c745
     renamecopy
d9c745
     weekly
d9c745
-- 
d9c745
2.30.2
d9c745