Skip to content

Commit fe53a0e

Browse files
committed
make renamecopy and copytruncate override each other
These option cannot work together. This rule prevents unnecessary rotation failure in case one of the options comes from the global configuration and the other one from log-specific configuration. Bug: https://bugzilla.redhat.com/1934601 Closes: #386
1 parent 6ac9fe5 commit fe53a0e

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,10 +1121,12 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
11211121
newlog->flags &= ~LOG_FLAG_SHAREDSCRIPTS;
11221122
} else if (!strcmp(key, "copytruncate")) {
11231123
newlog->flags |= LOG_FLAG_COPYTRUNCATE;
1124+
newlog->flags &= ~LOG_FLAG_TMPFILENAME;
11241125
} else if (!strcmp(key, "nocopytruncate")) {
11251126
newlog->flags &= ~LOG_FLAG_COPYTRUNCATE;
11261127
} else if (!strcmp(key, "renamecopy")) {
11271128
newlog->flags |= LOG_FLAG_TMPFILENAME;
1129+
newlog->flags &= ~LOG_FLAG_COPYTRUNCATE;
11281130
} else if (!strcmp(key, "norenamecopy")) {
11291131
newlog->flags &= ~LOG_FLAG_TMPFILENAME;
11301132
} else if (!strcmp(key, "copy")) {

logrotate.8.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ truncating it, so some logging data might be lost.
429429
When this option is used, the \fBcreate\fR option will have no effect,
430430
as the old log file stays in place. The \fBcopytruncate\fR option allows
431431
storing rotated log files on the different devices using \fBolddir\fR
432-
directive.
432+
directive. The \fBcopytruncate\fR option implies \fBnorenamecopy\fR.
433433

434434
.TP
435435
\fBnocopytruncate\fR
@@ -443,6 +443,7 @@ Log file is renamed to temporary filename in the same directory by adding
443443
and log file is copied from temporary filename to final filename. In the end,
444444
temporary filename is removed. The \fBrenamecopy\fR option allows storing
445445
rotated log files on the different devices using \fBolddir\fR directive.
446+
The \fBrenamecopy\fR option implies \fBnocopytruncate\fR.
446447

447448
.TP
448449
\fBnorenamecopy\fR

test/test-config.24.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
create
22

3+
# will be overridden by copytruncate
4+
renamecopy
5+
36
&DIR&/test*.log {
47
daily
58
copytruncate

test/test-config.58.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
create
22

3+
# will be overridden by renamecopy
4+
copytruncate
5+
36
&DIR&/test.log {
47
renamecopy
58
weekly

0 commit comments

Comments
 (0)