anacron Use xclose instead of fclose

(cherry picked from commit aa10d6863df9fff8c53a44ac91030fde59f5e9d0)
This commit is contained in:
hongjinghao 2023-12-04 16:00:32 +08:00 committed by openeuler-sync-bot
parent 05b08c37e1
commit 18dedac5e6
2 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,46 @@
From 880489e42a652b84c7de348f0167dfd26abca326 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
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

View File

@ -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 <hongjinghao@huawei.com> - 1.5.5-5
- anacron Use xclose instead of fclose
* Thu Jun 15 2023 wangyuhang <wangyuhang27@huawei.com> - 1.5.5-4
- Type:bugfix
- CVE:NA