6194b5c0cd
- update to 3.8.7, fix bnc#849436 - Changelog 3.8.7: * Fixed --force/-f option handling together with "size" directive (3.8.5 regression). * Use "logrotate_tmp_t" context for SELinux tests and if this context does not exist, skip SELinux related tests. - Changelog 3.8.6 * Fixed memory corruption caused by rotation directory which does not exist with "sharedscripts" together with "prerotate" script. OBS-URL: https://build.opensuse.org/request/show/206232 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=30
150 lines
4.4 KiB
Diff
150 lines
4.4 KiB
Diff
Index: test/test
|
|
===================================================================
|
|
--- test/test.orig 2013-10-10 10:43:36.000000000 +0200
|
|
+++ test/test 2013-11-07 21:46:37.112487860 +0100
|
|
@@ -1358,4 +1358,27 @@
|
|
test.log.1 0 zero
|
|
EOF
|
|
|
|
+# check rotation with extension appended to the filename
|
|
+cleanup 100
|
|
+
|
|
+preptest test.log 100 1 0
|
|
+$RLR test-config.100 --force
|
|
+
|
|
+checkoutput <<EOF
|
|
+test.log 0
|
|
+test.log.1.newext 0 zero
|
|
+EOF
|
|
+
|
|
+# check rotation with extension moved after the number
|
|
+cleanup 101
|
|
+
|
|
+preptest test.log 101 1 0
|
|
+$RLR test-config.101 --force
|
|
+
|
|
+checkoutput <<EOF
|
|
+test.log 0
|
|
+test.1.log 0 zero
|
|
+EOF
|
|
+
|
|
+
|
|
cleanup
|
|
Index: config.c
|
|
===================================================================
|
|
--- config.c.orig 2013-07-25 14:13:02.780567373 +0200
|
|
+++ config.c 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -530,6 +530,7 @@ int readAllConfigPaths(const char **path
|
|
.preremove = NULL,
|
|
.logAddress = NULL,
|
|
.extension = NULL,
|
|
+ .addextension = NULL,
|
|
.compress_prog = NULL,
|
|
.uncompress_prog = NULL,
|
|
.compress_ext = NULL,
|
|
@@ -1217,6 +1218,19 @@ static int readConfigFile(const char *co
|
|
message(MESS_DEBUG, "extension is now %s\n",
|
|
newlog->extension);
|
|
|
|
+ } else if (!strcmp(key, "addextension")) {
|
|
+ if ((key = isolateValue
|
|
+ (configFile, lineNum, "addextension name", &start,
|
|
+ &buf, length)) != NULL) {
|
|
+ freeLogItem (addextension);
|
|
+ newlog->addextension = key;
|
|
+ key = NULL;
|
|
+ }
|
|
+ else continue;
|
|
+
|
|
+ message(MESS_DEBUG, "addextension is now %s\n",
|
|
+ newlog->addextension);
|
|
+
|
|
} else if (!strcmp(key, "compresscmd")) {
|
|
freeLogItem (compress_prog);
|
|
|
|
Index: logrotate.8
|
|
===================================================================
|
|
--- logrotate.8.orig 2013-07-25 14:13:02.780567373 +0200
|
|
+++ logrotate.8 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -265,6 +265,15 @@ configured to be run by cron daily. You
|
|
and run \fIlogrotate\fR hourly to be able to really rotate logs hourly.
|
|
|
|
.TP
|
|
+\fBaddextension \fIext\fR
|
|
+Log files are given the final extension \fIext\fR after rotation. If
|
|
+the original file already ends with \fIext\fR, the extension is not
|
|
+duplicated, but merely moved to the end, i.e. both \fBfilename\fR and
|
|
+\fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If
|
|
+compression is used, the compression extension (normally \fB.gz\fR)
|
|
+appears after \fIext\fR.
|
|
+
|
|
+.TP
|
|
\fBifempty\fR
|
|
Rotate the log file even if it is empty, overriding the \fBnotifempty\fR
|
|
option (\fBifempty\fR is the default).
|
|
Index: logrotate.c
|
|
===================================================================
|
|
--- logrotate.c.orig 2013-07-25 14:13:02.781567384 +0200
|
|
+++ logrotate.c 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -964,6 +964,24 @@ int prerotateSingleLog(struct logInfo *l
|
|
|
|
rotNames->baseName = strdup(ourBaseName(log->files[logNum]));
|
|
|
|
+ if (log->addextension) {
|
|
+ size_t baseLen = strlen(rotNames->baseName);
|
|
+ size_t extLen = strlen(log->addextension);
|
|
+ if (baseLen >= extLen &&
|
|
+ strncmp(&(rotNames->baseName[baseLen - extLen]),
|
|
+ log->addextension, extLen) == 0) {
|
|
+ char *tempstr;
|
|
+
|
|
+ fileext = log->addextension;
|
|
+ tempstr = calloc(baseLen - extLen + 1, sizeof(char));
|
|
+ strncat(tempstr, rotNames->baseName, baseLen - extLen);
|
|
+ free(rotNames->baseName);
|
|
+ rotNames->baseName = tempstr;
|
|
+ } else {
|
|
+ fileext = log->addextension;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (log->extension &&
|
|
strncmp(&
|
|
(rotNames->
|
|
Index: logrotate.h
|
|
===================================================================
|
|
--- logrotate.h.orig 2013-07-25 14:13:02.781567384 +0200
|
|
+++ logrotate.h 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -44,6 +44,7 @@ struct logInfo {
|
|
char *pre, *post, *first, *last, *preremove;
|
|
char *logAddress;
|
|
char *extension;
|
|
+ char *addextension;
|
|
char *compress_prog;
|
|
char *uncompress_prog;
|
|
char *compress_ext;
|
|
Index: test/test-config.100.in
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ test/test-config.100.in 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -0,0 +1,7 @@
|
|
+create
|
|
+
|
|
+&DIR&/test.log {
|
|
+ monthly
|
|
+ rotate 1
|
|
+ addextension .newext
|
|
+}
|
|
Index: test/test-config.101.in
|
|
===================================================================
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
+++ test/test-config.101.in 2013-07-25 14:13:04.196582364 +0200
|
|
@@ -0,0 +1,7 @@
|
|
+create
|
|
+
|
|
+&DIR&/test.log {
|
|
+ monthly
|
|
+ rotate 1
|
|
+ addextension .log
|
|
+}
|