Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
c31094208d
!37 [sync] PR-34: anacron use xclose instead of fclose
From: @openeuler-sync-bot 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
2023-12-04 12:41:49 +00:00
hongjinghao
18dedac5e6 anacron Use xclose instead of fclose
(cherry picked from commit aa10d6863df9fff8c53a44ac91030fde59f5e9d0)
2023-12-04 19:57:16 +08:00
openeuler-ci-bot
05b08c37e1
!29 Support reloading with SIGURG in addition to SIGHUP
From: @wangyuhang27 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
2023-06-15 06:54:49 +00:00
wangyuhang
bdf827704f Support reloading with SIGURG in addition to SIGHUP 2023-06-15 14:30:54 +08:00
openeuler-ci-bot
579973f4df !13 Add automake BuildRequires to use the aclocal program
From: @panxh_purple
Reviewed-by: @overweight
Signed-off-by: @overweight
2021-05-31 17:34:54 +08:00
panxiaohe
96596e6c12 Add automake BuildRequires to use the aclocal program 2021-05-28 19:29:20 +08:00
openeuler-ci-bot
82615d13a0 !6 Sync some patches from community
Merge pull request !6 from linwei9/cronie
2020-06-30 16:30:33 +08:00
linwei9
98ca10d73a sync some patches from community 2020-06-30 15:40:53 +08:00
openeuler-ci-bot
c8e0dfa28d !2 update to 1.5.5
Merge pull request !2 from 奥里给笑子李/master
2020-05-12 16:15:55 +08:00
oli_give_xiao_zi_li
fcbda8f8df update to 1.5.5 2020-05-11 18:09:54 +08:00
11 changed files with 333 additions and 33 deletions

View File

