import CS cronie-1.5.7-16.el9

This commit is contained in:
AlmaLinux RelEng Bot 2026-03-30 11:18:45 -04:00
parent 3a158d676d
commit e8c3158471
4 changed files with 108 additions and 12 deletions

View File

@ -0,0 +1,9 @@
# systemd-tmpfiles configuration for cronie-anacron
# Create the anacron spool directory
d /var/spool/anacron 0755 root root -
# Create anacron timestamp files
f /var/spool/anacron/cron.daily 0600 root root -
f /var/spool/anacron/cron.weekly 0600 root root -
f /var/spool/anacron/cron.monthly 0600 root root -

View File

@ -0,0 +1,4 @@
# systemd-tmpfiles configuration for cronie
# Create the cron spool directory
d /var/spool/cron 0700 root root -

View File

@ -0,0 +1,70 @@
From 5f9f16b5663becefdd0dd70df31c0ef5ac36f943 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= <opohorel@redhat.com>
Date: Thu, 27 Nov 2025 14:38:47 +0100
Subject: [PATCH] Forward XDG_SESSION_CLASS to PAM for session classification
Allow users to set the XDG_SESSION_CLASS environment variable in their
crontab to control the systemd session class for cron jobs. When set,
this value is forwarded to the PAM environment so that pam_systemd can
use it for session classification (e.g., "background-light").
This enables cron jobs to run in lighter-weight sessions that consume
fewer system resources.
---
man/crontab.5 | 10 ++++++++++
src/security.c | 21 +++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/man/crontab.5 b/man/crontab.5
index 68380c6..7487cc5 100644
--- a/man/crontab.5
+++ b/man/crontab.5
@@ -157,6 +157,16 @@ upper limit specified by the variable. The random scaling factor is
determined during the cron daemon startup so it remains constant for
the whole run time of the daemon.
.PP
+The
+.I XDG_SESSION_CLASS
+variable specifies the session class to be used when PAM creates a systemd
+session for the cron job. If set (e.g., to "background-light"), this value
+is forwarded to the PAM environment so that
+.BR pam_systemd (8)
+can use it for session classification. This allows cron jobs to run in
+lighter-weight sessions that consume fewer system resources. This variable
+has no effect if crond was built without PAM support.
+.PP
The format of a cron command is similar to the V7 standard, with a number
of upward-compatible extensions. Each line has five time-and-date fields
followed by a
diff --git a/src/security.c b/src/security.c
index 14a514a..67b6d26 100644
--- a/src/security.c
+++ b/src/security.c
@@ -131,6 +131,27 @@ int cron_set_job_security_context(entry *e, user *u ATTRIBUTE_UNUSED,
pam_strerror(pamh, ret), 0);
return -1;
}
+
+ /* Forward XDG_SESSION_CLASS from crontab environment to PAM
+ * so that pam_systemd.so can use it for session classification */
+#ifdef HAVE_PAM_PUTENV
+ if (pamh != NULL) {
+ char *xdg_session_class = env_get("XDG_SESSION_CLASS", e->envp);
+ if (xdg_session_class != NULL) {
+ char *xdg_session_class_env = NULL;
+ if (asprintf(&xdg_session_class_env, "XDG_SESSION_CLASS=%s",
+ xdg_session_class) >= 0) {
+ ret = pam_putenv(pamh, xdg_session_class_env);
+ if (ret != PAM_SUCCESS) {
+ log_it(e->pwd->pw_name, getpid(),
+ "WARNING: Failed to set XDG_SESSION_CLASS in PAM environment",
+ pam_strerror(pamh, ret), 0);
+ }
+ free(xdg_session_class_env);
+ }
+ }
+ }
+#endif
#endif
#ifdef WITH_SELINUX

View File

