2009-03-09 00:25:57 +01:00
|
|
|
Index: config.c
|
|
|
|
===================================================================
|
2013-07-25 17:40:16 +02:00
|
|
|
--- config.c.orig 2013-06-10 14:02:36.000000000 +0200
|
|
|
|
+++ config.c 2013-07-25 15:42:42.465060702 +0200
|
2015-02-20 13:18:45 +01:00
|
|
|
@@ -712,6 +712,7 @@
|
2011-09-13 11:24:51 +02:00
|
|
|
char **scriptDest = NULL;
|
|
|
|
struct logInfo *newlog = defConfig;
|
|
|
|
char *start, *chptr;
|
|
|
|
+ char *compresscmd_base;
|
|
|
|
char *dirName;
|
|
|
|
struct passwd *pw = NULL;
|
2015-02-20 13:18:45 +01:00
|
|
|
int rc;
|
2013-07-25 17:40:16 +02:00
|
|
|
@@ -1245,6 +1246,20 @@ static int readConfigFile(const char *co
|
2011-09-13 11:24:51 +02:00
|
|
|
message(MESS_DEBUG, "compress_prog is now %s\n",
|
|
|
|
newlog->compress_prog);
|
2007-01-16 00:24:09 +01:00
|
|
|
|
2011-09-13 11:24:51 +02:00
|
|
|
+ compresscmd_base=strdup(basename(newlog->compress_prog));
|
2013-07-25 17:40:16 +02:00
|
|
|
+ fprintf(stdout, "compress_ext is %s\n", newlog->compress_prog);
|
2011-09-13 11:24:51 +02:00
|
|
|
+ i=0; /* have to check whether we may do this! */
|
|
|
|
+ /* we check whether we changed the compress_cmd. In case we use the apropriate extension
|
|
|
|
+ as listed in compress_cmd_list */
|
|
|
|
+ while ((i>=0)&&(strcmp(compress_cmd_list[i][0], "EOLIST"))){
|
|
|
|
+ if (0==strcmp(compress_cmd_list[i][0], compresscmd_base)){
|
|
|
|
+ newlog->compress_ext=strdup((char *)compress_cmd_list[i][1]);
|
|
|
|
+ message(MESS_DEBUG, "compress_ext was changed to %s\n", newlog->compress_ext);
|
2013-07-25 17:40:16 +02:00
|
|
|
+ fprintf(stdout, "compress_ext was changed to %s\n", newlog->compress_ext);
|
2011-09-13 11:24:51 +02:00
|
|
|
+ i=-10; /* terminate loop! */
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
} else if (!strcmp(key, "uncompresscmd")) {
|
|
|
|
freeLogItem (uncompress_prog);
|
2007-01-16 00:24:09 +01:00
|
|
|
|
2009-03-09 00:25:57 +01:00
|
|
|
Index: logrotate.c
|
|
|
|
===================================================================
|
2013-07-25 17:40:16 +02:00
|
|
|
--- logrotate.c.orig 2013-06-10 14:02:36.000000000 +0200
|
|
|
|
+++ logrotate.c 2013-07-25 15:30:36.687434418 +0200
|
|
|
|
@@ -85,6 +85,16 @@ unsigned int hashSize;
|
2008-09-06 00:08:20 +02:00
|
|
|
int numLogs = 0;
|
2007-01-16 00:24:09 +01:00
|
|
|
int debug = 0;
|
|
|
|
char *mailCommand = DEFAULT_MAIL_COMMAND;
|
|
|
|
+/* This is the declaration. Note the "2" is needed in the definition (logrotate.h), too! */
|
|
|
|
+const char * compress_cmd_list[][2] = {
|
|
|
|
+ {"gzip", ".gz"},
|
|
|
|
+ {"bzip2", ".bz2"},
|
2011-08-12 21:00:30 +02:00
|
|
|
+ {"xz", ".xz"},
|
2007-01-16 00:24:09 +01:00
|
|
|
+ {"compress", ".Z"},
|
|
|
|
+ {"zip", "zip"},
|
|
|
|
+ {"EOLIST", "EOLIST"} /* end-marker */
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
time_t nowSecs = 0;
|
2011-09-13 11:24:51 +02:00
|
|
|
static uid_t save_euid;
|
|
|
|
static gid_t save_egid;
|
2009-03-09 00:25:57 +01:00
|
|
|
Index: logrotate.h
|
|
|
|
===================================================================
|
2013-07-25 17:40:16 +02:00
|
|
|
--- logrotate.h.orig 2013-06-10 14:02:36.000000000 +0200
|
|
|
|
+++ logrotate.h 2013-07-25 15:30:36.687434418 +0200
|
2011-09-13 11:24:51 +02:00
|
|
|
@@ -66,6 +66,9 @@ TAILQ_HEAD(logInfoHead, logInfo) logs;
|
2009-03-09 00:25:57 +01:00
|
|
|
extern int numLogs;
|
|
|
|
extern int debug;
|
|
|
|
|
|
|
|
+/* This is the definition. Note we have to carry the "2" within the declaration (logrotate.c), too! */
|
|
|
|
+extern const char * compress_cmd_list[][2];
|
|
|
|
+
|
|
|
|
int readAllConfigPaths(const char **paths);
|
2013-07-25 17:40:16 +02:00
|
|
|
#if !defined(asprintf) && !defined(_FORTIFY_SOURCE)
|
2011-09-13 11:24:51 +02:00
|
|
|
int asprintf(char **string_ptr, const char *format, ...);
|
2013-07-25 17:40:16 +02:00
|
|
|
Index: test/test
|
|
|
|
===================================================================
|
|
|
|
--- test/test.orig 2013-07-25 15:30:36.687434418 +0200
|
|
|
|
+++ test/test 2013-07-25 16:16:11.992044805 +0200
|
|
|
|
@@ -536,19 +536,6 @@ checkoutput <<EOF
|
|
|
|
test.log 0 zero
|
|
|
|
EOF
|
|
|
|
|
|
|
|
-cleanup 18
|
|
|
|
-
|
|
|
|
-# ------------------------------- Test 18 ------------------------------------
|
|
|
|
-preptest test.log 18 1
|
|
|
|
-$RLR test-config.18 --force
|
|
|
|
-
|
|
|
|
-checkoutput <<EOF
|
|
|
|
-test.log 0
|
|
|
|
-test.log.1.gz 1 zero
|
|
|
|
-EOF
|
|
|
|
-
|
|
|
|
-(echo "gzip -f -9") | diff -u - compress-args
|
|
|
|
-
|
|
|
|
cleanup 19
|
|
|
|
|
|
|
|
# ------------------------------- Test 19 ------------------------------------
|