!32 anacron use xclose instead of fclose

From: @hongjinghao 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
This commit is contained in:
openeuler-ci-bot 2023-12-04 11:54:22 +00:00 committed by Gitee
commit 840de45f56
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,47 @@
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 65f8fed..1ad904a 100644
--- a/anacron/main.c
+++ b/anacron/main.c
@@ -209,13 +209,13 @@ go_background(void)
/* stdin is already closed */
- if (fclose(stdout)) die_e("Can't close stdout");
+ xclose(STDOUT_FILENO);
/* coverity[leaked_handle] fd 1 closed automatically */
- xopen(1, "/dev/null", O_WRONLY);
+ xopen(STDOUT_FILENO, "/dev/null", O_WRONLY);
- if (fclose(stderr)) die_e("Can't close stderr");
+ xclose(STDERR_FILENO);
/* coverity[leaked_handle] fd 2 closed automatically */
- xopen(2, "/dev/null", O_WRONLY);
+ xopen(STDERR_FILENO, "/dev/null", O_WRONLY);
pid = xfork();
if (pid != 0)
@@ -476,7 +476,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 Name: cronie
Version: 1.6.1 Version: 1.6.1
Release: 4 Release: 5
Summary: Standard UNIX daemon crond Summary: Standard UNIX daemon crond
License: GPLv2+ and ISC License: GPLv2+ and ISC
URL: https://github.com/cronie-crond/cronie URL: https://github.com/cronie-crond/cronie
@ -10,6 +10,7 @@ Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{vers
Patch0: bugfix-cronie-systemd-alias.patch Patch0: bugfix-cronie-systemd-alias.patch
Patch6000: backport-Support-reloading-with-SIGURG-in-addition-to-SIGHUP.patch Patch6000: backport-Support-reloading-with-SIGURG-in-addition-to-SIGHUP.patch
Patch6001: backport-anacron-Use-xclose-instead-of-fclose.patch
BuildRequires: automake BuildRequires: automake
BuildRequires: gcc systemd libselinux-devel pam-devel audit-libs-devel BuildRequires: gcc systemd libselinux-devel pam-devel audit-libs-devel
@ -120,6 +121,9 @@ systemctl try-restart crond.service >/dev/null 2>&1 || :
%changelog %changelog
* Mon Dec 4 2023 hongjinghao <hongjinghao@huawei.com> - 1.6.1-5
- anacron use xclose instead of fclose
* Thu Jun 15 2023 wangyuhang <wangyuhang27@huawei.com> - 1.6.1-4 * Thu Jun 15 2023 wangyuhang <wangyuhang27@huawei.com> - 1.6.1-4
- Type:bugfix - Type:bugfix
- CVE:NA - CVE:NA