Blame SOURCES/logrotate-3.8.6-unlink-on-failure.patch

9b6d9a
From 733a43731739ecf2b8b405eab6868e7912d779a9 Mon Sep 17 00:00:00 2001
9b6d9a
From: Jan Kaluza <jkaluza@redhat.com>
9b6d9a
Date: Mon, 25 Jan 2016 11:04:05 +0100
9b6d9a
Subject: [PATCH] Remove half-rotated files when rotation of particular log
9b6d9a
 file is skipped because of an error during copy or compression.
9b6d9a
9b6d9a
Upstream-commit: e349752ccbbfa9ae8480ca504ded3af87e718298
9b6d9a
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
9b6d9a
---
9b6d9a
 logrotate.c | 3 +++
9b6d9a
 1 file changed, 3 insertions(+)
9b6d9a
9b6d9a
diff --git a/logrotate.c b/logrotate.c
9b6d9a
index fabfde9..f13d140 100644
9b6d9a
--- a/logrotate.c
9b6d9a
+++ b/logrotate.c
9b6d9a
@@ -633,6 +633,7 @@ static int compressLogFile(char *name, struct logInfo *log, struct stat *sb)
9b6d9a
     if (!WIFEXITED(status) || WEXITSTATUS(status)) {
9b6d9a
 	message(MESS_ERROR, "failed to compress log %s\n", name);
9b6d9a
 	close(inFile);
9b6d9a
+	unlink(compressedName);
9b6d9a
 	return 1;
9b6d9a
     }
9b6d9a
 
9b6d9a
@@ -805,6 +806,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
9b6d9a
 			saveLog, strerror(errno));
9b6d9a
 		close(fdcurr);
9b6d9a
 		close(fdsave);
9b6d9a
+		unlink(saveLog);
9b6d9a
 		return 1;
9b6d9a
 	    }
9b6d9a
 	}
9b6d9a
@@ -813,6 +815,7 @@ static int copyTruncate(char *currLog, char *saveLog, struct stat *sb,
9b6d9a
 		    currLog, strerror(errno));
9b6d9a
 	    close(fdcurr);
9b6d9a
 	    close(fdsave);
9b6d9a
+	    unlink(saveLog);
9b6d9a
 	    return 1;
9b6d9a
 	}
9b6d9a
     }
9b6d9a
-- 
9b6d9a
2.14.4
9b6d9a