@ -6,10 +6,12 @@
Summary: Cron daemon for executing programs at set times
Name: cronie
Version: 1.5.7
Release: 15%{?dist}
Release: 16%{?dist}
License: MIT and BSD and ISC and GPLv2+
URL: https://github.com/cronie-crond/cronie
Source0: https://github.com/cronie-crond/cronie/releases/download/cronie-%{version}/cronie-%{version}.tar.gz
Source1: cronie-tmpfiles.conf
Source2: cronie-anacron-tmpfiles.conf
Patch: 0001-Address-issues-found-by-coverity-scan.patch
# Add support for "~" ("random within range") + regression fixing patches (rhbz#2090691)
@ -41,6 +43,9 @@ Patch: set-size-out-of-bounds.patch
Patch: fix-range-parsing.patch
Patch: move_parsing_code.patch
# https://github.com/cronie-crond/cronie/pull/210
Patch: forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch
Requires: dailyjobs
%if %{with selinux}
@ -130,7 +135,6 @@ extra features.
%install
%make_install DESTMAN=$RPM_BUILD_ROOT%{_mandir}
mkdir -pm700 $RPM_BUILD_ROOT%{_localstatedir}/spool/cron
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/
mkdir -pm755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/
%if ! %{with pam}
@ -142,10 +146,6 @@ install -m 644 contrib/anacrontab $RPM_BUILD_ROOT%{_sysconfdir}/anacrontab
install -c -m755 contrib/0hourly $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/0hourly
mkdir -pm 755 $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly
install -c -m755 contrib/0anacron $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/0anacron
mkdir -p $RPM_BUILD_ROOT/var/spool/anacron
touch $RPM_BUILD_ROOT/var/spool/anacron/cron.daily
touch $RPM_BUILD_ROOT/var/spool/anacron/cron.weekly
touch $RPM_BUILD_ROOT/var/spool/anacron/cron.monthly
# noanacron package
install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs
@ -153,14 +153,19 @@ install -m 644 contrib/dailyjobs $RPM_BUILD_ROOT/%{_sysconfdir}/cron.d/dailyjobs
# install systemd initscript
install -m 644 -D contrib/cronie.systemd $RPM_BUILD_ROOT/usr/lib/systemd/system/crond.service
# install tmpfiles.d configuration for bootc compatibility
install -m 644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_tmpfilesdir}/cronie.conf
install -m 644 -D %{SOURCE2} $RPM_BUILD_ROOT%{_tmpfilesdir}/cronie-anacron.conf
%post
# run after an installation
%systemd_post crond.service
# create directories via tmpfiles.d for bootc compatibility
systemd-tmpfiles --create %{_tmpfilesdir}/cronie.conf 2>/dev/null || :
%post anacron
[ -e /var/spool/anacron/cron.daily ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.daily 2>/dev/null || :
[ -e /var/spool/anacron/cron.weekly ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.weekly 2>/dev/null || :
[ -e /var/spool/anacron/cron.monthly ] || install -m 0600 -D /dev/null /var/spool/anacron/cron.monthly 2>/dev/null || :
# create directories and files via tmpfiles.d for bootc compatibility
systemd-tmpfiles --create %{_tmpfilesdir}/cronie-anacron.conf 2>/dev/null || :
%preun
# run before a package is removed
@ -209,7 +214,6 @@ exit 0
%{_mandir}/man5/crontab.*
%{_mandir}/man1/crontab.*
%{_mandir}/man1/cronnext.*
%dir %{_localstatedir}/spool/cron
%dir %{_sysconfdir}/cron.d
%if %{with pam}
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/pam.d/crond
@ -218,23 +222,32 @@ exit 0
%config(noreplace,missingok) %{_sysconfdir}/cron.deny
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/0hourly
%attr(0644,root,root) /usr/lib/systemd/system/crond.service
%{_tmpfilesdir}/cronie.conf
%ghost %dir %attr(0700,root,root) %{_localstatedir}/spool/cron
%files anacron
%{_sbindir}/anacron
%attr(0755,root,root) %{_sysconfdir}/cron.hourly/0anacron
%config(noreplace) %{_sysconfdir}/anacrontab
%dir /var/spool/anacron
%ghost %dir %attr(0755,root,root) /var/spool/anacron
%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.daily
%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.weekly
%ghost %attr(0600,root,root) %verify(not md5 size mtime) /var/spool/anacron/cron.monthly
%{_mandir}/man5/anacrontab.*
%{_mandir}/man8/anacron.*
%{_tmpfilesdir}/cronie-anacron.conf
%files noanacron
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cron.d/dailyjobs
%changelog
* Wed Apr 14 2025 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.7-15
* Wed Dec 17 2025 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.7-16
- Forward XDG_SESSION_CLASS to PAM for session classification
- Also use systemd_tmpfiles to create files in /var, to ensure Cronie
- works properly in Image mode
- Resolves: RHEL-131190, RHEL-136491, RHEL-136492
* Wed May 14 2025 Ondřej Pohořelský <opohorel@redhat.com> - 1.5.7-15
- Move parsing code before separator check
- Related: RHEL-82795