Blame SOURCES/logrotate-3.8.6-olddir-missingok.patch

d06a0e
From 1787a97828b512b4b15e618a26d0e508ec7a253b Mon Sep 17 00:00:00 2001
d06a0e
From: Jan Kaluza <jkaluza@redhat.com>
d06a0e
Date: Tue, 26 Jan 2016 12:43:21 +0100
d06a0e
Subject: [PATCH] Fix 'olddir' usage with wildcard in the middle of path in the
d06a0e
 pattern definition when the pattern did not match any log file.
d06a0e
d06a0e
Upstream-commit: 73493ec38c5e806fa66d8c3f13259775da6282d9
d06a0e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
d06a0e
---
d06a0e
 config.c               | 24 ++++++++++++++++++------
d06a0e
 test/test              | 21 +++++++++++++++++++++
d06a0e
 test/test-config.69.in | 10 ++++++++++
d06a0e
 3 files changed, 49 insertions(+), 6 deletions(-)
d06a0e
 create mode 100644 test/test-config.69.in
d06a0e
d06a0e
diff --git a/config.c b/config.c
d06a0e
index 926d388..493f3f7 100644
d06a0e
--- a/config.c
d06a0e
+++ b/config.c
d06a0e
@@ -1454,12 +1454,24 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
d06a0e
 					int rv;
d06a0e
 					dirName = ourDirName(newlog->files[i]);
d06a0e
 					if (stat(dirName, &sb2)) {
d06a0e
-						message(MESS_ERROR,
d06a0e
-							"%s:%d error verifying log file "
d06a0e
-							"path %s: %s\n", configFile, lineNum,
d06a0e
-							dirName, strerror(errno));
d06a0e
-						free(dirName);
d06a0e
-						goto error;
d06a0e
+						if (!(newlog->flags & LOG_FLAG_MISSINGOK)) {
d06a0e
+							message(MESS_ERROR,
d06a0e
+								"%s:%d error verifying log file "
d06a0e
+								"path %s: %s\n", configFile, lineNum,
d06a0e
+								dirName, strerror(errno));
d06a0e
+							free(dirName);
d06a0e
+							goto error;
d06a0e
+						}
d06a0e
+						else {
d06a0e
+							message(MESS_DEBUG,
d06a0e
+								"%s:%d verifying log file "
d06a0e
+								"path failed %s: %s, log is probably missing, "
d06a0e
+								"but missingok is set, so this is not an error.\n",
d06a0e
+								configFile, lineNum,
d06a0e
+								dirName, strerror(errno));
d06a0e
+							free(dirName);
d06a0e
+							continue;
d06a0e
+						}
d06a0e
 					}
d06a0e
 					ld = alloca(strlen(dirName) + strlen(newlog->oldDir) + 2);
d06a0e
 					sprintf(ld, "%s/%s", dirName, newlog->oldDir);
d06a0e
diff --git a/test/test b/test/test
d06a0e
index 9d7618f..54d57d2 100755
d06a0e
--- a/test/test
d06a0e
+++ b/test/test
d06a0e
@@ -1566,4 +1566,25 @@ test.log 0
d06a0e
 test.log.$DATESTRING 0 zero
d06a0e
 EOF
d06a0e
 
d06a0e
+cleanup 69
d06a0e
+
d06a0e
+# ------------------------------- Test 69 ------------------------------------
d06a0e
+# Test olddir with wildcard in the pattern
d06a0e
+preptest test.log 69 1 0
d06a0e
+rm -rf testdir adir bdir
d06a0e
+mkdir adir
d06a0e
+mkdir bdir
d06a0e
+cp test.log adir
d06a0e
+cp test.log bdir
d06a0e
+$RLR test-config.69 --force -v
d06a0e
+
d06a0e
+checkoutput <
d06a0e
+adir/test.log 0
d06a0e
+testdir/test.log.1 0 zero
d06a0e
+EOF
d06a0e
+
d06a0e
+rm -rf testdir adir
d06a0e
+rm -rf testdir bdir
d06a0e
+
d06a0e
 cleanup
d06a0e
+
d06a0e
diff --git a/test/test-config.69.in b/test/test-config.69.in
d06a0e
new file mode 100644
d06a0e
index 0000000..9752e0a
d06a0e
--- /dev/null
d06a0e
+++ b/test/test-config.69.in
d06a0e
@@ -0,0 +1,10 @@
d06a0e
+create
d06a0e
+
d06a0e
+&DIR&/*/test.log
d06a0e
+&DIR&/*/test.lo3 {
d06a0e
+    monthly
d06a0e
+    rotate 1
d06a0e
+    olddir &DIR&/testdir
d06a0e
+    createolddir 700 &USER& &GROUP&
d06a0e
+    missingok
d06a0e
+}
d06a0e
-- 
d06a0e
2.7.4
d06a0e