do not rotate logs on prerotate failure
This commit is contained in:
parent
4ae79e42bd
commit
32fd2ff5f5
45
backport-do-not-rotate-old-logs-on-prerotate-failure.patch
Normal file
45
backport-do-not-rotate-old-logs-on-prerotate-failure.patch
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
From 5f24239f282b8c6291cf35ea5f871ed0ca6b2672 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
||||||
|
Date: Tue, 4 Apr 2023 17:49:06 +0200
|
||||||
|
Subject: [PATCH] do not rotate old logs on prerotate failure
|
||||||
|
|
||||||
|
Ensures old logs are preserved and not rotated out for logs with a
|
||||||
|
failing prerotate script.
|
||||||
|
|
||||||
|
Alternative to #502
|
||||||
|
---
|
||||||
|
logrotate.c | 14 ++++++++++----
|
||||||
|
1 files changed, 10 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/logrotate.c b/logrotate.c
|
||||||
|
index f44b3851..d3ccb447 100644
|
||||||
|
--- a/logrotate.c
|
||||||
|
+++ b/logrotate.c
|
||||||
|
@@ -2476,10 +2476,6 @@ static int rotateLogSet(const struct logInfo *log, int force)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
memset(rotNames[i], 0, sizeof(struct logNames));
|
||||||
|
-
|
||||||
|
- logHasErrors[i] |=
|
||||||
|
- prerotateSingleLog(log, i, state[i], rotNames[i]);
|
||||||
|
- hasErrors |= logHasErrors[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log->pre
|
||||||
|
@@ -2509,6 +2505,16 @@ static int rotateLogSet(const struct logInfo *log, int force)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ for (i = j;
|
||||||
|
+ ((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)
|
||||||
|
+ || (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {
|
||||||
|
+ if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))
|
||||||
|
+ || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) {
|
||||||
|
+ logHasErrors[i] |= prerotateSingleLog(log, i, state[i], rotNames[i]);
|
||||||
|
+ hasErrors |= logHasErrors[i];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
for (i = j;
|
||||||
|
((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)
|
||||||
|
|| (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {
|
||||||
@ -2,13 +2,15 @@
|
|||||||
|
|
||||||
Name: logrotate
|
Name: logrotate
|
||||||
Version: 3.20.1
|
Version: 3.20.1
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: simplify the administration of log files
|
Summary: simplify the administration of log files
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Url: https://github.com/logrotate/logrotate
|
Url: https://github.com/logrotate/logrotate
|
||||||
Source0: https://github.com/logrotate/logrotate/releases/download/%{version}/logrotate-%{version}.tar.xz
|
Source0: https://github.com/logrotate/logrotate/releases/download/%{version}/logrotate-%{version}.tar.xz
|
||||||
# lockState: do not print `error:` when exit code is unaffected
|
# lockState: do not print `error:` when exit code is unaffected
|
||||||
Patch0: 0001-logrotate-3.20.1-lock-state-msg.patch
|
Patch0: 0001-logrotate-3.20.1-lock-state-msg.patch
|
||||||
|
Patch6001: backport-do-not-rotate-old-logs-on-prerotate-failure.patch
|
||||||
|
|
||||||
BuildRequires: acl gcc automake libacl-devel libselinux-devel popt-devel
|
BuildRequires: acl gcc automake libacl-devel libselinux-devel popt-devel
|
||||||
Requires: coreutils
|
Requires: coreutils
|
||||||
|
|
||||||
@ -75,6 +77,9 @@ fi
|
|||||||
%{_mandir}/man5/logrotate.conf.5*
|
%{_mandir}/man5/logrotate.conf.5*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Jun 5 2023 hanhuihui <hanhuihui5@huawei.com> - 3.20.1-2
|
||||||
|
- do not rotate old logs on prerotate failure
|
||||||
|
|
||||||
* Fri Jun 10 2022 duyiwei <duyiwei@kylinos.cn> - 3.20.1-1
|
* Fri Jun 10 2022 duyiwei <duyiwei@kylinos.cn> - 3.20.1-1
|
||||||
- upgrade version to 3.20.1 and fix CVE-2022-1348
|
- upgrade version to 3.20.1 and fix CVE-2022-1348
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user