Blame SOURCES/logrotate-3.8.6-compress-subject.patch

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