Previously, when MAILTO recipients were set in the /etc/sysconfig/packagekit-background file, the /etc/cron.daily/packagekit-background.cron script only checked for the return value from the pkcon command before trying to send email reports. As a consequence, two unnecessary empty emails were sent under certain circumstances. With this update, the $PKTMP file is not attempted to be sent by email if the files is empty, and only emails with useful information are now sent in the described scenario.
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):
PackageKit-cron-0.5.8-23.el6.x86_64
How reproducible:
Daily.
Steps to Reproduce:
1. Set MAILTO in /etc/sysconfig/packagekit-background
2. Wait
3. Two emails are sent, from /etc/cron.daily/packagekit-background and anacron. None of these carry any useful information.
Actual results:
Useless unneccessary emails are sent
Expected results:
Only email with useful info should be sent from /etc/cron.daily/packagekit-background.cron
Additional info:
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
else
# default behavior is to use cron's internal mailing of output from cron-script
- cat $PKTMP
+ cat $PKTMP
fi
+ fi
fi
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.
https://rhn.redhat.com/errata/RHBA-2015-1352.html
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): PackageKit-cron-0.5.8-23.el6.x86_64 How reproducible: Daily. Steps to Reproduce: 1. Set MAILTO in /etc/sysconfig/packagekit-background 2. Wait 3. Two emails are sent, from /etc/cron.daily/packagekit-background and anacron. None of these carry any useful information. Actual results: Useless unneccessary emails are sent Expected results: Only email with useful info should be sent from /etc/cron.daily/packagekit-background.cron Additional info: 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 else # default behavior is to use cron's internal mailing of output from cron-script - cat $PKTMP + cat $PKTMP fi + fi fi