Skip to content

Commit 1161152

Browse files
committed
Do not send mail for "sudo -nv" or "sudo -nl"
This avoids sending mail for users running "sudo -nv" or "sudo -nl" even when mail_badpass or mail_always are enabled. We already avoid logging in that case but mailing was not disabled when that change was made. Bug #1072.
1 parent 9d49f86 commit 1161152

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

plugins/sudoers/logging.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,15 +507,6 @@ log_auth_failure(const struct sudoers_context *ctx, unsigned int status,
507507
/* Do auditing first (audit_failure() handles the locale itself). */
508508
audit_failure(ctx, ctx->runas.argv, "%s", N_("authentication failure"));
509509

510-
if (ISSET(status, FLAG_NO_USER_INPUT)) {
511-
/* For "sudo -n", only log the entry if an actual command was run. */
512-
if (ISSET(ctx->mode, MODE_LIST|MODE_VALIDATE))
513-
logit = false;
514-
} else if (!ISSET(status, FLAG_BAD_PASSWORD)) {
515-
/* Authenticated OK, sudoers denials are logged separately. */
516-
logit = false;
517-
}
518-
519510
/*
520511
* Do we need to send mail?
521512
* We want to avoid sending multiple messages for the same command
@@ -536,6 +527,18 @@ log_auth_failure(const struct sudoers_context *ctx, unsigned int status,
536527
logit = false;
537528
}
538529

530+
/* Special case overrides for logging and mailing. */
531+
if (ISSET(status, FLAG_NO_USER_INPUT)) {
532+
/* For "sudo -n", only log the entry if an actual command was run. */
533+
if (ISSET(ctx->mode, MODE_LIST|MODE_VALIDATE)) {
534+
logit = false;
535+
mailit = false;
536+
}
537+
} else if (!ISSET(status, FLAG_BAD_PASSWORD)) {
538+
/* Authenticated OK, sudoers denials are logged separately. */
539+
logit = false;
540+
}
541+
539542
if (logit || mailit) {
540543
/* Log and mail messages should be in the sudoers locale. */
541544
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);

0 commit comments

Comments
 (0)