mclarkson/nagrestconf

Permissons for /var/mail/

Closed this issue · 8 comments

Hi,

please check the permission of /var/mail, it's now:

rwxrwsr-x root:root

So all mails to root generate permission-denied-errors

I think it should be:

rwxrwsr-x root:mail
^^^^^
What do you think?

After changing permission root-mails could be saved in /var/mail/mail

One more question: I think its better to send these mails to a real email-address, because nobody will check /var/mail/mail. Do you have an idea how to do this?
/etc/aliases didn't work, because your exim don't send mail to external addresses.

Best Regards,

Thomas Rosin

Hi Thomas,
Synology changed the way tars are unpacked, so user and group aren't preserved, and I missed that one, so thanks for reporting it. It will be correct in the next build, 0.14.3

I did a blog post about enablilng email alerts here:
http://blogger.smorg.co.uk/2014/02/enabling-synagios-email-alerts.html

There's more information that might help in the comments on that page.

It doesn't use exim or mailx etc. There's a dumb binary, mailsender, that should be used. It's so dumb that it mostly always works without any extra configuration.

Buuut, the mailsender binary needs to be replaced for x86 (not arm afaik), or wait for 0.14.3, if you're using DSM 6. The new mailsender binary is in the download area at: https://sourceforge.net/projects/nagrestconf/files/Synology/x86/

You're right, nagios use /usr/local/bin/mailsender, but ...

... maybe my DSM has the name "mynas".
Some of your default nagios-checks for DSM tried to resolve the ip-address of the DSM-hostname ("mynas"). I'm not sure which one it is. In the DSM conext the name is resolved via /etc/hosts, but in your nagios chroot conext your /etc/hosts has no information about the hostname of my nas:

127.0.0.1   localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

Result: The user "nagios@jessie01" sends an error-message to "root@jessie01". The local mail-server (which one?), tried to save this mail via router "mail4root" to /var/mail/mail. You can find these informations in chroot:/var/log/exim4/main.log".

After correction of the permission /var/mail all these error-mails are saved in chroot:/var/mail/mail.

I add "mynas x.x.x.x" to /etc/hosts and "order hosts,bind" to /etc/host.conf. After this, there are no mire error mails about dns problems.

I hope I have explained it understandable. Please ask, if I can give you more information.

Best Regards,

Thomas Rosin

Thanks for having a good dig into this problem and I can confirm that I see the same thing.

It's sudo that emits the error email, and one nagios plugin, check_logfiles, is run with sudo.

Exim is installed in the chroot but the server is never started. I guess sudo is trying to use sendmail (which is symlinked to exim4) to send the error messages, like cron does. When exim4 couldn't deliver, due to the permission error, it put the messages in the retry queue producing the log messages you saw. This retry queue will never be serviced since the exim server isn't started.

I'm glad you found this bug! I had a huge mailq that I delivered with:

exim -bp | awk '{ print $3 }' | xargs exim -M

Then truncated the /var/mail/mail file. I have implemented your fix, which should stop this problem happening and it will be in 0.14.3. Might need a cron job to clean out old mail in /var/mail/mail at some point though, although it should only grow by MB rather than GB.

I have released a new Synagios, 0.14.3, with the above fixes. Thanks again!

Thanks for your fast support and the new version. ;-)
I'm glad that there is nagrestconf.

Me too! It makes life a lot easier for me :)
I'll close this ticket then.