Description of problem: The code added to logwatch.pl #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'}; } overrides any mailto setting in the /etc/logwatch/conf/logwatch.conf file and because the default cron config sets mailto to root, this forces all emails to go to root regardless of the logwatch.conf setting. Version-Release number of selected component (if applicable): logwatch-7.3.4-9.fc7.noarch.rpm How reproducible: every time Steps to Reproduce: 1. add MailTo = USER to /etc/logwatch/conf/logwatch.conf 2. execute /usr/sbin/logwatch 3. report is emailed to USER given in step 1. 4. wait for cron to run logwatch, report is emailed to root Actual results: report emailed to root Expected results: report emailed to user specified in conf file Additional info: solution is to move this code up above where the config files are read in. It will override the default mailto but not the configuration files mailto, which would seem to be more expected behavior.
This is not logwatch bug - the mail is sent by cron so the addressee itself so there is no way for logwatch to change it.
Cron is running logwatch from cron.daily, which is run from /etc/crontab. Here is defined the enviroment. Cron is overriding the settings of individual programs. Usually is the receiver of root mails set in /etc/aliases, which I recommend. Did this setting solve your problem?
The point is that I want logwatch output mailed to a different address while cron output and the rest of root's mail goes to root. This should be configurable in the /etc/logwatch/conf/logwatch.conf file, but as explained below the modification involving the piece of code above is stopping this and this is a change from previous behavior. The piece of code above, which appears to have been added to logwatch.pl by the rpm packager (It's not in the source for logwatch from their site) imports the MAILTO environment setting that is set in /etc/crontab. The location of the piece of code in logwatch.pl is after all logwatch configuration files have been read in, thus it overrides them. So the setting of MAILTO from /etc/crontab overrides any setting in /etc/logwatch/conf/logwatch.conf. /etc/crontab has MAILTO=root in it as supplied with the cron rpm. Thus with this setup, there is no way to individually have logwatch output mailed to an address in the logwatch.conf file without removing the MAILTO line entirely from /etc/crontab (if this then makes MAILTO undefined in the cron environment, which I have not checked). I can see the idea behind this patch. Change the MAILTO in the /etc/crontab and all cron output (including logwatch output) does to the same place. But this should not override configuration for logwatch if it is set to mail somewhere else. And because MAILTO is by default set in /etc/crontab it will always do so, making any attempt to set a mail recipient in a logwatch.conf file futile. I don't think this is expected behavior. You need to pass this on to whoever put together the logwatch rpm and added the code above (I'm assuming they are the same person). This change appeared the rpm version listed above. It is not in the previous version. Prior to this rpm version logwatch.conf controlled where logwatch output was mailed when it was run from /etc/crontab. I hope this explains the issue better. Thanks, Tom
This has been fixed in logwatch-7.3.4-10.fc7, the piece of code listed above was moved to before where the configuration files are read and thus it no longer overrides the configuration file settings. You can mark this bug as resolved. Tom