Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
Jan Staněk
7757449621
Update to version 1.7.2 (rhbz#2294896)
- Polish bconds to use newer macros
- Patch leaks found by SAST scan
2024-07-01 15:02:04 +02:00
Ondřej Pohořelský
8ee9a63fea Update to 1.7.1 2024-02-26 10:12:47 +01:00
5 changed files with 76 additions and 59 deletions

12
.gitignore vendored
View file

@ -1,11 +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-*.tar.gz

View file

@ -0,0 +1,61 @@
From b3a54d0b3561bc2ab46c11fd5c67350cc216b171 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= <jstanek@redhat.com>
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) {

View file

@ -1,18 +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.0
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
# https://github.com/cronie-crond/cronie/pull/163
Patch: n_option_wait_on_finnishing_grandchild_process.patch
Patch: 0001-do-no-leak-file-descriptors.patch
Requires: dailyjobs
@ -83,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

View file

@ -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?= <opohorel@redhat.com>
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;

View file

@ -1 +1 @@
SHA512 (cronie-1.7.0.tar.gz) = a8e6688a164540e2cd3741c58813b6684c4c22a04806bcc8ba028a9ff72f986f165715ac3663bd34133af6566bdbd272a3e7be893f139e315aef35b2dbeb622f
SHA512 (cronie-1.7.2.tar.gz) = 5b55c677a5b812dbfa70f6ee25e41907e99cc63a4883974c6bb8115ad65155d66665704808c338d2f7be6b0a57028c319f2d1115c69bb5f3efdda1efafd144de