@ -0,0 +1,31 @@
From 05f5f1834d31e4d9480b59d4e8bd3e999a62fa40 Mon Sep 17 00:00:00 2001
From: John Horne <john.horne@plymouth.ac.uk>
Date: Mon, 20 Apr 2020 16:02:31 +0100
Subject: [PATCH] Add CMDEND log entry to log when cron jobs end.
---
src/do_command.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/do_command.c b/src/do_command.c
index ed56775..dda8ff7 100644
--- a/src/do_command.c
+++ b/src/do_command.c
@@ -581,6 +581,14 @@ static int child_process(entry * e, char **jobenv) {
Debug(DPROC,
("[%ld] no more grandchildren--mail written?\n",
(long) getpid()));
+
+ if ((e->flags & DONT_LOG) == 0) {
+ char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
+
+ log_it(usernm, getpid(), "CMDEND", x, 0);
+ free(x);
+ }
+
break;
}
Debug(DPROC, ("[%ld] grandchild #%ld finished, status=%04x",
--
1.8.3.1

View File

@ -0,0 +1,25 @@
From 59063efa62fbb75bb75ad34a9e9c551b77284377 Mon Sep 17 00:00:00 2001
From: John Horne <john.horne@plymouth.ac.uk>
Date: Mon, 20 Apr 2020 20:16:29 +0100
Subject: [PATCH] Ensure the command name is not null before logging it.
---
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 76939a1..d1594c6 100644
--- a/src/do_command.c
+++ b/src/do_command.c
@@ -592,7 +592,7 @@ static int child_process(entry * e, char **jobenv) {
if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
- log_it(usernm, getpid(), "CMDEND", x, 0);
+ log_it(usernm, getpid(), "CMDEND", x ? x : "Unknown command" , 0);
free(x);
}
return OK_EXIT;
--
1.8.3.1

View File

@ -0,0 +1,46 @@
From 22ae88868f48090e2a5ad4b9bb165581df91511f Mon Sep 17 00:00:00 2001
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
Date: Sun, 24 Nov 2019 17:22:49 +0100
Subject: [PATCH] Fix incorrect include of fcntl.h
---
configure.ac | 1 -
src/cron.c | 5 +----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index bffe9ad..5493261 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,7 +38,6 @@ AC_CHECK_HEADERS( \
sys/timers.h \
sys/types.h \
sys/cdefs.h \
- sys/fcntl.h \
time.h \
unistd.h \
util.h \
diff --git a/src/cron.c b/src/cron.c
index 7eabfe9..40e1e76 100644
--- a/src/cron.c
+++ b/src/cron.c
@@ -40,15 +40,12 @@
#include <sys/wait.h>
#include <unistd.h>
#include <sys/time.h>
+#include <fcntl.h>
#ifdef WITH_INOTIFY
# include <sys/inotify.h>
#endif
-#ifdef HAVE_SYS_FCNTL_H
-# include <sys/fcntl.h>
-#endif
-
#include "cronie_common.h"
#include "funcs.h"
#include "globals.h"
--
1.8.3.1

View File

@ -0,0 +1,35 @@
From 654b85488b128aab5baf8feee71f38b763425d56 Mon Sep 17 00:00:00 2001
From: Tomas Mraz <tmraz@fedoraproject.org>
Date: Tue, 21 Apr 2020 09:30:03 +0200
Subject: [PATCH] Handle out-of-memory condition from mkprints() call
---
src/do_command.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/do_command.c b/src/do_command.c
index d1594c6..b4f1d18 100644
--- a/src/do_command.c
+++ b/src/do_command.c
@@ -194,6 +194,9 @@ static int child_process(entry * e, char **jobenv) {
if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
+ if (x == NULL) /* out of memory, better exit */
+ _exit(ERROR_EXIT);
+
log_it(usernm, getpid(), "CMD", x, 0);
free(x);
}
@@ -592,7 +595,7 @@ static int child_process(entry * e, char **jobenv) {
if ((e->flags & DONT_LOG) == 0) {
char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
- log_it(usernm, getpid(), "CMDEND", x ? x : "Unknown command" , 0);
+ log_it(usernm, getpid(), "CMDEND", x ? x : "**Unknown command**" , 0);
free(x);
}
return OK_EXIT;
--
1.8.3.1

View File

@ -0,0 +1,44 @@
From 79d403e34e8a65b7f4c21f0dcb31fcc9c6fabc7d Mon Sep 17 00:00:00 2001
From: John Horne <john.horne@plymouth.ac.uk>
Date: Mon, 20 Apr 2020 16:59:53 +0100
Subject: [PATCH] Moved CMDEND code to outside for for loop.
---
src/do_command.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/do_command.c b/src/do_command.c
index dda8ff7..76939a1 100644
--- a/src/do_command.c
+++ b/src/do_command.c
@@ -581,14 +581,6 @@ static int child_process(entry * e, char **jobenv) {
Debug(DPROC,
("[%ld] no more grandchildren--mail written?\n",
(long) getpid()));
-
- if ((e->flags & DONT_LOG) == 0) {
- char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
-
- log_it(usernm, getpid(), "CMDEND", x, 0);
- free(x);
- }
-
break;
}
Debug(DPROC, ("[%ld] grandchild #%ld finished, status=%04x",
@@ -597,6 +589,12 @@ static int child_process(entry * e, char **jobenv) {
Debug(DPROC, (", dumped core"));
Debug(DPROC, ("\n"));
}
+ if ((e->flags & DONT_LOG) == 0) {
+ char *x = mkprints((u_char *) e->cmd, strlen(e->cmd));
+
+ log_it(usernm, getpid(), "CMDEND", x, 0);
+ free(x);
+ }
return OK_EXIT;
}
--
1.8.3.1

View File

@ -1,30 +0,0 @@
From 04d556ba1f3c18508c51231fa12a6d8f0bddf36c Mon Sep 17 00:00:00 2001
From: root <root@localhost.localdomain>
Date: Tue, 23 Jul 2019 07:54:07 -0400
Subject: [PATCH] Revert "Avoid creating pid files when crond doesn't fork"
Reason: The PID file is useful to avoid running multiple crond instances
at once.
Source: https://github.com/cronie-crond/cronie/commit/0570c2cd979bc9ce1da6a873089e89dbca900a1f
Signed-off-by: root <root@localhost.localdomain>
---
src/misc.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/misc.c b/src/misc.c
index 4efab64..587c761 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -315,9 +315,6 @@ void acquire_daemonlock(int closeflag) {
return;
}
- if (NoFork == 1)
- return; //move along, nothing to do here...
-
if (fd == -1) {
pidfile = _PATH_CRON_PID;
/* Initial mode is 0600 to prevent flock() race/DoS. */
--
2.19.1

View File

@ -0,0 +1,78 @@
From 630b24112fbd87c0dd020795a221fefc8840630a Mon Sep 17 00:00:00 2001
From: YoruStar <524413304@qq.com>
Date: Wed, 29 Mar 2023 15:58:58 +0800
Subject: [PATCH] Support reloading with SIGURG in addition to SIGHUP
And use that with the systemd unit to handle the reload.
Conflict:NA
Reference:https://github.com/cronie-crond/cronie/commit/630b24112fbd87c0dd020795a221fefc8840630a
---
contrib/cronie.systemd | 2 +-
src/cron.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/contrib/cronie.systemd b/contrib/cronie.systemd
index 19f2a98..8317367 100644
--- a/contrib/cronie.systemd
+++ b/contrib/cronie.systemd
@@ -5,7 +5,7 @@ After=auditd.service nss-user-lookup.target systemd-user-sessions.service time-s
[Service]
EnvironmentFile=/etc/sysconfig/crond
ExecStart=/usr/sbin/crond -n $CRONDARGS
-ExecReload=/bin/kill -HUP $MAINPID
+ExecReload=/bin/kill -URG $MAINPID
KillMode=process
Restart=on-failure
RestartSec=30s
diff --git a/src/cron.c b/src/cron.c
index 1ff19e3..e4e119d 100644
--- a/src/cron.c
+++ b/src/cron.c
@@ -66,10 +66,11 @@ set_time(int),
cron_sleep(int, cron_db *),
sigchld_handler(int),
sighup_handler(int ATTRIBUTE_UNUSED),
+sigurg_handler(int ATTRIBUTE_UNUSED),
sigchld_reaper(void),
sigintterm_handler(int ATTRIBUTE_UNUSED), parse_args(int c, char *v[]);
-static volatile sig_atomic_t got_sighup, got_sigchld, got_sigintterm;
+static volatile sig_atomic_t got_sighup, got_sigchld, got_sigintterm, got_sigurg;
static int timeRunning, virtualTime, clockTime;
static long GMToff;
static int DisableInotify;
@@ -151,8 +152,9 @@ void set_cron_watched(int fd) {
#endif
static void handle_signals(cron_db * database) {
- if (got_sighup) {
+ if (got_sighup || got_sigurg) {
got_sighup = 0;
+ got_sigurg = 0;
#if defined WITH_INOTIFY
/* watches must be reinstated on reload */
if (inotify_enabled && (EnableClustering != 1)) {
@@ -243,6 +245,8 @@ int main(int argc, char *argv[]) {
sact.sa_handler = sigintterm_handler;
(void) sigaction(SIGINT, &sact, NULL);
(void) sigaction(SIGTERM, &sact, NULL);
+ sact.sa_handler = sigurg_handler;
+ (void) sigaction(SIGURG, &sact, NULL);
acquire_daemonlock(0);
set_cron_uid();
@@ -664,6 +668,10 @@ static void sigintterm_handler(int x ATTRIBUTE_UNUSED) {
got_sigintterm = 1;
}
+static void sigurg_handler(int x ATTRIBUTE_UNUSED) {
+ got_sigurg = 1;
+}
+
static void sigchld_reaper(void) {
WAIT_T waiter;
PID_T pid;
--
2.33.0

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

Binary file not shown.

BIN
cronie-1.5.5.tar.gz Normal file

Binary file not shown.

View File

@ -1,16 +1,23 @@
Name: cronie
Version: 1.5.4
Version: 1.5.5
Release: 5
Summary: Standard UNIX daemon crond
License: GPLv2+ and ISC
URL: https://github.com/cronie-crond/cronie
Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}-final/cronie-%{version}.tar.gz
Patch6000: Revert-Avoid-creating-pid-files.patch
Patch9000: bugfix-cronie-systemd-alias.patch
Patch0: bugfix-cronie-systemd-alias.patch
Patch1: Fix-incorrect-include-of-fcntl.h.patch
Patch2: Add-CMDEND-log-entry-to-log-when-cron-jobs-end.patch
Patch3: Moved-CMDEND-code-to-outside-for-for-loop.patch
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
Requires: libselinux pam crontabs
@ -119,6 +126,24 @@ 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
- SUG:NA
- DESC:Support reloading with SIGURG in addition to SIGHUP
* Fri May 28 2021 panxiaohe <panxiaohe@huawei.com> - 1.5.5-3
- Add automake BuildRequires to use the aclocal program
* Mon Jun 29 2020 linwei <linwei54@huawei.com> - 1.5.5-2
- sync some patchs from community
* Mon May 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.5.5-1
- update to 1.5.5-1
* Sat Mar 21 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.5.4-5
- Type:bugfix
- ID:NA