From 8ee9a63fea7f0aec13b6c2c4c064bfa452150236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= Date: Mon, 26 Feb 2024 09:32:05 +0100 Subject: [PATCH 1/2] Update to 1.7.1 --- .gitignore | 1 + cronie.spec | 4 +-- ...ait_on_finnishing_grandchild_process.patch | 25 ------------------- sources | 2 +- 4 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 n_option_wait_on_finnishing_grandchild_process.patch diff --git a/.gitignore b/.gitignore index 4079eb0..14befbb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /cronie-1.6.0.tar.gz /cronie-1.6.1.tar.gz /cronie-1.7.0.tar.gz +/cronie-1.7.1.tar.gz diff --git a/cronie.spec b/cronie.spec index fc4df93..6b48080 100644 --- a/cronie.spec +++ b/cronie.spec @@ -5,14 +5,12 @@ Summary: Cron daemon for executing programs at set times Name: cronie -Version: 1.7.0 +Version: 1.7.1 Release: %autorelease License: GPL-2.0-or-later AND BSD-3-Clause AND BSD-2-Clause AND ISC AND LGPL-2.1-or-later URL: https://github.com/cronie-crond/cronie Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz -# https://github.com/cronie-crond/cronie/pull/163 -Patch: n_option_wait_on_finnishing_grandchild_process.patch Requires: dailyjobs diff --git a/n_option_wait_on_finnishing_grandchild_process.patch b/n_option_wait_on_finnishing_grandchild_process.patch deleted file mode 100644 index b01c6f5..0000000 --- a/n_option_wait_on_finnishing_grandchild_process.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 5cf85f8cbb816ff1df5b317d6f8559b67e1993dd Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= -Date: Wed, 25 Oct 2023 10:58:46 +0200 -Subject: [PATCH] -n option: wait on finnishing grandchild process - -With `WNOHANG` we skip sending the email when waitpid() returns 0, -which happens if the process is still running. Instead, using `0` -parameter will wait for the process to actually stop running. ---- - src/do_command.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/do_command.c b/src/do_command.c -index d7ca840..2ada913 100644 ---- a/src/do_command.c -+++ b/src/do_command.c -@@ -579,7 +579,7 @@ static int child_process(entry * e, char **jobenv) { - if (mail && e->flags & MAIL_WHEN_ERR) { - int jobstatus = -1; - if (jobpid > 0) { -- while (waitpid(jobpid, &jobstatus, WNOHANG) == -1) { -+ while (waitpid(jobpid, &jobstatus, 0) == -1) { - if (errno == EINTR) continue; - log_it("CRON", getpid(), "error", "invalid job pid", errno); - break; diff --git a/sources b/sources index 22b8e68..9c61c48 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (cronie-1.7.0.tar.gz) = a8e6688a164540e2cd3741c58813b6684c4c22a04806bcc8ba028a9ff72f986f165715ac3663bd34133af6566bdbd272a3e7be893f139e315aef35b2dbeb622f +SHA512 (cronie-1.7.1.tar.gz) = 4479f6f05ca9da3ecefa0e9b73662f1db58ffff309916de9f92f89c5e7f93f1c5c744f18cb3e1a3df9664d533afe7dad710f97484e72a314c87d84f57a6c56fb From 775744962120088d90532d25718e3adba1d58f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Mon, 1 Jul 2024 14:51:31 +0200 Subject: [PATCH 2/2] Update to version 1.7.2 (rhbz#2294896) - Polish bconds to use newer macros - Patch leaks found by SAST scan --- .gitignore | 13 +----- 0001-do-no-leak-file-descriptors.patch | 61 ++++++++++++++++++++++++++ cronie.spec | 33 ++++++-------- sources | 2 +- 4 files changed, 76 insertions(+), 33 deletions(-) create mode 100644 0001-do-no-leak-file-descriptors.patch diff --git a/.gitignore b/.gitignore index 14befbb..29a96bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1 @@ -/cronie-1.5.0.tar.gz -/cronie-1.5.1.tar.gz -/cronie-1.5.2.tar.gz -/cronie-1.5.3.tar.gz -/cronie-1.5.4.tar.gz -/cronie-1.5.5.tar.gz -/cronie-1.5.6.tar.gz -/cronie-1.5.7.tar.gz -/cronie-1.6.0.tar.gz -/cronie-1.6.1.tar.gz -/cronie-1.7.0.tar.gz -/cronie-1.7.1.tar.gz +/cronie-*.tar.gz diff --git a/0001-do-no-leak-file-descriptors.patch b/0001-do-no-leak-file-descriptors.patch new file mode 100644 index 0000000..3c81e32 --- /dev/null +++ b/0001-do-no-leak-file-descriptors.patch @@ -0,0 +1,61 @@ +From b3a54d0b3561bc2ab46c11fd5c67350cc216b171 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= +Date: Wed, 26 Jun 2024 16:08:44 +0200 +Subject: [PATCH] Do not leak file descriptors in backup_crontab + +Originally, if anything went wrong during the backup, +the early return caused the crontab_file and possibly backup_file +pointers to leak. + +Issue found by static scanner. +--- + src/crontab.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/crontab.c b/src/crontab.c +index f61fd46..55d2aed 100644 +--- a/src/crontab.c ++++ b/src/crontab.c +@@ -563,6 +563,7 @@ static int backup_crontab(const char *crontab_path) { + + if (swap_uids() == -1) { + perror("swapping uids"); ++ (void) fclose(crontab_file); + exit(ERROR_EXIT); + } + +@@ -590,22 +591,29 @@ static int backup_crontab(const char *crontab_path) { + + if (swap_uids_back() < OK) { + perror("swapping uids back"); ++ if (backup_file != NULL) { ++ (void) fclose(backup_file); ++ } ++ (void) fclose(crontab_file); + exit(ERROR_EXIT); + } + + if (retval != 0) +- return retval; ++ goto cleanup; + + if (EOF != ch) + while (EOF != (ch = get_char(crontab_file))) + putc(ch, backup_file); + +- (void) fclose(crontab_file); +- (void) fclose(backup_file); +- + printf("Backup of %s's previous crontab saved to %s\n", User, backup_path); + +- return 0; ++cleanup: ++ if (backup_file != NULL) { ++ (void) fclose(backup_file); ++ } ++ (void) fclose(crontab_file); ++ ++ return retval; + } + + static void check_error(const char *msg) { diff --git a/cronie.spec b/cronie.spec index 6b48080..ce56756 100644 --- a/cronie.spec +++ b/cronie.spec @@ -1,16 +1,17 @@ -%bcond_without selinux -%bcond_without pam -%bcond_without audit -%bcond_without inotify +%bcond selinux 1 +%bcond pam 1 +%bcond audit 1 +%bcond inotify 1 Summary: Cron daemon for executing programs at set times Name: cronie -Version: 1.7.1 +Version: 1.7.2 Release: %autorelease License: GPL-2.0-or-later AND BSD-3-Clause AND BSD-2-Clause AND ISC AND LGPL-2.1-or-later URL: https://github.com/cronie-crond/cronie Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz +Patch: 0001-do-no-leak-file-descriptors.patch Requires: dailyjobs @@ -81,21 +82,13 @@ extra features. %build %configure \ -%if %{with pam} ---with-pam \ -%endif -%if %{with selinux} ---with-selinux \ -%endif -%if %{with audit} ---with-audit \ -%endif -%if %{with inotify} ---with-inotify \ -%endif ---enable-anacron \ ---enable-pie \ ---enable-relro + %{?with_pam:--with-pam} \ + %{?with_selinux:--with-selinux} \ + %{?with_audit:--with-audit} \ + %{?with_inotify:--with-inotify} \ + --enable-anacron \ + --enable-pie \ + --enable-relro %make_build V=2 diff --git a/sources b/sources index 9c61c48..be7e26e 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (cronie-1.7.1.tar.gz) = 4479f6f05ca9da3ecefa0e9b73662f1db58ffff309916de9f92f89c5e7f93f1c5c744f18cb3e1a3df9664d533afe7dad710f97484e72a314c87d84f57a6c56fb +SHA512 (cronie-1.7.2.tar.gz) = 5b55c677a5b812dbfa70f6ee25e41907e99cc63a4883974c6bb8115ad65155d66665704808c338d2f7be6b0a57028c319f2d1115c69bb5f3efdda1efafd144de