Skip to content
Snippets Groups Projects
Commit 1a0bd966 authored by Kamil Dudka's avatar Kamil Dudka
Browse files

uncompress logs before mailing them

... even if delaycompress is enabled

Closes #151
parent 123557b3
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -879,20 +879,24 @@ static int mailLog(struct logInfo *log, char *logFile, const char *mailComm,
static int mailLogWrapper(char *mailFilename, const char *mailComm,
int logNum, struct logInfo *log)
{
/* if the log is compressed (and we're not mailing a
* file whose compression has been delayed), we need
* to uncompress it */
if ((log->flags & LOG_FLAG_COMPRESS) && !(log->flags & LOG_FLAG_DELAYCOMPRESS)) {
if (mailLog(log, mailFilename, mailComm,
log->uncompress_prog, log->logAddress,
(log->flags & LOG_FLAG_MAILFIRST) ? log->files[logNum] : mailFilename))
return 1;
} else {
if (mailLog(log, mailFilename, mailComm, NULL,
log->logAddress, mailFilename))
return 1;
}
return 0;
/* uncompress already compressed log files before mailing them */
char *uncompress_prog = (log->flags & LOG_FLAG_COMPRESS)
? log->uncompress_prog
: NULL;
char *subject = mailFilename;
if (log->flags & LOG_FLAG_MAILFIRST) {
if (log->flags & LOG_FLAG_DELAYCOMPRESS)
/* the log we are mailing has not been compressed yet */
uncompress_prog = NULL;
if (uncompress_prog)
/* use correct subject when mailfirst is enabled */
subject = log->files[logNum];
}
return mailLog(log, mailFilename, mailComm, uncompress_prog,
log->logAddress, subject);
}
 
/* Use a heuristic to determine whether stat buffer SB comes from a file
Loading
Loading
Loading
Loading
@@ -73,6 +73,7 @@ TEST_CASES = \
test-0072.sh \
test-0073.sh \
test-0074.sh \
test-0075.sh \
test-0100.sh \
test-0101.sh
 
Loading
Loading
#!/bin/bash
. ./test-common.sh
cleanup 75
# ------------------------------- Test 75 ------------------------------------
# uncompress logs before mailing them even if delaycompress is enabled
# https://github.com/logrotate/logrotate/issues/151
preptest test.log 75 2 1
$RLR test-config.75 --verbose
checkoutput <<EOF
test.log 0
test.log.1 0 zero
test.log.2.gz 1 first
EOF
checkmail test.log.3.gz second
&DIR&/test.log {
create
rotate 2
size 0
compress
delaycompress
mail user@invalid.
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment