Index: test/test =================================================================== --- test/test.orig 2008-05-14 12:31:35.000000000 +0200 +++ test/test 2009-03-06 15:15:00.000000000 +0100 @@ -369,4 +369,27 @@ EOF rm -rf testdir + +# check rotation with extension appended to the filename +cleanup 15 + +preptest test.log 15 1 0 +$RLR test-config.15 --force + +checkoutput <extension); + } else if (!strcmp(start, "addextension")) { + *endtag = oldchar, start = endtag; + + freeLogItem (addextension); + + 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; Index: logrotate.8 =================================================================== --- logrotate.8.orig 2008-12-06 15:05:40.000000000 +0100 +++ logrotate.8 2009-03-06 15:15:00.000000000 +0100 @@ -144,6 +144,15 @@ 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(1) by default. See also \fBnocompress\fR. Index: logrotate.c =================================================================== --- logrotate.c.orig 2009-03-06 15:07:06.000000000 +0100 +++ logrotate.c 2009-03-06 15:15:00.000000000 +0100 @@ -671,6 +671,24 @@ 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; + } + } + oldName = alloca(PATH_MAX); newName = alloca(PATH_MAX); rotNames->disposeName = malloc(PATH_MAX); Index: logrotate.h =================================================================== --- logrotate.h.orig 2009-03-06 15:07:06.000000000 +0100 +++ logrotate.h 2009-03-06 15:15:00.000000000 +0100 @@ -41,6 +41,7 @@ char *pre, *post, *first, *last; char *logAddress; char *extension; + char *addextension; char *compress_prog; char *uncompress_prog; char *compress_ext;