Description of problem: logwatch ignores anacron setting of mailto, which can prevent log analysis from being delivered where it is needed. Version-Release number of selected component (if applicable): logwatch-7.3-5 Note this also affects earlier versions too. How reproducible: Always. Steps to Reproduce: 1. in /etc/anacrontab set MAILTO=yourUname 2. get anacron to run logwatch again (cron.daily to be ran) anacron -d -t /tmp/anacrontab -f -n Actual results: Mail is sent to the root user. Expected results: Mail is sent to the address defined in the /etc/anacrontab MAILTO variable. Additional info: $ ls /tmp/t.daily/ -l lrwxrwxrwx ... 0logwatch -> /usr/share/logwatch/scripts/logwatch.pl the following patch works for me, though it may not be the cleanest method. --- logwatch-7.3/scripts/logwatch.pl.orig 2007-04-16 13:10:55.000000000 -0500 +++ logwatch-7.3/scripts/logwatch.pl 2007-04-16 14:26:34.000000000 -0500 @@ -306,6 +306,13 @@ CleanVars(); +#if MAILTO is set in the environment, grab it as we may be being used by +#cron or anacron, which do not set command line args. +if ($ENV{'MAILTO'}) + { + $Config{'mailto'} = $ENV{'MAILTO'}; + } + if ($OldMailTo ne $Config{'mailto'}) { $Config{'print'} = 0; } elsif ($OldPrint ne $Config{'print'}) {
Created attachment 152713 [details] a testing anacrontab to be used as /tmp/anacrontab in the desription.
Fixed in logwatch-7.3.4-7.fc7.
I'm not sure the "expected results" in comment #0 are expected at all. I expect *non-error* output to be mailed to wherever is configured in logwatch.conf. And I expect that to be root by default -- then, the root alias should be defined as going somewhere useful in /etc/aliases. I would expect cron error output to be sent to the MAILTO address, though.
Re: comment #3 I also expected logwatch.conf to be the place to get the value into logwatch's system after finding that it was by default ignoring the environment variable, however all the manipulations of /etc/logwatch/conf/[logwatch.conf|override.conf] failed to get logwatch to use the value set in MAILTO. FYI the last mods I made to logwatch.conf was to put the following line in: MailTo="$ENV{'MAILTO'}" I had tried many variations on this line, all were ignored by logwatch. The reason the expected results are different from the actual is (I conjecture) that when logwatch was written, it was done as a tool ment to be ran from the command line by hand or the original cron instead of from anacron. The portion of least supprise that is/was violated by logwatch is that when anything is ran from anacron, unless that program is told explicitly otherwise in it's config file, the output should be sent to the location anacron has been told to send it, i.e., MAILTO, or if MAILTO is notset to the default user cron/anacron is running as. The reason that /etc/aliases is not a usefull suggestion, is if /etc/mail/submit.mc has been set up with masquerade_envelope & masquerade_entire_domain (required for my location), the 'root' user is no longer processed localy (.forward or /etc/aliases processed) even with LOCAL_USER(root) set in submit.mc (under FC4). Although this may be a problem with sendmail's processing of submit.cf, the workaround for a cron job that had no other explicit configuration should have been as simple as setting the MAILTO variable for ALL cron jobs controled by that [ana]crontab.
Oh, I see. Do you have "Print=No" set in logwatch.conf?
No, except for the testing line for MailTo, my logwatch.conf was as delivered from fedora [one comment line].
Some versions (not sure exactly when it started) have "Print=Yes" by default, which causes the output to go to stdout rather than being sent to the MailTo address. Make sure it's set to No. (see bug #247611)