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.

I have added the below lines to /etc/sudoers.d/my_sudoers

Defaults    mail_always
Defaults    mailto="email@domain.com"

I get an email every time sudo is run

How can i modify this so I only receive emails when particular people run sudo (Everybody except 2 users)

Thanks

share|improve this question

migrated from stackoverflow.com Apr 12 '13 at 0:55

This question came from our site for professional and enthusiast programmers.

3 Answers 3

I'm not to sure on the syntax but wouldn't creating an if statement help SUDO if (name = NAME1, NAME2,) { do nothing } else { email }

share|improve this answer

Assuming that only the two users exist in the sudoers file, the following will achieve what you want:

Defaults mailto="email@domain.com", mail_no_user

Otherwise, you'll probably need to resort to filtering your emails.

share|improve this answer
    
This didn't work. There must be another option without filtering emails. –  ubuntu101010101 Apr 11 '13 at 12:27
    
I didn't realize that mail_no_user is on by default. –  devnull Apr 11 '13 at 12:32

This is straightforward; Defaults can apply to specific users (and other limitations), and user aliases can be constructed with negated matches. Something along these lines:

User_Alias NoMail = goodboy, goodgirl
User_Alias MailUsers = ALL, !NoMail

Defaults           mailto="omgsudo@example.com"
Defaults:MailUsers mail_always
Defaults:NoMail    !mail_badpass
share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.