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?
Nov 27 15:29:30 localhost postfix/sendmail[1736]: fatal: Recipient addresses must be specified on the command line or via the -t optionshows up at the same time thatsudowas called. I'd assume this means I have to specify '-t' in the 'mailerflags'sudoersdefault, but the manpage (ofsudoers) says that '-t' is the default. I'll try anyways, though. – Anachrome Nov 27 '11 at 20:34mailerflagsdoesn't default to '-t' like, according to the manpage, it should. – Anachrome Nov 27 '11 at 20:37