Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I understand correctly, when a user not in sudoers uses sudo, an email is sent out to root. Without any sort of mail program installed on my Arch machine, this wasn't doing anything, however. So I installed postfix, and made the following changes to the config file:

inet_interfaces = loopback-only
mynetworkstyle = host
home_mailbox = Maildir/

and appended the following line to /etc/postfix/aliases:

root:        anachrome

and ran sudo postalias /etc/postfix/aliases and started the postfix daemon. Next, I did a simple test with postfix' sendmail frontend:

/usr/sbin/sendmail root
(some generic test input)

and it worked as it should; the message appeared in anachrome's ~/Maildir/new/ directory. When I su'd into a user who was not in sudoers, and used a command (sudo visudo, if it matters), I got the standard this incident will be reported message. However, I found no new mail in my Maildir. Just to be sure, I put in sudoers the lines

Defaults mailerpath=/usr/sbin/sendmail
Defaults mailto="anachrome"    # in case it's a problem with forwarding
Defaults mail_always    # in case it's a problem with just not sending mail under that scenario

However, repeating my test (running sudo visudo as a user not in sudoers), I still did not receive any mail. What could be the source of this? Am I doing something wrong, or do I misunderstand how sudo reports incidents?

share|improve this question
    
Have you checked the Postfix log? –  grawity Nov 27 '11 at 19:50
    
Ah, right. Just did now, the message Nov 27 15:29:30 localhost postfix/sendmail[1736]: fatal: Recipient addresses must be specified on the command line or via the -t option shows up at the same time that sudo was called. I'd assume this means I have to specify '-t' in the 'mailerflags' sudoers default, but the manpage (of sudoers) says that '-t' is the default. I'll try anyways, though. –  Anachrome Nov 27 '11 at 20:34
    
Yep, that worked, though I'd like to know why mailerflags doesn't default to '-t' like, according to the manpage, it should. –  Anachrome Nov 27 '11 at 20:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.