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

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