diff --git a/0017-logrotate-3.18.0-writeState-do-nothing-if-state-file-is-dev-null.patch b/0017-logrotate-3.18.0-writeState-do-nothing-if-state-file-is-dev-null.patch new file mode 100644 index 0000000..f25d25a --- /dev/null +++ b/0017-logrotate-3.18.0-writeState-do-nothing-if-state-file-is-dev-null.patch @@ -0,0 +1,80 @@ +From d8e171f36aab41182c2cf52d9a33ba478f090490 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Thu, 3 Jun 2021 10:51:07 +0200 +Subject: [PATCH] writeState: do nothing if state file is /dev/null + +If users do not want to use any state file, they can specify `/dev/null` +as the state file. Without this fix, logrotate would unnecessarily fail +to rename a temporary file to `/dev/null`. + +Fixes: https://github.com/logrotate/logrotate/issues/395 +(cherry picked from commit 456692644cbf5adb6253cb7ed2d169e950a9e348) +--- + logrotate.c | 4 ++++ + test/Makefile.am | 1 + + test/test-0089.sh | 14 ++++++++++++++ + test/test-config.89.in | 4 ++++ + 4 files changed, 23 insertions(+) + create mode 100755 test/test-0089.sh + create mode 100644 test/test-config.89.in + +diff --git a/logrotate.c b/logrotate.c +index b0f8332..df0eb22 100644 +--- a/logrotate.c ++++ b/logrotate.c +@@ -2507,6 +2507,10 @@ static int writeState(const char *stateFilename) + char *prevCtx; + int force_mode = 0; + ++ if (!strcmp(stateFilename, "/dev/null")) ++ /* explicitly asked not to write the state file */ ++ return 0; ++ + localtime_r(&nowSecs, &now); + + tmpFilename = malloc(strlen(stateFilename) + 5 ); +diff --git a/test/Makefile.am b/test/Makefile.am +index 69a5e45..27c3900 100644 +--- a/test/Makefile.am ++++ b/test/Makefile.am +@@ -87,6 +87,7 @@ TEST_CASES = \ + test-0086.sh \ + test-0087.sh \ + test-0088.sh \ ++ test-0089.sh \ + test-0092.sh \ + test-0100.sh \ + test-0101.sh \ +diff --git a/test/test-0089.sh b/test/test-0089.sh +new file mode 100755 +index 0000000..c586690 +--- /dev/null ++++ b/test/test-0089.sh +@@ -0,0 +1,14 @@ ++#!/bin/sh ++ ++. ./test-common.sh ++ ++# skip the test if /dev/null is not readable ++test -r /dev/null || exit 77 ++ ++# we don't want any stuff left from previous runs ++cleanup 89 ++ ++# ------------------------------- Test 89 ------------------------------------ ++# using /dev/null as state file tells logrotate not to write the state file ++preptest test.log 89 2 ++$RLR --state /dev/null test-config.89 +diff --git a/test/test-config.89.in b/test/test-config.89.in +new file mode 100644 +index 0000000..ec41c37 +--- /dev/null ++++ b/test/test-config.89.in +@@ -0,0 +1,4 @@ ++&DIR&/test.log { ++ daily ++ rotate 2 ++} +-- +2.49.0 + diff --git a/logrotate.spec b/logrotate.spec index 992db82..e76d3a8 100644 --- a/logrotate.spec +++ b/logrotate.spec @@ -1,7 +1,7 @@ Summary: Rotates, compresses, removes and mails system log files Name: logrotate Version: 3.18.0 -Release: 11%{?dist} +Release: 12%{?dist} License: GPLv2+ URL: https://github.com/logrotate/logrotate Source0: https://github.com/logrotate/logrotate/releases/download/%{version}/logrotate-%{version}.tar.xz @@ -30,6 +30,7 @@ Patch: 0008-logrotate-3.18.0-test-0107-cover-the-ignoreduplicates-configuratio # allow to disable state management (RHEL-69959) Patch: 0009-logrotate-3.18.0-add-documentation-for-state-dev-null-special-case.patch Patch: 0010-logrotate-3.18.0-Do-not-lock-state-file-dev-null.patch +Patch: 0017-logrotate-3.18.0-writeState-do-nothing-if-state-file-is-dev-null.patch # fix memory corruption issues in config file parsing Patch: 0011-logrotate-3.18.0-Log-all-glob-errors-in-debug-mode.patch @@ -139,6 +140,9 @@ fi %config(noreplace) %{_sysconfdir}/rwtab.d/logrotate %changelog +* Wed Jun 11 2025 Jan Macku - 3.18.0-12 +- allow to disable state management (RHEL-69959) + * Fri Jun 06 2025 Jan Macku - 3.18.0-11 - fix memory corruption issues in config file parsing (RHEL-91449)