import CS logrotate-3.18.0-9.el9

This commit is contained in:
eabdullin 2025-03-11 07:43:37 +00:00
parent 691aface10
commit 5cfb3649a6
4 changed files with 328 additions and 1 deletions

View File

@ -0,0 +1,104 @@
From a272346b75de27b5c87ea60901ccd790c823ec52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Fri, 18 Dec 2020 15:09:35 +0100
Subject: [PATCH 1/3] Ensure the type for configuration flags is wide enough
On 32-bit platforms int might be only 16 bit wide. With the next added
flag this size will be exceeded.
(cherry picked from commit dcb05f64bf1d397e3fff8b4b2a2418a177bb9377)
---
configure.ac | 2 ++
logrotate.c | 2 +-
logrotate.h | 35 ++++++++++++++++++-----------------
3 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5229db0..9ffcb22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,8 @@ AC_STRUCT_ST_BLOCKS
AC_CANONICAL_HOST
+AC_TYPE_UINT32_T
+
dnl Use 64-bit file offsets on 32-bit systems (defines C macros if necessary)
AC_SYS_LARGEFILE
diff --git a/logrotate.c b/logrotate.c
index 43ff9ef..819aaed 100644
--- a/logrotate.c
+++ b/logrotate.c
@@ -1155,7 +1155,7 @@ static int sparse_copy(int src_fd, int dest_fd, const struct stat *sb,
}
static int copyTruncate(const char *currLog, const char *saveLog, const struct stat *sb,
- int flags, int skip_copy)
+ uint32_t flags, int skip_copy)
{
int rc = 1;
int fdcurr = -1, fdsave = -1;
diff --git a/logrotate.h b/logrotate.h
index 25b5851..0a086ae 100644
--- a/logrotate.h
+++ b/logrotate.h
@@ -1,6 +1,7 @@
#ifndef H_LOGROTATE
#define H_LOGROTATE
+#include <stdint.h>
#include <sys/types.h>
#include "queue.h"
#include <glob.h>
@@ -10,22 +11,22 @@
# include <libgen.h>
#endif
-#define LOG_FLAG_COMPRESS (1 << 0)
-#define LOG_FLAG_CREATE (1 << 1)
-#define LOG_FLAG_IFEMPTY (1 << 2)
-#define LOG_FLAG_DELAYCOMPRESS (1 << 3)
-#define LOG_FLAG_COPYTRUNCATE (1 << 4)
-#define LOG_FLAG_MISSINGOK (1 << 5)
-#define LOG_FLAG_MAILFIRST (1 << 6)
-#define LOG_FLAG_SHAREDSCRIPTS (1 << 7)
-#define LOG_FLAG_COPY (1 << 8)
-#define LOG_FLAG_DATEEXT (1 << 9)
-#define LOG_FLAG_SHRED (1 << 10)
-#define LOG_FLAG_SU (1 << 11)
-#define LOG_FLAG_DATEYESTERDAY (1 << 12)
-#define LOG_FLAG_OLDDIRCREATE (1 << 13)
-#define LOG_FLAG_TMPFILENAME (1 << 14)
-#define LOG_FLAG_DATEHOURAGO (1 << 15)
+#define LOG_FLAG_COMPRESS (1U << 0)
+#define LOG_FLAG_CREATE (1U << 1)
+#define LOG_FLAG_IFEMPTY (1U << 2)
+#define LOG_FLAG_DELAYCOMPRESS (1U << 3)
+#define LOG_FLAG_COPYTRUNCATE (1U << 4)
+#define LOG_FLAG_MISSINGOK (1U << 5)
+#define LOG_FLAG_MAILFIRST (1U << 6)
+#define LOG_FLAG_SHAREDSCRIPTS (1U << 7)
+#define LOG_FLAG_COPY (1U << 8)
+#define LOG_FLAG_DATEEXT (1U << 9)
+#define LOG_FLAG_SHRED (1U << 10)
+#define LOG_FLAG_SU (1U << 11)
+#define LOG_FLAG_DATEYESTERDAY (1U << 12)
+#define LOG_FLAG_OLDDIRCREATE (1U << 13)
+#define LOG_FLAG_TMPFILENAME (1U << 14)
+#define LOG_FLAG_DATEHOURAGO (1U << 15)
#define NO_MODE ((mode_t) -1)
#define NO_UID ((uid_t) -1)
@@ -70,7 +71,7 @@ struct logInfo {
char *uncompress_prog;
char *compress_ext;
char *dateformat; /* specify format for strftime (for dateext) */
- int flags;
+ uint32_t flags;
int shred_cycles; /* if !=0, pass -n shred_cycles to GNU shred */
mode_t createMode; /* if any/all of these are -1, we use the */
uid_t createUid; /* attributes from the log file just rotated */
--
2.47.1

View File

@ -0,0 +1,147 @@
From b92841ef7539cf51a5fbc1e18ec03981331e242e Mon Sep 17 00:00:00 2001
From: Falk Werner <falk.werner@gmx.net>
Date: Thu, 17 Nov 2022 18:20:22 +0100
Subject: [PATCH 2/3] config: introduce `ignoreduplicates` configuration
directive
... to allow duplicate file matches
Closes: https://github.com/logrotate/logrotate/pull/473
(cherry picked from commit 986f32af66db7248326ac647cd0b24b79da34b4d)
---
config.c | 39 ++++++++++++++++++++++++++-------------
logrotate.8.in | 4 ++++
logrotate.h | 33 +++++++++++++++++----------------
3 files changed, 47 insertions(+), 29 deletions(-)
diff --git a/config.c b/config.c
index c0fd4ff..e76fad0 100644
--- a/config.c
+++ b/config.c
@@ -1380,6 +1380,8 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
newlog->flags |= LOG_FLAG_MISSINGOK;
} else if (!strcmp(key, "nomissingok")) {
newlog->flags &= ~LOG_FLAG_MISSINGOK;
+ } else if (!strcmp(key, "ignoreduplicates")) {
+ newlog->flags |= LOG_FLAG_IGNOREDUPLICATES;
} else if (!strcmp(key, "prerotate")) {
freeLogItem (pre);
scriptStart = start;
@@ -1812,6 +1814,7 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
for (glob_count = 0; glob_count < globResult.gl_pathc; glob_count++) {
struct logInfo *log;
+ int add_file = 1;
/* if we glob directories we can get false matches */
if (!lstat(globResult.gl_pathv[glob_count], &sb) &&
@@ -1825,24 +1828,34 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
for (k = 0; k < log->numFiles; k++) {
if (!strcmp(log->files[k],
globResult.gl_pathv[glob_count])) {
- message(MESS_ERROR,
- "%s:%d duplicate log entry for %s\n",
- configFile, lineNum,
- globResult.gl_pathv[glob_count]);
- logerror = 1;
- goto duperror;
+ if (log->flags & LOG_FLAG_IGNOREDUPLICATES) {
+ add_file = 0;
+ message(MESS_DEBUG,
+ "%s:%d ignore duplicate log entry for %s\n",
+ configFile, lineNum,
+ globResult.gl_pathv[glob_count]);
+ } else {
+ message(MESS_ERROR,
+ "%s:%d duplicate log entry for %s\n",
+ configFile, lineNum,
+ globResult.gl_pathv[glob_count]);
+ logerror = 1;
+ goto duperror;
+ }
}
}
}
- newlog->files[newlog->numFiles] =
- strdup(globResult.gl_pathv[glob_count]);
- if (newlog->files[newlog->numFiles] == NULL) {
- message_OOM();
- logerror = 1;
- goto duperror;
+ if (add_file) {
+ newlog->files[newlog->numFiles] =
+ strdup(globResult.gl_pathv[glob_count]);
+ if (newlog->files[newlog->numFiles] == NULL) {
+ message_OOM();
+ logerror = 1;
+ goto duperror;
+ }
+ newlog->numFiles++;
}
- newlog->numFiles++;
}
duperror:
globfree(&globResult);
diff --git a/logrotate.8.in b/logrotate.8.in
index f0aa23f..e0a3ed8 100644
--- a/logrotate.8.in
+++ b/logrotate.8.in
@@ -299,6 +299,10 @@ message. See also \fBnomissingok\fR.
\fBnomissingok\fR
If a log file does not exist, issue an error. This is the default.
+.TP
+\fBignoreduplicates\fR
+Ignore any following matches of a log file.
+
.TP
\fBifempty\fR
Rotate the log file even if it is empty, overriding the \fBnotifempty\fR
diff --git a/logrotate.h b/logrotate.h
index 0a086ae..26e516b 100644
--- a/logrotate.h
+++ b/logrotate.h
@@ -11,22 +11,23 @@
# include <libgen.h>
#endif
-#define LOG_FLAG_COMPRESS (1U << 0)
-#define LOG_FLAG_CREATE (1U << 1)
-#define LOG_FLAG_IFEMPTY (1U << 2)
-#define LOG_FLAG_DELAYCOMPRESS (1U << 3)
-#define LOG_FLAG_COPYTRUNCATE (1U << 4)
-#define LOG_FLAG_MISSINGOK (1U << 5)
-#define LOG_FLAG_MAILFIRST (1U << 6)
-#define LOG_FLAG_SHAREDSCRIPTS (1U << 7)
-#define LOG_FLAG_COPY (1U << 8)
-#define LOG_FLAG_DATEEXT (1U << 9)
-#define LOG_FLAG_SHRED (1U << 10)
-#define LOG_FLAG_SU (1U << 11)
-#define LOG_FLAG_DATEYESTERDAY (1U << 12)
-#define LOG_FLAG_OLDDIRCREATE (1U << 13)
-#define LOG_FLAG_TMPFILENAME (1U << 14)
-#define LOG_FLAG_DATEHOURAGO (1U << 15)
+#define LOG_FLAG_COMPRESS (1U << 0)
+#define LOG_FLAG_CREATE (1U << 1)
+#define LOG_FLAG_IFEMPTY (1U << 2)
+#define LOG_FLAG_DELAYCOMPRESS (1U << 3)
+#define LOG_FLAG_COPYTRUNCATE (1U << 4)
+#define LOG_FLAG_MISSINGOK (1U << 5)
+#define LOG_FLAG_MAILFIRST (1U << 6)
+#define LOG_FLAG_SHAREDSCRIPTS (1U << 7)
+#define LOG_FLAG_COPY (1U << 8)
+#define LOG_FLAG_DATEEXT (1U << 9)
+#define LOG_FLAG_SHRED (1U << 10)
+#define LOG_FLAG_SU (1U << 11)
+#define LOG_FLAG_DATEYESTERDAY (1U << 12)
+#define LOG_FLAG_OLDDIRCREATE (1U << 13)
+#define LOG_FLAG_TMPFILENAME (1U << 14)
+#define LOG_FLAG_DATEHOURAGO (1U << 15)
+#define LOG_FLAG_IGNOREDUPLICATES (1U << 17)
#define NO_MODE ((mode_t) -1)
#define NO_UID ((uid_t) -1)
--
2.47.1

View File

@ -0,0 +1,68 @@
From be64b6f0e42610be2a2b252fe30bd1bf7bf5d021 Mon Sep 17 00:00:00 2001
From: Falk Werner <falk.werner@gmx.net>
Date: Fri, 25 Nov 2022 18:28:03 +0100
Subject: [PATCH 3/3] test-0107: cover the `ignoreduplicates` configuration
directive
Closes: https://github.com/logrotate/logrotate/pull/473
(cherry picked from commit bce6eec2c92f647940978feb12dc134a2bc20116)
---
test/Makefile.am | 3 ++-
test/test-0107.sh | 15 +++++++++++++++
test/test-config.107.in | 8 ++++++++
3 files changed, 25 insertions(+), 1 deletion(-)
create mode 100755 test/test-0107.sh
create mode 100644 test/test-config.107.in
diff --git a/test/Makefile.am b/test/Makefile.am
index f1a0062..69a5e45 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -93,7 +93,8 @@ TEST_CASES = \
test-0102.sh \
test-0103.sh \
test-0104.sh \
- test-0105.sh
+ test-0105.sh \
+ test-0107.sh
EXTRA_DIST = \
compress \
diff --git a/test/test-0107.sh b/test/test-0107.sh
new file mode 100755
index 0000000..5a5c37f
--- /dev/null
+++ b/test/test-0107.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. ./test-common.sh
+
+cleanup 107
+
+# ------------------------------- Test 107 ------------------------------------
+preptest test.log 107 1
+preptest zzzz.log 107 1
+$RLR test-config.107 --force || exit 23
+
+checkoutput <<EOF
+test.log.1 0 zero
+zzzz.log.1 0 zero
+EOF
diff --git a/test/test-config.107.in b/test/test-config.107.in
new file mode 100644
index 0000000..b57ec7f
--- /dev/null
+++ b/test/test-config.107.in
@@ -0,0 +1,8 @@
+&DIR&/test.log {
+ rotate 1
+ ignoreduplicates
+}
+
+&DIR&/*.log {
+ rotate 1
+}
--
2.47.1

View File

@ -1,7 +1,7 @@
Summary: Rotates, compresses, removes and mails system log files Summary: Rotates, compresses, removes and mails system log files
Name: logrotate Name: logrotate
Version: 3.18.0 Version: 3.18.0
Release: 8%{?dist} Release: 9%{?dist}
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
@ -22,6 +22,11 @@ Patch: 0004-logrotate-3.18.0-CVE-2022-1348.patch
# enforce stricter parsing of config files (#2148925) # enforce stricter parsing of config files (#2148925)
Patch: 0005-logrotate-3.18.0-stricter-config-parser.patch Patch: 0005-logrotate-3.18.0-stricter-config-parser.patch
# introduce `ignoreduplicates` configuration directive (RHEL-5711)
Patch: 0006-logrotate-3.18.0-Ensure-the-type-for-configuration-flags-is-wide-enou.patch
Patch: 0007-logrotate-3.18.0-config-introduce-ignoreduplicates-configuration-dire.patch
Patch: 0008-logrotate-3.18.0-test-0107-cover-the-ignoreduplicates-configuration-d.patch
BuildRequires: acl BuildRequires: acl
BuildRequires: automake BuildRequires: automake
BuildRequires: gcc BuildRequires: gcc
@ -122,6 +127,9 @@ fi
%config(noreplace) %{_sysconfdir}/rwtab.d/logrotate %config(noreplace) %{_sysconfdir}/rwtab.d/logrotate
%changelog %changelog
* Thu Jan 02 2025 Jan Macku <jamacku@redhat.com> - 3.18.0-9
- config: introduce `ignoreduplicates` configuration directive (#RHEL-5711)
* Tue Dec 20 2022 Kamil Dudka <kdudka@redhat.com> - 3.18.0-8 * Tue Dec 20 2022 Kamil Dudka <kdudka@redhat.com> - 3.18.0-8
- enforce stricter parsing of config files (#2148925) - enforce stricter parsing of config files (#2148925)