2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-29 13:28:10 +00:00

Don't send mail about pseudo-command failure unless it is an

authentication failure.
This commit is contained in:
Todd C. Miller 2015-02-02 15:01:06 -07:00
parent dfb369198a
commit ed4ffa6265
5 changed files with 68 additions and 22 deletions

3
NEWS
View File

@ -61,6 +61,9 @@ What's new in Sudo 1.8.12
`+' prefix and checking whether the user is a member of any of `+' prefix and checking whether the user is a member of any of
the returned netgroups. the returned netgroups.
* The mail_always sudoers option no longer sends mail for "sudo -l"
or "sudo -v" unless the user is unable to authenticate themselves.
What's new in Sudo 1.8.11p2 What's new in Sudo 1.8.11p2
* Fixed a bug where dynamic shared objects loaded from a plugin * Fixed a bug where dynamic shared objects loaded from a plugin

View File

@ -75,9 +75,12 @@ DDEESSCCRRIIPPTTIIOONN
mail is configurable via the _m_a_i_l_t_o Defaults entry (described later) and mail is configurable via the _m_a_i_l_t_o Defaults entry (described later) and
defaults to root. defaults to root.
Note that mail will not be sent if an unauthorized user tries to run ssuuddoo Note that no mail will be sent if an unauthorized user tries to run ssuuddoo
with the --ll or --vv option. This allows users to determine for themselves with the --ll or --vv option unless there is an authentication error and
whether or not they are allowed to use ssuuddoo. either the _m_a_i_l___a_l_w_a_y_s or _m_a_i_l___b_a_d_p_a_s_s flags are enabled. This allows
users to determine for themselves whether or not they are allowed to use
ssuuddoo. All attempts to run ssuuddoo (successful or not) will be logged,
regardless of whether or not mail is sent.
If ssuuddoo is run by root and the SUDO_USER environment variable is set, the If ssuuddoo is run by root and the SUDO_USER environment variable is set, the
_s_u_d_o_e_r_s policy will use this value to determine who the actual user is. _s_u_d_o_e_r_s policy will use this value to determine who the actual user is.
@ -174,7 +177,7 @@ DDEESSCCRRIIPPTTIIOONN
_e_n_v___r_e_s_e_t. The DISPLAY, PATH and TERM variables remain unchanged; HOME, _e_n_v___r_e_s_e_t. The DISPLAY, PATH and TERM variables remain unchanged; HOME,
MAIL, SHELL, USER, and LOGNAME are set based on the target user. On AIX MAIL, SHELL, USER, and LOGNAME are set based on the target user. On AIX
(and Linux systems without PAM), the contents of _/_e_t_c_/_e_n_v_i_r_o_n_m_e_n_t are (and Linux systems without PAM), the contents of _/_e_t_c_/_e_n_v_i_r_o_n_m_e_n_t are
also included. On BSD systems, if the _u_s_e___l_o_g_i_n_c_l_a_s_s option is enabled, also included. On BSD systems, if the _u_s_e___l_o_g_i_n_c_l_a_s_s flag is enabled,
the _p_a_t_h and _s_e_t_e_n_v variables in _/_e_t_c_/_l_o_g_i_n_._c_o_n_f are also applied. All the _p_a_t_h and _s_e_t_e_n_v variables in _/_e_t_c_/_l_o_g_i_n_._c_o_n_f are also applied. All
other environment variables are removed. other environment variables are removed.
@ -1047,8 +1050,12 @@ SSUUDDOOEERRSS OOPPTTIIOONNSS
some people find it more convenient. This flag is _o_f_f some people find it more convenient. This flag is _o_f_f
by default. by default.
mail_always Send mail to the _m_a_i_l_t_o user every time a user runs mail_always Send mail to the _m_a_i_l_t_o user every time a user attempts
ssuuddoo. This flag is _o_f_f by default. to run a command via ssuuddoo. Mail will be sent for both
successful and unsuccessful attempts. No mail will be
sent if the user runs ssuuddoo with the --ll or --vv option
unless there is an authentication error. This flag is
_o_f_f by default.
mail_badpass Send mail to the _m_a_i_l_t_o user if the user running ssuuddoo mail_badpass Send mail to the _m_a_i_l_t_o user if the user running ssuuddoo
does not enter the correct password. If the command does not enter the correct password. If the command
@ -2356,4 +2363,4 @@ DDIISSCCLLAAIIMMEERR
file distributed with ssuuddoo or http://www.sudo.ws/license.html for file distributed with ssuuddoo or http://www.sudo.ws/license.html for
complete details. complete details.
Sudo 1.8.12 December 4, 2014 Sudo 1.8.12 Sudo 1.8.12 January 21, 2015 Sudo 1.8.12

View File

