|
|
285127 |
diff --git a/logrotate.c b/logrotate.c
|
|
|
285127 |
index 4ef044e..9faf341 100644
|
|
|
285127 |
--- a/logrotate.c
|
|
|
285127 |
+++ b/logrotate.c
|
|
|
285127 |
@@ -662,22 +662,20 @@ static int mailLog(struct logInfo *log, char *logFile, char *mailCommand,
|
|
|
285127 |
static int mailLogWrapper(char *mailFilename, char *mailCommand,
|
|
|
285127 |
int logNum, struct logInfo *log)
|
|
|
285127 |
{
|
|
|
285127 |
- /* if the log is compressed (and we're not mailing a
|
|
|
285127 |
- * file whose compression has been delayed), we need
|
|
|
285127 |
- * to uncompress it */
|
|
|
285127 |
- if ((log->flags & LOG_FLAG_COMPRESS) &&
|
|
|
285127 |
- !((log->flags & LOG_FLAG_DELAYCOMPRESS) &&
|
|
|
285127 |
- (log->flags & LOG_FLAG_MAILFIRST))) {
|
|
|
285127 |
- if (mailLog(log, mailFilename, mailCommand,
|
|
|
285127 |
- log->uncompress_prog, log->logAddress,
|
|
|
285127 |
- log->files[logNum]))
|
|
|
285127 |
- return 1;
|
|
|
285127 |
- } else {
|
|
|
285127 |
- if (mailLog(log, mailFilename, mailCommand, NULL,
|
|
|
285127 |
- log->logAddress, mailFilename))
|
|
|
285127 |
- return 1;
|
|
|
285127 |
- }
|
|
|
285127 |
- return 0;
|
|
|
285127 |
+ /* if the log is compressed (and we're not mailing a
|
|
|
285127 |
+ * file whose compression has been delayed), we need
|
|
|
285127 |
+ * to uncompress it */
|
|
|
285127 |
+ if ((log->flags & LOG_FLAG_COMPRESS) && !(log->flags & LOG_FLAG_DELAYCOMPRESS)) {
|
|
|
285127 |
+ if (mailLog(log, mailFilename, mailCommand,
|
|
|
285127 |
+ log->uncompress_prog, log->logAddress,
|
|
|
285127 |
+ (log->flags & LOG_FLAG_MAILFIRST) ? log->files[logNum] : mailFilename))
|
|
|
285127 |
+ return 1;
|
|
|
285127 |
+ } else {
|
|
|
285127 |
+ if (mailLog(log, mailFilename, mailCommand, NULL,
|
|
|
285127 |
+ log->logAddress, mailFilename))
|
|
|
285127 |
+ return 1;
|
|
|
285127 |
+ }
|
|
|
285127 |
+ return 0;
|
|
|
285127 |
}
|
|
|
285127 |
|
|
|
285127 |
static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
|
|
|
285127 |
diff --git a/test/test b/test/test
|
|
|
285127 |
index e9ce46f..f7f3cf4 100755
|
|
|
285127 |
--- a/test/test
|
|
|
285127 |
+++ b/test/test
|
|
|
285127 |
@@ -132,6 +132,9 @@ createlogs() {
|
|
|
285127 |
|
|
|
285127 |
checkmail() {
|
|
|
285127 |
(echo -s $PWD/$1 user@myhost.org; echo $2) | diff -u - mail-out
|
|
|
285127 |
+ if [ $? != 0 ]; then
|
|
|
285127 |
+ exit 5
|
|
|
285127 |
+ fi
|
|
|
285127 |
}
|
|
|
285127 |
|
|
|
285127 |
checkoutput() {
|
|
|
285127 |
@@ -429,7 +432,7 @@ test.log 0
|
|
|
285127 |
scriptout 0 foo
|
|
|
285127 |
EOF
|
|
|
285127 |
|
|
|
285127 |
-checkmail test.log first
|
|
|
285127 |
+checkmail test.log.2.gz first
|
|
|
285127 |
|
|
|
285127 |
# check rotation into a directory given as a relative pathname
|
|
|
285127 |
cleanup 12
|
|
|
285127 |
@@ -1424,4 +1427,37 @@ fi
|
|
|
285127 |
|
|
|
285127 |
rm -f *test.log*
|
|
|
285127 |
|
|
|
285127 |
+cleanup 64
|
|
|
285127 |
+
|
|
|
285127 |
+# ------------------------------- Test 64 ------------------------------------
|
|
|
285127 |
+# filename in mail's subject with compress directive and maillast directive
|
|
|
285127 |
+# should be the name of the removed log
|
|
|
285127 |
+preptest test.log 64 1 0
|
|
|
285127 |
+
|
|
|
285127 |
+DATESTRING=$(/bin/date +%Y%m%d)
|
|
|
285127 |
+
|
|
|
285127 |
+$RLR test-config.64 --force
|
|
|
285127 |
+checkoutput <
|
|
|
285127 |
+test.log 0
|
|
|
285127 |
+EOF
|
|
|
285127 |
+
|
|
|
285127 |
+checkmail test.log-$DATESTRING.gz zero
|
|
|
285127 |
+
|
|
|
285127 |
+cleanup 65
|
|
|
285127 |
+
|
|
|
285127 |
+# ------------------------------- Test 65 ------------------------------------
|
|
|
285127 |
+# filename in mail's subject without compress directive and maillast directive
|
|
|
285127 |
+# should be the name of the removed log
|
|
|
285127 |
+preptest test.log 65 1 0
|
|
|
285127 |
+
|
|
|
285127 |
+DATESTRING=$(/bin/date +%Y%m%d)
|
|
|
285127 |
+
|
|
|
285127 |
+$RLR test-config.65 --force
|
|
|
285127 |
+checkoutput <
|
|
|
285127 |
+test.log 0
|
|
|
285127 |
+EOF
|
|
|
285127 |
+
|
|
|
285127 |
+checkmail test.log-$DATESTRING zero
|
|
|
285127 |
+
|
|
|
285127 |
+
|
|
|
285127 |
cleanup
|
|
|
285127 |
diff --git a/test/test-config.64.in b/test/test-config.64.in
|
|
|
285127 |
new file mode 100644
|
|
|
285127 |
index 0000000..c817734
|
|
|
285127 |
--- /dev/null
|
|
|
285127 |
+++ b/test/test-config.64.in
|
|
|
285127 |
@@ -0,0 +1,13 @@
|
|
|
285127 |
+create
|
|
|
285127 |
+
|
|
|
285127 |
+&DIR&/test.log {
|
|
|
285127 |
+ daily
|
|
|
285127 |
+ dateext
|
|
|
285127 |
+ dateformat -%Y%m%d
|
|
|
285127 |
+ rotate 0
|
|
|
285127 |
+ compress
|
|
|
285127 |
+ nosharedscripts
|
|
|
285127 |
+ dateext
|
|
|
285127 |
+ mail user@myhost.org
|
|
|
285127 |
+ maillast
|
|
|
285127 |
+}
|
|
|
285127 |
diff --git a/test/test-config.65.in b/test/test-config.65.in
|
|
|
285127 |
new file mode 100644
|
|
|
285127 |
index 0000000..19007f5
|
|
|
285127 |
--- /dev/null
|
|
|
285127 |
+++ b/test/test-config.65.in
|
|
|
285127 |
@@ -0,0 +1,12 @@
|
|
|
285127 |
+create
|
|
|
285127 |
+
|
|
|
285127 |
+&DIR&/test.log {
|
|
|
285127 |
+ daily
|
|
|
285127 |
+ dateext
|
|
|
285127 |
+ dateformat -%Y%m%d
|
|
|
285127 |
+ rotate 0
|
|
|
285127 |
+ nosharedscripts
|
|
|
285127 |
+ dateext
|
|
|
285127 |
+ mail user@myhost.org
|
|
|
285127 |
+ maillast
|
|
|
285127 |
+}
|