logrotate/logrotate-3.7.8-addextension.patch
Michal Vyskocil a7ebe2d3f3 Accepting request 81574 from home:vitezslav_cizek:branches:Base:System
- update to 3.8.1
- dropped CVE patches as they were merged to upstream
- changelog
  - fixed 1 memory leak in prerotateSingleLog
  - do not redirect logrotate errors to /dev/null in cron script
  - fixed "size" directive parsing
  - handle situation when acl_get_fd is supported, but acl_set_fd is not
  - added "maxsize" directive (see man page)
  - added "dateyesterday" option (see man page)
  - fixed crash when config file had exactly 4096*N bytes
  - added WITH_ACL make option to link against -lacl and preserve ACLs
    during rotation
  - added "su" option to define user/group for rotation. Logrotate now
    skips directories which are world writable or writable by group
    which is not "root" unless "su" directive is used.
  - fixed CVE-2011-1098: race condition by creation of new files
  - fixed possible shell injection when using "shred" directive (CVE-2011-1154)
  - fixed escaping of file names within 'write state' action (CVE-2011-1155)
  - better 'size' directive description
  - fixed possible buffer-overflow when reading config files

OBS-URL: https://build.opensuse.org/request/show/81574
OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=18
2011-09-13 09:24:51 +00:00

149 lines
3.9 KiB
Diff

Index: test/test
===================================================================
--- test/test.orig
+++ test/test
@@ -427,4 +427,26 @@ test.log 0
test.log.1 0 zero
EOF
+# check rotation with extension appended to the filename
+cleanup 17
+
+preptest test.log 17 1 0
+$RLR test-config.17 --force
+
+checkoutput <<EOF
+test.log 0
+test.log.1.newext 0 zero
+EOF
+
+# check rotation with extension moved after the number
+cleanup 18
+
+preptest test.log 18 1 0
+$RLR test-config.18 --force
+
+checkoutput <<EOF
+test.log 0
+test.1.log 0 zero
+EOF
+
# cleanup
Index: config.c
===================================================================
--- config.c.orig
+++ config.c
@@ -519,6 +519,7 @@ int readAllConfigPaths(const char **path
.last = NULL,
.logAddress = NULL,
.extension = NULL,
+ .addextension = NULL,
.compress_prog = NULL,
.uncompress_prog = NULL,
.compress_ext = NULL,
@@ -1177,6 +1178,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
+++ logrotate.8
@@ -248,6 +248,15 @@ appears after \fIext\fR. For example you
and want to rotate it to mylog.1.foo.gz instead of mylog.foo.1.gz.
.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
+++ logrotate.c
@@ -867,6 +867,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
+++ logrotate.h
@@ -44,6 +44,7 @@ struct logInfo {
char *pre, *post, *first, *last;
char *logAddress;
char *extension;
+ char *addextension;
char *compress_prog;
char *uncompress_prog;
char *compress_ext;
Index: test/test-config.17.in
===================================================================
--- /dev/null
+++ test/test-config.17.in
@@ -0,0 +1,7 @@
+create
+
+&DIR&/test.log {
+ monthly
+ rotate 1
+ addextension .newext
+}
Index: test/test-config.18.in
===================================================================
--- /dev/null
+++ test/test-config.18.in
@@ -0,0 +1,7 @@
+create
+
+&DIR&/test.log {
+ monthly
+ rotate 1
+ addextension .log
+}