@ -1,7 +1,7 @@
.\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER! .\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!
.\" IT IS GENERATED AUTOMATICALLY FROM sudoers.mdoc.in .\" IT IS GENERATED AUTOMATICALLY FROM sudoers.mdoc.in
.\" .\"
.\" Copyright (c) 1994-1996, 1998-2005, 2007-2014 .\" Copyright (c) 1994-1996, 1998-2005, 2007-2015
.\" Todd C. Miller <Todd.Miller@courtesan.com> .\" Todd C. Miller <Todd.Miller@courtesan.com>
.\" .\"
.\" Permission to use, copy, modify, and distribute this software for any .\" Permission to use, copy, modify, and distribute this software for any
@ -21,7 +21,7 @@
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\" .\"
.TH "SUDOERS" "5" "December 4, 2014" "Sudo @PACKAGE_VERSION@" "File Formats Manual" .TH "SUDOERS" "5" "January 21, 2015" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
.nh .nh
.if n .ad l .if n .ad l
.SH "NAME" .SH "NAME"
@ -172,17 +172,25 @@ Defaults entry
(described later) and defaults to (described later) and defaults to
\fR@mailto@\fR. \fR@mailto@\fR.
.PP .PP
Note that mail will not be sent if an unauthorized user tries to Note that no mail will be sent if an unauthorized user tries to run
run
\fBsudo\fR \fBsudo\fR
with the with the
\fB\-l\fR \fB\-l\fR
or or
\fB\-v\fR \fB\-v\fR
option. option unless there is an authentication error and
either the
\fImail_always\fR
or
\fImail_badpass\fR
flags are enabled.
This allows users to This allows users to
determine for themselves whether or not they are allowed to use determine for themselves whether or not they are allowed to use
\fBsudo\fR. \fBsudo\fR.
All attempts to run
\fBsudo\fR
(successful or not)
will be logged, regardless of whether or not mail is sent.
.PP .PP
If If
\fBsudo\fR \fBsudo\fR
@ -440,7 +448,7 @@ are also
included. included.
On BSD systems, if the On BSD systems, if the
\fIuse_loginclass\fR \fIuse_loginclass\fR
option is flag is
enabled, the enabled, the
\fIpath\fR \fIpath\fR
and and
@ -2218,8 +2226,16 @@ by default.
mail_always mail_always
Send mail to the Send mail to the
\fImailto\fR \fImailto\fR
user every time a user runs user every time a user attempts to run a command via
\fBsudo\fR. \fBsudo\fR.
Mail will be sent for both successful and unsuccessful attempts.
No mail will be sent if the user runs
\fBsudo\fR
with the
\fB\-l\fR
or
\fB\-v\fR
option unless there is an authentication error.
This flag is This flag is
\fIoff\fR \fIoff\fR
by default. by default.

View File

@ -1,5 +1,5 @@
.\" .\"
.\" Copyright (c) 1994-1996, 1998-2005, 2007-2014 .\" Copyright (c) 1994-1996, 1998-2005, 2007-2015
.\" Todd C. Miller <Todd.Miller@courtesan.com> .\" Todd C. Miller <Todd.Miller@courtesan.com>
.\" .\"
.\" Permission to use, copy, modify, and distribute this software for any .\" Permission to use, copy, modify, and distribute this software for any
@ -19,7 +19,7 @@
.\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
.\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
.\" .\"
.Dd December 4, 2014 .Dd January 21, 2015
.Dt SUDOERS @mansectform@ .Dt SUDOERS @mansectform@
.Os Sudo @PACKAGE_VERSION@ .Os Sudo @PACKAGE_VERSION@
.Sh NAME .Sh NAME
@ -160,17 +160,25 @@ Defaults entry
(described later) and defaults to (described later) and defaults to
.Li @mailto@ . .Li @mailto@ .
.Pp .Pp
Note that mail will not be sent if an unauthorized user tries to Note that no mail will be sent if an unauthorized user tries to run
run
.Nm sudo .Nm sudo
with the with the
.Fl l .Fl l
or or
.Fl v .Fl v
option. option unless there is an authentication error and
either the
.Em mail_always
or
.Em mail_badpass
flags are enabled.
This allows users to This allows users to
determine for themselves whether or not they are allowed to use determine for themselves whether or not they are allowed to use
.Nm sudo . .Nm sudo .
All attempts to run
.Nm sudo
(successful or not)
will be logged, regardless of whether or not mail is sent.
.Pp .Pp
If If
.Nm sudo .Nm sudo
@ -426,7 +434,7 @@ are also
included. included.
On BSD systems, if the On BSD systems, if the
.Em use_loginclass .Em use_loginclass
option is flag is
enabled, the enabled, the
.Em path .Em path
and and
@ -2075,8 +2083,16 @@ by default.
.It mail_always .It mail_always
Send mail to the Send mail to the
.Em mailto .Em mailto
user every time a user runs user every time a user attempts to run a command via
.Nm sudo . .Nm sudo .
Mail will be sent for both successful and unsuccessful attempts.
No mail will be sent if the user runs
.Nm sudo
with the
.Fl l
or
.Fl v
option unless there is an authentication error.
This flag is This flag is
.Em off .Em off
by default. by default.

View File

@ -364,7 +364,7 @@ log_auth_failure(int status, unsigned int tries)
SET(flags, SLOG_SEND_MAIL); SET(flags, SLOG_SEND_MAIL);
} else { } else {
/* Command denied, auth failed; make sure we don't send mail twice. */ /* Command denied, auth failed; make sure we don't send mail twice. */
if (def_mail_badpass && !should_mail(status)) if ((def_mail_badpass || def_mail_always) && !should_mail(status))
SET(flags, SLOG_SEND_MAIL); SET(flags, SLOG_SEND_MAIL);
/* Don't log the bad password message, we'll log a denial instead. */ /* Don't log the bad password message, we'll log a denial instead. */
SET(flags, SLOG_NO_LOG); SET(flags, SLOG_NO_LOG);
@ -756,6 +756,10 @@ should_mail(int status)
{ {
debug_decl(should_mail, SUDOERS_DEBUG_LOGGING) debug_decl(should_mail, SUDOERS_DEBUG_LOGGING)
/* Never send mail about the "sudo -l" and "sudo -v" pseudo-commands. */
if (ISSET(sudo_mode, (MODE_VALIDATE|MODE_CHECK|MODE_LIST)))
debug_return_bool(false);
debug_return_bool(def_mail_always || debug_return_bool(def_mail_always ||
(def_mail_no_user && ISSET(status, FLAG_NO_USER)) || (def_mail_no_user && ISSET(status, FLAG_NO_USER)) ||
(def_mail_no_host && ISSET(status, FLAG_NO_HOST)) || (def_mail_no_host && ISSET(status, FLAG_NO_HOST)) ||