From 18dedac5e6ab9a43e93b8e7baf8b8fd8a8f55de5 Mon Sep 17 00:00:00 2001 From: hongjinghao Date: Mon, 4 Dec 2023 16:00:32 +0800 Subject: [PATCH] anacron Use xclose instead of fclose (cherry picked from commit aa10d6863df9fff8c53a44ac91030fde59f5e9d0) --- ...anacron-Use-xclose-instead-of-fclose.patch | 46 +++++++++++++++++++ cronie.spec | 6 ++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 backport-anacron-Use-xclose-instead-of-fclose.patch diff --git a/backport-anacron-Use-xclose-instead-of-fclose.patch b/backport-anacron-Use-xclose-instead-of-fclose.patch new file mode 100644 index 0000000..683cf92 --- /dev/null +++ b/backport-anacron-Use-xclose-instead-of-fclose.patch @@ -0,0 +1,46 @@ +From 880489e42a652b84c7de348f0167dfd26abca326 Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Fri, 13 Oct 2023 10:40:05 +0200 +Subject: [PATCH] anacron: Use xclose() instead of fclose() + +When replacing standard descriptors we use +xclose() elsewhere and it is less error-prone. + +Fixes #156 + +--- + anacron/main.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/anacron/main.c b/anacron/main.c +index d092970..3ede1d2 100644 +--- a/anacron/main.c ++++ b/anacron/main.c +@@ -207,11 +207,11 @@ go_background(void) + + /* stdin is already closed */ + +- if (fclose(stdout)) die_e("Can't close stdout"); +- xopen(1, "/dev/null", O_WRONLY); ++ xclose(STDOUT_FILENO); ++ xopen(STDOUT_FILENO, "/dev/null", O_WRONLY); + +- if (fclose(stderr)) die_e("Can't close stderr"); +- xopen(2, "/dev/null", O_WRONLY); ++ xclose(STDERR_FILENO); ++ xopen(STDERR_FILENO, "/dev/null", O_WRONLY); + + pid = xfork(); + if (pid != 0) +@@ -472,7 +472,7 @@ main(int argc, char *argv[]) + + if (sigprocmask(0, NULL, &old_sigmask)) die_e("sigset error"); + +- if (fclose(stdin)) die_e("Can't close stdin"); ++ xclose(STDIN_FILENO); + xopen(STDIN_FILENO, "/dev/null", O_RDONLY); + + if (!no_daemon && !testing_only) +-- +2.33.0 + diff --git a/cronie.spec b/cronie.spec index 91d51da..d424ee5 100644 --- a/cronie.spec +++ b/cronie.spec @@ -1,6 +1,6 @@ Name: cronie Version: 1.5.5 -Release: 4 +Release: 5 Summary: Standard UNIX daemon crond License: GPLv2+ and ISC URL: https://github.com/cronie-crond/cronie @@ -15,6 +15,7 @@ Patch4: Ensure-the-command-name-is-not-null-before-logging-i.patch Patch5: Handle-out-of-memory-condition-from-mkprints-call.patch Patch6000: backport-Support-reloading-with-SIGURG-in-addition-to-SIGHUP.patch +Patch6001: backport-anacron-Use-xclose-instead-of-fclose.patch BuildRequires: automake BuildRequires: gcc systemd libselinux-devel pam-devel audit-libs-devel git @@ -125,6 +126,9 @@ systemctl try-restart crond.service >/dev/null 2>&1 || : %changelog +* Mon Dec 4 2023 hongjinghao - 1.5.5-5 +- anacron Use xclose instead of fclose + * Thu Jun 15 2023 wangyuhang - 1.5.5-4 - Type:bugfix - CVE:NA