cron doesn't support MAILFROM

Bug #1750051 reported by Simon Déziel on 2018-02-16
70
This bug affects 12 people
Affects Status Importance Assigned to Milestone
cron (Debian)
New
Unknown
cron (Ubuntu)
Low
Unassigned

Bug Description

Ubuntu's cron version doesn't support setting MAILFROM to set the "From:" header of cron generated emails. This feature would be nice to have and bring parity with RHEL/CentOS which has it since RHEL 6:

$ cat /etc/redhat-release
CentOS release 6.6 (Final)

$ man 5 crontab | grep -1 FROM
       doesn´t do aliasing, and UUCP usually doesn´t read its mail. If MAIL-
       FROM is defined (and non-empty), it will be used as the envelope sender
       address, otherwise, ‘‘root’’ will be used.

$ apt-cache policy cron
cron:
  Installed: 3.0pl1-128ubuntu2
  Candidate: 3.0pl1-128ubuntu2
  Version table:
 *** 3.0pl1-128ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: cron 3.0pl1-128ubuntu2
ProcVersionSignature: Ubuntu 4.4.0-116.140-generic 4.4.98
Uname: Linux 4.4.0-116-generic x86_64
NonfreeKernelModules: zfs zunicode zcommon znvpair zavl
ApportVersion: 2.20.1-0ubuntu2.15
Architecture: amd64
CurrentDesktop: Unity
Date: Fri Feb 16 15:52:54 2018
InstallationDate: Installed on 2016-12-06 (436 days ago)
InstallationMedia: Ubuntu-Server 16.04.1 LTS "Xenial Xerus" - Beta amd64 (20161206)
SourcePackage: cron
UpgradeStatus: No upgrade log present (probably fresh install)

Simon Déziel (sdeziel) wrote :
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cron (Ubuntu):
status: New → Confirmed
tags: added: bionic
Changed in cron (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Low
niconil (laurent-combe) wrote :

submit a patch to add the feature.

Heavily inspired from cronie project :
https://github.com/cronie-crond/cronie/blob/master/src/do_command.c

The attachment "patch.txt" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Simon Déziel (sdeziel) wrote :

I looked at the patch (didn't test it) and I think the fprintf call is missing an argument to format as a string. It should read like this IMHO:

- fprintf(mail, "From: root (Cron Daemon)\n");
+ fprintf(mail, "From: %s\n", mailfrom);

niconil (laurent-combe) wrote :

you're right
only adding 6 lines and one bug inside :-(

new patch with the corrected line

niconil (laurent-combe) on 2018-05-08
Changed in cron (Debian):
importance: Undecided → Unknown
status: New → Unknown
Changed in cron (Debian):
status: Unknown → New
crash (crash369) wrote :

Another issue with this is that setting the "From:" header to "root (Cron daemon)" makes it difficult to forward this mail outside of the system. Many servers (like gmail) will bounce emails with an improper "From:" header.

Gordan Krešić (gordan-kresic) wrote :

It looks I accidentally changed status of this bug from "Triaged" to "Fix Released" (I clicked "fix released" in hope it will take me to the version in which it was fixed, but that wasn't a link, but an update action).

I'm not sure how I even could change status, since I'm not maintainer. I've tried, but I cannot revert this change.

Anyway, please somebody, revert status of tris to "Triaged".

Changed in cron (Ubuntu):
status: Triaged → Fix Released
niconil (laurent-combe) wrote :

to answer #7
if you set an improper value to MAILFROM ok
but if you give to From field a correct value there is no reason to not be forwarded

locally i've patched my cron deamon and there is no particular problem

Changed in cron (Ubuntu):
status: Fix Released → Triaged
elatllat (elatllat) wrote :

CentOS 8 is not out yet so Ubuntu 18.04 is the best LTS for servers at the moment ... except for bugs like this.

niconil (laurent-combe) wrote :

a bug report with a patch submitted and no news since one year ... what can we do to make it accepted more quickly ?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.