|
|
6e9866 |
From 71c2315b76ef0d5408bfa37c31ad1b5a27e2b3e7 Mon Sep 17 00:00:00 2001
|
|
|
6e9866 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
Date: Wed, 7 Dec 2016 10:39:55 +0100
|
|
|
6e9866 |
Subject: [PATCH 1/4] config.c: skip a duplicated log entry but continue
|
|
|
6e9866 |
reading
|
|
|
6e9866 |
|
|
|
6e9866 |
... other entries which are not duplicated.
|
|
|
6e9866 |
|
|
|
6e9866 |
Closes #81
|
|
|
6e9866 |
|
|
|
6e9866 |
Upstream-commit: 06ede862d319efc98942536cba11bdfdbdc9cc72
|
|
|
6e9866 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
---
|
|
|
6e9866 |
config.c | 4 ++--
|
|
|
6e9866 |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
6e9866 |
|
|
|
6e9866 |
diff --git a/config.c b/config.c
|
|
|
6e9866 |
index 2a610de..aaf4fbb 100644
|
|
|
6e9866 |
--- a/config.c
|
|
|
6e9866 |
+++ b/config.c
|
|
|
6e9866 |
@@ -1389,7 +1389,7 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
|
|
|
6e9866 |
|
|
|
6e9866 |
newlog->files = NULL;
|
|
|
6e9866 |
newlog->numFiles = 0;
|
|
|
6e9866 |
- for (argNum = 0; argNum < argc && logerror != 1; argNum++) {
|
|
|
6e9866 |
+ for (argNum = 0; argNum < argc; argNum++) {
|
|
|
6e9866 |
if (globerr_msg) {
|
|
|
6e9866 |
free(globerr_msg);
|
|
|
6e9866 |
globerr_msg = NULL;
|
|
|
6e9866 |
@@ -1672,7 +1672,7 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
|
|
|
6e9866 |
|
|
|
6e9866 |
munmap(buf, (size_t) length);
|
|
|
6e9866 |
close(fd);
|
|
|
6e9866 |
- return 0;
|
|
|
6e9866 |
+ return logerror;
|
|
|
6e9866 |
error:
|
|
|
6e9866 |
if (key)
|
|
|
6e9866 |
free(key);
|
|
|
6e9866 |
--
|
|
|
6e9866 |
2.20.1
|
|
|
6e9866 |
|
|
|
6e9866 |
|
|
|
6e9866 |
From 9915dc4c4bf84b1ff16f34d7d34178098a03cf7c Mon Sep 17 00:00:00 2001
|
|
|
6e9866 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
Date: Mon, 2 Jan 2017 20:35:17 +0100
|
|
|
6e9866 |
Subject: [PATCH 2/4] config.c: recover from failures of readConfigFile()
|
|
|
6e9866 |
|
|
|
6e9866 |
Closes #81
|
|
|
6e9866 |
|
|
|
6e9866 |
Upstream-commit: 56598fd1e9338b45ba3e1bda1b91522e75b40e06
|
|
|
6e9866 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
---
|
|
|
6e9866 |
config.c | 30 ++++++++++++++----------------
|
|
|
6e9866 |
1 file changed, 14 insertions(+), 16 deletions(-)
|
|
|
6e9866 |
|
|
|
6e9866 |
diff --git a/config.c b/config.c
|
|
|
6e9866 |
index aaf4fbb..203b3e3 100644
|
|
|
6e9866 |
--- a/config.c
|
|
|
6e9866 |
+++ b/config.c
|
|
|
6e9866 |
@@ -510,8 +510,8 @@ static void freeTailLogs(int num)
|
|
|
6e9866 |
static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
{
|
|
|
6e9866 |
struct stat sb;
|
|
|
6e9866 |
- int here, oldnumlogs, result = 1;
|
|
|
6e9866 |
- struct logInfo defConfigBackup;
|
|
|
6e9866 |
+ int here, result = 1;
|
|
|
6e9866 |
+ struct logInfo defConfigBackup;
|
|
|
6e9866 |
|
|
|
6e9866 |
if (stat(path, &sb)) {
|
|
|
6e9866 |
message(MESS_ERROR, "cannot stat %s: %s\n", path, strerror(errno));
|
|
|
6e9866 |
@@ -588,11 +588,9 @@ static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
|
|
|
6e9866 |
for (i = 0; i < files_count; ++i) {
|
|
|
6e9866 |
assert(namelist[i] != NULL);
|
|
|
6e9866 |
- oldnumlogs = numLogs;
|
|
|
6e9866 |
copyLogInfo(&defConfigBackup, defConfig);
|
|
|
6e9866 |
if (readConfigFile(namelist[i], defConfig)) {
|
|
|
6e9866 |
message(MESS_ERROR, "found error in file %s, skipping\n", namelist[i]);
|
|
|
6e9866 |
- freeTailLogs(numLogs - oldnumlogs);
|
|
|
6e9866 |
freeLogInfo(defConfig);
|
|
|
6e9866 |
copyLogInfo(defConfig, &defConfigBackup);
|
|
|
6e9866 |
freeLogInfo(&defConfigBackup);
|
|
|
6e9866 |
@@ -609,10 +607,8 @@ static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
close(here);
|
|
|
6e9866 |
free_2d_array(namelist, files_count);
|
|
|
6e9866 |
} else {
|
|
|
6e9866 |
- oldnumlogs = numLogs;
|
|
|
6e9866 |
copyLogInfo(&defConfigBackup, defConfig);
|
|
|
6e9866 |
if (readConfigFile(path, defConfig)) {
|
|
|
6e9866 |
- freeTailLogs(numLogs - oldnumlogs);
|
|
|
6e9866 |
freeLogInfo(defConfig);
|
|
|
6e9866 |
copyLogInfo(defConfig, &defConfigBackup);
|
|
|
6e9866 |
} else {
|
|
|
6e9866 |
@@ -678,10 +674,8 @@ int readAllConfigPaths(const char **paths)
|
|
|
6e9866 |
}
|
|
|
6e9866 |
|
|
|
6e9866 |
for (file = paths; *file; file++) {
|
|
|
6e9866 |
- if (readConfigPath(*file, &defConfig)) {
|
|
|
6e9866 |
+ if (readConfigPath(*file, &defConfig))
|
|
|
6e9866 |
result = 1;
|
|
|
6e9866 |
- break;
|
|
|
6e9866 |
- }
|
|
|
6e9866 |
}
|
|
|
6e9866 |
free_2d_array(tabooExts, tabooCount);
|
|
|
6e9866 |
freeLogInfo(&defConfig);
|
|
|
6e9866 |
@@ -1207,17 +1201,21 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
|
|
|
6e9866 |
&buf, length)) != NULL) {
|
|
|
6e9866 |
|
|
|
6e9866 |
message(MESS_DEBUG, "including %s\n", key);
|
|
|
6e9866 |
- if (++recursion_depth > MAX_NESTING) {
|
|
|
6e9866 |
+ if (recursion_depth >= MAX_NESTING) {
|
|
|
6e9866 |
message(MESS_ERROR, "%s:%d include nesting too deep\n",
|
|
|
6e9866 |
configFile, lineNum);
|
|
|
6e9866 |
- --recursion_depth;
|
|
|
6e9866 |
- goto error;
|
|
|
6e9866 |
- }
|
|
|
6e9866 |
- if (readConfigPath(key, newlog)) {
|
|
|
6e9866 |
- --recursion_depth;
|
|
|
6e9866 |
- goto error;
|
|
|
6e9866 |
+ logerror = 1;
|
|
|
6e9866 |
+ continue;
|
|
|
6e9866 |
}
|
|
|
6e9866 |
+
|
|
|
6e9866 |
+ ++recursion_depth;
|
|
|
6e9866 |
+ rv = readConfigPath(key, newlog);
|
|
|
6e9866 |
--recursion_depth;
|
|
|
6e9866 |
+
|
|
|
6e9866 |
+ if (rv) {
|
|
|
6e9866 |
+ logerror = 1;
|
|
|
6e9866 |
+ continue;
|
|
|
6e9866 |
+ }
|
|
|
6e9866 |
}
|
|
|
6e9866 |
else continue;
|
|
|
6e9866 |
} else if (!strcmp(key, "olddir")) {
|
|
|
6e9866 |
--
|
|
|
6e9866 |
2.20.1
|
|
|
6e9866 |
|
|
|
6e9866 |
|
|
|
6e9866 |
From ed099a0321e799d4be72f9096532bb976680aad8 Mon Sep 17 00:00:00 2001
|
|
|
6e9866 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
Date: Thu, 12 Jan 2017 08:44:39 +0100
|
|
|
6e9866 |
Subject: [PATCH 3/4] config.c: propagate errors from readConfigFile() properly
|
|
|
6e9866 |
|
|
|
6e9866 |
Closes #81
|
|
|
6e9866 |
|
|
|
6e9866 |
Upstream-commit: 6a75cdeab61a29ea99d49a85461f597c1d8d055c
|
|
|
6e9866 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
---
|
|
|
6e9866 |
config.c | 8 +++-----
|
|
|
6e9866 |
1 file changed, 3 insertions(+), 5 deletions(-)
|
|
|
6e9866 |
|
|
|
6e9866 |
diff --git a/config.c b/config.c
|
|
|
6e9866 |
index 203b3e3..72981b0 100644
|
|
|
6e9866 |
--- a/config.c
|
|
|
6e9866 |
+++ b/config.c
|
|
|
6e9866 |
@@ -510,7 +510,7 @@ static void freeTailLogs(int num)
|
|
|
6e9866 |
static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
{
|
|
|
6e9866 |
struct stat sb;
|
|
|
6e9866 |
- int here, result = 1;
|
|
|
6e9866 |
+ int here, result = 0;
|
|
|
6e9866 |
struct logInfo defConfigBackup;
|
|
|
6e9866 |
|
|
|
6e9866 |
if (stat(path, &sb)) {
|
|
|
6e9866 |
@@ -594,9 +594,8 @@ static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
freeLogInfo(defConfig);
|
|
|
6e9866 |
copyLogInfo(defConfig, &defConfigBackup);
|
|
|
6e9866 |
freeLogInfo(&defConfigBackup);
|
|
|
6e9866 |
+ result = 1;
|
|
|
6e9866 |
continue;
|
|
|
6e9866 |
- } else {
|
|
|
6e9866 |
- result = 0;
|
|
|
6e9866 |
}
|
|
|
6e9866 |
freeLogInfo(&defConfigBackup);
|
|
|
6e9866 |
}
|
|
|
6e9866 |
@@ -611,8 +610,7 @@ static int readConfigPath(const char *path, struct logInfo *defConfig)
|
|
|
6e9866 |
if (readConfigFile(path, defConfig)) {
|
|
|
6e9866 |
freeLogInfo(defConfig);
|
|
|
6e9866 |
copyLogInfo(defConfig, &defConfigBackup);
|
|
|
6e9866 |
- } else {
|
|
|
6e9866 |
- result = 0;
|
|
|
6e9866 |
+ result = 1;
|
|
|
6e9866 |
}
|
|
|
6e9866 |
freeLogInfo(&defConfigBackup);
|
|
|
6e9866 |
}
|
|
|
6e9866 |
--
|
|
|
6e9866 |
2.20.1
|
|
|
6e9866 |
|
|
|
6e9866 |
|
|
|
6e9866 |
From 58f8efbfde9d0ff2d8fbb0cef30ed842928835cd Mon Sep 17 00:00:00 2001
|
|
|
6e9866 |
From: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
Date: Thu, 12 Jan 2017 08:50:55 +0100
|
|
|
6e9866 |
Subject: [PATCH 4/4] do not treat errors in reading configuration as fatal
|
|
|
6e9866 |
|
|
|
6e9866 |
Closes #81
|
|
|
6e9866 |
|
|
|
6e9866 |
Upstream-commit: 74b788f790990d5958314df5f908a6fc5eaeccdd
|
|
|
6e9866 |
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
|
6e9866 |
---
|
|
|
6e9866 |
logrotate.c | 8 +++-----
|
|
|
6e9866 |
1 file changed, 3 insertions(+), 5 deletions(-)
|
|
|
6e9866 |
|
|
|
6e9866 |
diff --git a/logrotate.c b/logrotate.c
|
|
|
6e9866 |
index 976210e..459e01e 100644
|
|
|
6e9866 |
--- a/logrotate.c
|
|
|
6e9866 |
+++ b/logrotate.c
|
|
|
6e9866 |
@@ -2417,12 +2417,10 @@ int main(int argc, const char **argv)
|
|
|
6e9866 |
selinux_enforce = security_getenforce();
|
|
|
6e9866 |
#endif
|
|
|
6e9866 |
|
|
|
6e9866 |
- TAILQ_INIT(&logs);
|
|
|
6e9866 |
+ TAILQ_INIT(&logs);
|
|
|
6e9866 |
|
|
|
6e9866 |
- if (readAllConfigPaths(files)) {
|
|
|
6e9866 |
- poptFreeContext(optCon);
|
|
|
6e9866 |
- exit(1);
|
|
|
6e9866 |
- }
|
|
|
6e9866 |
+ if (readAllConfigPaths(files))
|
|
|
6e9866 |
+ rc = 1;
|
|
|
6e9866 |
|
|
|
6e9866 |
poptFreeContext(optCon);
|
|
|
6e9866 |
nowSecs = time(NULL);
|
|
|
6e9866 |
--
|
|
|
6e9866 |
2.20.1
|
|
|
6e9866 |
|