2008-09-06 00:08:20 +02:00
|
|
|
--- ./config.c.orig 2008-09-02 17:28:52.000000000 +0200
|
|
|
|
+++ ./config.c 2008-09-02 17:29:59.000000000 +0200
|
|
|
|
@@ -434,6 +434,7 @@ int readAllConfigPaths(const char **path
|
2007-01-16 00:24:09 +01:00
|
|
|
/* first, last */ NULL, NULL,
|
|
|
|
/* logAddress */ NULL,
|
|
|
|
/* extension */ NULL,
|
|
|
|
+ /* addextension */ NULL,
|
|
|
|
/* compress_prog */ NULL,
|
|
|
|
/* uncompress_prog */ NULL,
|
|
|
|
/* compress_ext */ NULL,
|
2008-09-06 00:08:20 +02:00
|
|
|
@@ -1151,6 +1152,24 @@ static int readConfigFile(const char *co
|
2007-01-16 00:24:09 +01:00
|
|
|
message(MESS_DEBUG, "extension is now %s\n",
|
|
|
|
newlog->extension);
|
|
|
|
|
|
|
|
+ } else if (!strcmp(start, "addextension")) {
|
|
|
|
+ *endtag = oldchar, start = endtag;
|
|
|
|
+
|
2008-09-06 00:08:20 +02:00
|
|
|
+ freeLogItem (addextension);
|
|
|
|
+
|
2007-01-16 00:24:09 +01:00
|
|
|
+ if (!isolateValue
|
|
|
|
+ (configFile, lineNum, "addextension name", &start,
|
|
|
|
+ &endtag)) {
|
|
|
|
+ oldchar = *endtag, *endtag = '\0';
|
|
|
|
+
|
|
|
|
+ newlog->addextension = strdup(start);
|
|
|
|
+
|
|
|
|
+ *endtag = oldchar, start = endtag;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ message(MESS_DEBUG, "addextension is now %s\n",
|
|
|
|
+ newlog->addextension);
|
|
|
|
+
|
|
|
|
} else if (!strcmp(start, "compresscmd")) {
|
|
|
|
*endtag = oldchar, start = endtag;
|
2008-09-06 00:08:20 +02:00
|
|
|
|
|
|
|
--- ./logrotate.h.orig 2008-09-02 17:28:52.000000000 +0200
|
|
|
|
+++ ./logrotate.h 2008-09-02 17:29:59.000000000 +0200
|
|
|
|
@@ -41,6 +41,7 @@ struct logInfo {
|
|
|
|
char *pre, *post, *first, *last;
|
|
|
|
char *logAddress;
|
|
|
|
char *extension;
|
|
|
|
+ char *addextension;
|
|
|
|
char *compress_prog;
|
|
|
|
char *uncompress_prog;
|
|
|
|
char *compress_ext;
|
|
|
|
--- ./logrotate.8.orig 2008-09-02 17:28:52.000000000 +0200
|
|
|
|
+++ ./logrotate.8 2008-09-02 17:29:59.000000000 +0200
|
|
|
|
@@ -142,6 +142,15 @@ Here is more information on the directiv
|
2007-01-16 00:24:09 +01:00
|
|
|
a \fBlogrotate\fR configuration file:
|
|
|
|
|
|
|
|
.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
|
|
|
|
\fBcompress\fR
|
|
|
|
Old versions of log files are compressed with \fBgzip\fR by default. See also
|
|
|
|
\fBnocompress\fR.
|
2008-09-06 00:08:20 +02:00
|
|
|
--- ./logrotate.c.orig 2008-09-02 17:28:52.000000000 +0200
|
|
|
|
+++ ./logrotate.c 2008-09-02 17:29:59.000000000 +0200
|
|
|
|
@@ -618,6 +618,24 @@ int prerotateSingleLog(struct logInfo *l
|
2007-01-16 00:24:09 +01:00
|
|
|
|
|
|
|
rotNames->baseName = strdup(ourBaseName(log->files[logNum]));
|
|
|
|
|
|
|
|
+ if (log->addextension) {
|
2008-09-06 00:08:20 +02:00
|
|
|
+ size_t baseLen = strlen(rotNames->baseName);
|
2007-01-16 00:24:09 +01:00
|
|
|
+ size_t extLen = strlen(log->addextension);
|
|
|
|
+ if (baseLen >= extLen &&
|
|
|
|
+ strncmp(&(rotNames->baseName[baseLen - extLen]),
|
2008-09-06 00:08:20 +02:00
|
|
|
+ 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;
|
2007-01-16 00:24:09 +01:00
|
|
|
+ } else {
|
|
|
|
+ fileext = log->addextension;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2008-09-06 00:08:20 +02:00
|
|
|
oldName = alloca(PATH_MAX);
|
|
|
|
newName = alloca(PATH_MAX);
|
|
|
|
rotNames->disposeName = malloc(PATH_MAX);
|
|
|
|
--- test/test.orig 2008-09-03 10:25:58.000000000 +0200
|
|
|
|
+++ test/test 2008-09-03 10:27:06.000000000 +0200
|
|
|
|
@@ -369,4 +369,27 @@
|
|
|
|
EOF
|
2007-01-16 00:24:09 +01:00
|
|
|
|
|
|
|
rm -rf testdir
|
2008-09-06 00:08:20 +02:00
|
|
|
+
|
2007-01-16 00:24:09 +01:00
|
|
|
+# check rotation with extension appended to the filename
|
2008-09-06 00:08:20 +02:00
|
|
|
+cleanup 15
|
2007-01-16 00:24:09 +01:00
|
|
|
+
|
2008-09-06 00:08:20 +02:00
|
|
|
+preptest test.log 15 1 0
|
|
|
|
+$RLR test-config.15 --force
|
2007-01-16 00:24:09 +01:00
|
|
|
+
|
|
|
|
+checkoutput <<EOF
|
|
|
|
+test.log 0
|
|
|
|
+test.log.1.newext 0 zero
|
|
|
|
+EOF
|
|
|
|
+
|
|
|
|
+# check rotation with extension moved after the number
|
2008-09-06 00:08:20 +02:00
|
|
|
+cleanup 16
|
2007-01-16 00:24:09 +01:00
|
|
|
+
|
2008-09-06 00:08:20 +02:00
|
|
|
+preptest test.log 16 1 0
|
|
|
|
+$RLR test-config.16 --force
|
2007-01-16 00:24:09 +01:00
|
|
|
+
|
|
|
|
+checkoutput <<EOF
|
|
|
|
+test.log 0
|
|
|
|
+test.1.log 0 zero
|
|
|
|
+EOF
|
|
|
|
+
|
|
|
|
cleanup
|
2008-09-06 00:08:20 +02:00
|
|
|
--- test/test-config.16.in.orig 2008-09-03 10:27:59.000000000 +0200
|
|
|
|
+++ test/test-config.16.in 2008-09-03 10:28:23.000000000 +0200
|
|
|
|
@@ -0,0 +1,8 @@
|
2007-01-16 00:24:09 +01:00
|
|
|
+create
|
|
|
|
+
|
|
|
|
+&DIR&/test.log {
|
|
|
|
+ monthly
|
|
|
|
+ rotate 1
|
2008-09-06 00:08:20 +02:00
|
|
|
+ addextension .log
|
2007-01-16 00:24:09 +01:00
|
|
|
+}
|
2008-09-06 00:08:20 +02:00
|
|
|
+
|
|
|
|
--- test/test-config.15.in.orig 2008-09-03 10:27:59.000000000 +0200
|
|
|
|
+++ test/test-config.15.in 2008-09-03 10:28:23.000000000 +0200
|
|
|
|
@@ -0,0 +1,8 @@
|
2007-01-16 00:24:09 +01:00
|
|
|
+create
|
|
|
|
+
|
|
|
|
+&DIR&/test.log {
|
|
|
|
+ monthly
|
|
|
|
+ rotate 1
|
2008-09-06 00:08:20 +02:00
|
|
|
+ addextension .newext
|
2007-01-16 00:24:09 +01:00
|
|
|
+}
|
2008-09-06 00:08:20 +02:00
|
|
|
+
|