From b613b536bec6b219c82697b79e43992254d202c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= Date: Wed, 14 Jan 2026 11:52:25 +0100 Subject: [PATCH] Fix MAILFROM envelope address handling Resolves: RHEL-140696 --- ...Revert-do-not-put-in-quotation-marks.patch | 34 +++++++++++++ 0002-Revert-set-the-return-path-hard-to.patch | 50 +++++++++++++++++++ ...velope-address-with-default-mailfrom.patch | 31 ++++++++++++ cronie.spec | 8 +++ 4 files changed, 123 insertions(+) create mode 100644 0001-Revert-do-not-put-in-quotation-marks.patch create mode 100644 0002-Revert-set-the-return-path-hard-to.patch create mode 100644 0003-Use-empty-envelope-address-with-default-mailfrom.patch diff --git a/0001-Revert-do-not-put-in-quotation-marks.patch b/0001-Revert-do-not-put-in-quotation-marks.patch new file mode 100644 index 0000000..6d65b0b --- /dev/null +++ b/0001-Revert-do-not-put-in-quotation-marks.patch @@ -0,0 +1,34 @@ +From 3428028e6df0a1e9b2efa1cb52b2722f790d9741 Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Thu, 16 Nov 2023 18:01:00 +0100 +Subject: [PATCH 1/3] Revert "do not put <> in quotation marks" + +This reverts commit a81bede998b510dadc79917b21e0a6dfbbc3436b. +--- + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 8858a6d..754b8c9 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -196,14 +196,14 @@ AC_DEFINE(DEBUGGING,1,[Code will be built with debug info.]) + + AC_DEFINE(MAILARG,"/usr/sbin/sendmail",[There will be path to sendmail.]) + +-AC_DEFINE(MAILFMT,"%s -FCronDaemon -i -odi -oem -oi -t -f <>", ++AC_DEFINE(MAILFMT,"%s -FCronDaemon -i -odi -oem -oi -t -f '<>'", + [-i = don't terminate on "." by itself + -Fx = Set full-name of sender + -odi = Option Deliverymode Interactive + -oem = Option Errors Mailedtosender + -oi = Ignore "." alone on a line + -t = Get recipient from headers +--f <> = Empty envelope sender address ++-f '<>' = Empty envelope sender address + -d = undocumented but common flag.]) + + AC_DEFINE(SYSLOG,1,[Using syslog for log messages.]) +-- +2.52.0 + diff --git a/0002-Revert-set-the-return-path-hard-to.patch b/0002-Revert-set-the-return-path-hard-to.patch new file mode 100644 index 0000000..5b1cc29 --- /dev/null +++ b/0002-Revert-set-the-return-path-hard-to.patch @@ -0,0 +1,50 @@ +From 4e8c767efb1bea03da465fee29641b65da1246eb Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Thu, 16 Nov 2023 18:01:12 +0100 +Subject: [PATCH 2/3] Revert "set the return-path hard to "<>"" + +This reverts commit d5d7db6a42f8c3ae6f6bd1efc767ae3fe97f4734. + +This is problematic in some use-cases. It needs to be optional. +--- + configure.ac | 4 ++-- + src/do_command.c | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 754b8c9..17fa357 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -196,14 +196,14 @@ AC_DEFINE(DEBUGGING,1,[Code will be built with debug info.]) + + AC_DEFINE(MAILARG,"/usr/sbin/sendmail",[There will be path to sendmail.]) + +-AC_DEFINE(MAILFMT,"%s -FCronDaemon -i -odi -oem -oi -t -f '<>'", ++AC_DEFINE(MAILFMT,"%s -FCronDaemon -i -odi -oem -oi -t -f %s", + [-i = don't terminate on "." by itself + -Fx = Set full-name of sender + -odi = Option Deliverymode Interactive + -oem = Option Errors Mailedtosender + -oi = Ignore "." alone on a line + -t = Get recipient from headers +--f '<>' = Empty envelope sender address ++-f %s = Envelope sender address + -d = undocumented but common flag.]) + + AC_DEFINE(SYSLOG,1,[Using syslog for log messages.]) +diff --git a/src/do_command.c b/src/do_command.c +index 665e1f0..8226a69 100644 +--- a/src/do_command.c ++++ b/src/do_command.c +@@ -471,7 +471,7 @@ static int child_process(entry * e, char **jobenv) { + if (MailCmd[0] == '\0') { + int len; + +- len = snprintf(mailcmd, sizeof mailcmd, MAILFMT, MAILARG); ++ len = snprintf(mailcmd, sizeof mailcmd, MAILFMT, MAILARG, mailfrom); + if (len < 0) { + fprintf(stderr, "mailcmd snprintf failed\n"); + (void) _exit(ERROR_EXIT); +-- +2.52.0 + diff --git a/0003-Use-empty-envelope-address-with-default-mailfrom.patch b/0003-Use-empty-envelope-address-with-default-mailfrom.patch new file mode 100644 index 0000000..f4b2172 --- /dev/null +++ b/0003-Use-empty-envelope-address-with-default-mailfrom.patch @@ -0,0 +1,31 @@ +From c640f4f39e5c20995e960e4b954cd0574a96c028 Mon Sep 17 00:00:00 2001 +From: Tomas Mraz +Date: Thu, 16 Nov 2023 18:12:12 +0100 +Subject: [PATCH 3/3] Use empty envelope address with default mailfrom + +This should still reasonably fix the issue resolved in +https://github.com/cronie-crond/cronie/pull/118 +But it would provide normal envelope address if +MAILFROM is explicitly set. +--- + src/do_command.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/do_command.c b/src/do_command.c +index 8226a69..d7ca840 100644 +--- a/src/do_command.c ++++ b/src/do_command.c +@@ -471,7 +471,9 @@ static int child_process(entry * e, char **jobenv) { + if (MailCmd[0] == '\0') { + int len; + +- len = snprintf(mailcmd, sizeof mailcmd, MAILFMT, MAILARG, mailfrom); ++ /* Use empty envelope address with default mailfrom */ ++ len = snprintf(mailcmd, sizeof mailcmd, MAILFMT, MAILARG, ++ mailfrom == e->pwd->pw_name ? "<>" : mailfrom); + if (len < 0) { + fprintf(stderr, "mailcmd snprintf failed\n"); + (void) _exit(ERROR_EXIT); +-- +2.52.0 + diff --git a/cronie.spec b/cronie.spec index fbe140b..8c711a3 100644 --- a/cronie.spec +++ b/cronie.spec @@ -33,6 +33,13 @@ Patch: 0001-crontab-Fix-backup-failure-when-cache-directory-mis.patch # https://github.com/cronie-crond/cronie/pull/210 Patch: forward-XDG_SESSION_CLASS-to-PAM-for-session-classification.patch +# https://github.com/cronie-crond/cronie/issues/166 +# two of these patches touched configure.ac, so we need 'automake'as a BuildRequires +# it is safe to remove it once these patches are part of the upstream release +Patch: 0001-Revert-do-not-put-in-quotation-marks.patch +Patch: 0002-Revert-set-the-return-path-hard-to.patch +Patch: 0003-Use-empty-envelope-address-with-default-mailfrom.patch + Requires: dailyjobs %if %{with selinux} @@ -50,6 +57,7 @@ Buildrequires: audit-libs-devel >= 1.4.1 BuildRequires: gcc BuildRequires: systemd BuildRequires: make +BuildRequires: automake Obsoletes: %{name}-sysvinit Requires(post): coreutils sed