logrotate/logrotate-addextension.patch

150 lines
3.9 KiB
Diff
Raw Normal View History

Index: test/test
===================================================================
--- test/test.orig
+++ test/test
@@ -1599,4 +1599,27 @@ test.log 0
test.log.1 0 zero
EOF
+# check rotation with extension appended to the filename
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
+cleanup 100
+
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
+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
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
+cleanup 101
+
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
+preptest test.log 101 1 0
+$RLR test-config.101 --force
+
+checkoutput <<EOF
+test.log 0
+test.1.log 0 zero
+EOF
+
+
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
cleanup
Index: config.c
===================================================================
--- config.c.orig
+++ config.c
@@ -637,6 +637,7 @@ int readAllConfigPaths(const char **path
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
.preremove = NULL,
.logAddress = NULL,
.extension = NULL,
+ .addextension = NULL,
.compress_prog = NULL,
.uncompress_prog = NULL,
.compress_ext = NULL,
@@ -1220,6 +1221,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
@@ -283,6 +283,15 @@ configured to be run by cron daily. You
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
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
+++ logrotate.c
@@ -1216,6 +1216,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
@@ -54,6 +54,7 @@ struct logInfo {
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
char *pre, *post, *first, *last, *preremove;
char *logAddress;
char *extension;
+ char *addextension;
char *compress_prog;
char *uncompress_prog;
char *compress_ext;
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
Index: test/test-config.100.in
===================================================================
--- /dev/null
+++ test/test-config.100.in
@@ -0,0 +1,7 @@
+create
+
+&DIR&/test.log {
+ monthly
+ rotate 1
+ addextension .newext
+}
Accepting request 184333 from home:vitezslav_cizek:branches:Base:System - update to 3.8.5 * dropped logrotate-3.7.9-compressoptions.patch (upstream) * refreshed other patches Changelog: - Improved rotation during daylight saving time and between timezone changes. - Fixed ACL setting problem caused by ext3 erroneously reporting ENOSYS instead of ENOSUP. - Do not continue with rotation if state file is corrupted. - Make logrotate.status creation atomic. - Allow "hourly" rotation. See manpage for more information. - Use "/bin/echo" in tests. Fixes tests execution in Dash. - Do no try to parse config files bigger than 16MB. - Improved manpage consistency and formatting. - Fix race condition between acl_set_fd() and fchmod(). - Added --version command line option - Disable ACL tests if logrotate is not compiled WITH_ACL support or if ACLs are not supported by the system running tests - Disable SELinux tests if logrotate is not compiled WITH_SELINUX support or if SELinux is not supported by the system running tests - Fixed bug which prevented skipping particular log file config if the config contained errors. - Fixed skipping of configs containing firstaction/lastaction scripts with '}' character in case of error before these scripts. - Support also 'K' unit for *size directives. - Added preremove option to let admin to do something with the old logs before they are removed by logrotate. - Fixed possible loop in tabooext parsing. - Move code to set SELinux context before compressLogFile calls to create compressed log files with the proper context. OBS-URL: https://build.opensuse.org/request/show/184333 OBS-URL: https://build.opensuse.org/package/show/Base:System/logrotate?expand=0&rev=24
2013-07-25 17:40:16 +02:00
Index: test/test-config.101.in
===================================================================
--- /dev/null
+++ test/test-config.101.in
@@ -0,0 +1,7 @@
+create
+
+&DIR&/test.log {
+ monthly
+ rotate 1
+ addextension .log
+}