Scenario: personal system with a few cron jobs that might send email (as cronjobs are often want to do). I want such email to show up in my normal email account at my ISP, but they require authentication (login/password) to send email. My normal email client works fine (it is easy to configure), but how do I get cron (in my case it's vixie-cron) to send the email?
As described in previous postings in this thread, using the combo of ssmtp and mailwrap you can pass a username and password to the remote MTA by modifying /etc/mail/mailer.conf. Unfortunately, this file is world readable because it is read by mailwrap (/usr/sbin/sendmail) and because mailwrap is running with an effective uid of potentially any user.
My solution to this world readable file was to make it not world readable and to make mailwrap setgid.
I added a new group to /etc/group:
I then put both /usr/sbin/sendmail and /etc/mail/mailer.conf in that group:
Code: Select all
# chgrp mailwrap /usr/sbin/sendmail /etc/mail/mailer.conf
Finally, I adjusted the permissions on /usr/sbin/sendmail and /etc/mail/mailer.conf:
Code: Select all
# chmod g+s /usr/sbin/sendmail
# chmod 640 /etc/mail/mailer.conf
Cron and other apps can still send email by feeding them into /usr/lib/sendmail, but users cannot see the login/password info in /etc/mail/mailer.conf.
Is this perfect? No. For one thing, my login and password are on the command line for ssmtp where they can be seen by ps(1). This may also interfere with mail clients which invoke sendmail for delivery and want to pass their own -au and -ap parameters. But for a single user system with a mail client like mozilla or thunderbird (or any with a built in smtp capabilities) it might work.
YMMV,
-- William
PS. You'll need to edit /etc/ssmtp/ssmtp.conf for some basic ssmtp configuration. The comments help you do it. To test, create a file named "test.msg" with something like this:
And pipe that into sendmail like so (as a normal user):
Code: Select all
% cat test.msg | /usr/lib/sendmail myemail@my.isp
Of course, replace "
myemail@my.isp" with your real email address. -- WPR