Red Hat Bugzilla – Bug 844379
Junk included in cron job output
Last modified: 2012-08-01 11:01:16 EDT
Created attachment 601257 [details]
Email received when I run "crontest.sh" from cron
Description of problem:
I have a cron job that runs once a day to identify and purge some duplicate files. It emits one line to stdout per file it deletes. The output mailed to me by cron preiodically includes lumps of binary data.
To test, I created a much simpler job that simply echo's a couple of hundred lines of text. This works as expected as long as there is no delay between the lines being echo'd. If I include a usleep 100000 between each line, I get the same binary junk included as in my real job's output.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Schedule a job with cron that outputs a reasonable amount to stdout, with delays between each line. I used the following "crontest.sh":
for l in `seq -w 1 $limit`; do
echo "This is line number $l of $limit ... Something fox, something dog."
2. Receive bad output by mail.
(Mail received from the script above attached).
The 58th line output includes a null byte part way through (in place of the "o" in "of 200") and is followed by a block of binary data after which the 58th line completes from the "o" that was mangled earlier and normal output resumes.
Line 121 of the output next shows the same corruption (but one character further in). And again at line 184.
Unmangled lines of text in the output mailed by cron.
The binary data includes a small number of tantalising strings: "Linux", "seshat.verelanthe.lan" (the machine's hostname), and "3.4.6-2.fc17.x86_64" (the version of the running kernel).
Running the test script and piping its output into mail does not show any problems.
Sorry, forgot to mention: this seems to affect (at least) Fedora 15, 16 and 17. I see this behaviour on my F16 and F17 boxes at the moment (the F15 box was upgraded before I'd got around to filing the bug report).
Done some more testing. I'm only able to reproduce the problem if mail is moved off the machine with ssmtp.
Piping the output of my test script to sendmail (i.e. ssmtp) does not show the problem, I still only see it if the script is run by cron.
Any suggestions on how to identify if this is a bug with cron, or ssmtp?
I don't think it's a problem of cron. Cronie is just doing what you want. It calls exec on your script. You can try different sendmail utility if it's a problem for all.
OK; looks like this is an ssmtp bug.
I just tried using using a simple "dump stdin to a file" replacement for the mail command and what I'm seeing is that cron is sending the job's output to the mail program in blocks that correspond to the intact portions of the corrupt emails. I.e. the corruption I see in the mail coincides with the pause between the blocks of output piped to ssmtp (as sendmail).
If I pipe the same output as cron creates through sendmail (i.e. ssmtp) with a delay at the same point, I get corruption in the same way.
Will file a fresh bug against ssmtp.