logrotate/logrotate-3.7.7-autoext.patch

70 lines
2.3 KiB
Diff
Raw Normal View History

--- ./config.c.orig 2008-05-09 09:28:59.000000000 +0200
+++ ./config.c 2008-08-22 16:21:35.000000000 +0200
@@ -485,7 +485,7 @@
static int readConfigFile(const char *configFile, struct logInfo *defConfig)
{
int fd;
- char *buf, *endtag;
+ char *buf, *endtag, *compresscmd_base;
char oldchar, foo;
off_t length;
int lineNum = 1;
@@ -1182,6 +1182,18 @@
message(MESS_DEBUG, "compress_prog is now %s\n",
newlog->compress_prog);
+ compresscmd_base=strdup(basename(newlog->compress_prog));
+ 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);
+ i=-10; /* terminate loop! */
+ }
+ i++;
+ }
} else if (!strcmp(start, "uncompresscmd")) {
*endtag = oldchar, start = endtag;
--- ./logrotate.h.orig 2008-05-09 09:28:59.000000000 +0200
+++ ./logrotate.h 2008-08-22 16:38:13.000000000 +0200
@@ -61,6 +61,9 @@
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);
#endif
--- ./logrotate.c.orig 2008-05-14 12:31:35.000000000 +0200
+++ ./logrotate.c 2008-08-22 16:21:35.000000000 +0200
@@ -51,6 +51,15 @@
int numLogs = 0;
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"},
+ {"compress", ".Z"},
+ {"zip", "zip"},
+ {"EOLIST", "EOLIST"} /* end-marker */
+};
+
time_t nowSecs = 0;
static int shred_file(char *filename, struct logInfo *log);
@@ -278,7 +287,7 @@
char *uncompressCommand, char *address, char *subject)
{
int mailInput;
- pid_t mailChild, uncompressChild;
+ pid_t mailChild, uncompressChild=(pid_t) 0;
int mailStatus, uncompressStatus;
int uncompressPipe[2];
char *mailArgv[] = { mailCommand, "-s", subject, address, NULL };