From 09ee6698161216dd4cbb36c26bd0e6e8c076aee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= Date: Fri, 6 Dec 2024 14:52:46 +0100 Subject: [PATCH] Reintroduce file existence check and fix timestamp file permissions In 1.7.0, cronie is not testing if /etc/default/anacron exists. This caused multiple errors to be logged in journal if the file was missing. Additionally, this update ensures that anacron timestamp files are created with the correct permissions. Previously, the files were created with 644 permissions in the %post script of the anacron subpackage but were listed as having 600 permissions in the %files section. This mismatch has now been resolved by creating the files with the appropriate 600 permissions. Resolves: RHEL-42706, RHEL-70286 --- cronie.spec | 9 ++++--- ...oduce-the-test-for-existence-of-file.patch | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 re-introduce-the-test-for-existence-of-file.patch diff --git a/cronie.spec b/cronie.spec index 7683c34..f646efa 100644 --- a/cronie.spec +++ b/cronie.spec @@ -17,6 +17,9 @@ Patch: n_option_wait_on_finnishing_grandchild_process.patch # https://github.com/cronie-crond/cronie/pull/184 Patch: 0001-Do-not-leak-file-descriptors-in-backup_crontab.patch +# https://github.com/cronie-crond/cronie/pull/161 +Patch: re-introduce-the-test-for-existence-of-file.patch + Requires: dailyjobs %if %{with selinux} @@ -135,9 +138,9 @@ install -m 644 contrib/cronie.systemd $RPM_BUILD_ROOT/lib/systemd/system/crond.s %systemd_post crond.service %post anacron -[ -e /var/spool/anacron/cron.daily ] || touch /var/spool/anacron/cron.daily 2>/dev/null || : -[ -e /var/spool/anacron/cron.weekly ] || touch /var/spool/anacron/cron.weekly 2>/dev/null || : -[ -e /var/spool/anacron/cron.monthly ] || touch /var/spool/anacron/cron.monthly 2>/dev/null || : +[ -e /var/spool/anacron/cron.daily ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.daily 2>/dev/null || : +[ -e /var/spool/anacron/cron.weekly ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.weekly 2>/dev/null || : +[ -e /var/spool/anacron/cron.monthly ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.monthly 2>/dev/null || : %preun # run before a package is removed diff --git a/re-introduce-the-test-for-existence-of-file.patch b/re-introduce-the-test-for-existence-of-file.patch new file mode 100644 index 0000000..2110f33 --- /dev/null +++ b/re-introduce-the-test-for-existence-of-file.patch @@ -0,0 +1,26 @@ +From 7700b1465d32ddb1d3988e9af852af6f0f5cd66e Mon Sep 17 00:00:00 2001 +From: Christian Hesse +Date: Mon, 16 Oct 2023 10:14:33 +0200 +Subject: [PATCH] re-introduce the test for existence of file + +If the file does not exist it exits early with error... Let's source +only if files acutually does exist. We still have a sane default. +--- + contrib/0anacron | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/contrib/0anacron b/contrib/0anacron +index 090219a..5379e41 100644 +--- a/contrib/0anacron ++++ b/contrib/0anacron +@@ -8,7 +8,9 @@ if [ `date +%Y%m%d` = "$day" ]; then + fi + + # Check whether run on battery should be allowed +-. /etc/default/anacron ++if test -r /etc/default/anacron; then ++ . /etc/default/anacron ++fi + + if [ "$ANACRON_RUN_ON_BATTERY_POWER" != "yes" ]; then +