Created attachment 966217 [details]
patch to ensure that the $PKTMP file is not attempted to be sent by mail if the files is empty
Description of problem:
When setting MAILTO recipients in /etc/sysconfig/packagekit-background /etc/cron.daily/packagekit-background will only check for the return value from the pkcon command before trying to send email reports. In the case that the pkcon has not output any message(s) to the temporary file named by $PKTMP in the script, the mail command is invoked trying to send a null message body as a report. Anacron will also send a mail with the warning from the mail command, "
Null message body; hope that's ok".
In short, if MAILTO is set in /etc/sysconfig/packagekit-background and if pkcon returns anything else but return value 5 (nothing useful done) and at the same time does not output any warnings or error messages, two unneccessary emails are sent.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Set MAILTO in /etc/sysconfig/packagekit-background
3. Two emails are sent, from /etc/cron.daily/packagekit-background and anacron. None of these carry any useful information.
Useless unneccessary emails are sent
Only email with useful info should be sent from /etc/cron.daily/packagekit-background.cron
patch to use bash built-in test -s to check if $PKTMP actually contains information:
--- /etc/cron.daily/packagekit-background.cron 2014-05-20 15:31:02.000000000 +0200
+++ /etc/cron.daily/packagekit-background.cron.fix 2014-12-09 13:13:48.067878542 +0100
@@ -36,13 +36,16 @@
# this is when seomthing useful was done
if [ $PKCON_RETVAL -ne 5 ]; then
+ # Do we actually have something to report? Is $PKTMP non-empty?
+ if [ -s $PKTMP ]; then
# send email
if [ -n "$MAILTO" ]; then
- mail -s "System updates available: $SYSTEMNAME" $MAILTO < $PKTMP
+ mail -s "System updates available: $SYSTEMNAME" $MAILTO < $PKTMP
# default behavior is to use cron's internal mailing of output from cron-script
- cat $PKTMP
+ cat $PKTMP
Seems logical enough to me.
I found and filled new similar bug: https://bugzilla.redhat.com/show_bug.cgi?id=1206196
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.