[PATCH] Print "This incident will be reported" message *if* mail will be sent.
[email protected] Fri, 18 Feb 2022 20:29:12 -0800
| Newsgroups | gmane.comp.tools.sudo.devel |
|---|---|
| Message-ID | <YhByGOJAHOLg4msP@kitty> |
From 2e5e9e192480de47a34a3f215a53c73de21720f6 Mon Sep 17 00:00:00 2001 From: 10maurycy10 <[email protected]> Date: Fri, 18 Feb 2022 10:58:53 -0800 Subject: [PATCH] Print "This incident will be reported" message *if* mail will be sent. Removing the message will ruin the classic meme, as show in https://xkcd.com/838/ The message was inaccurate if sudo was configured not to mail incident reports, However a few if statements can solve the problem. signed off by [email protected] --- plugins/sudoers/logging.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index 12a516ebb..1ed99ec9b 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -312,14 +312,26 @@ log_denial(int status, bool inform_user) sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale); if (ISSET(status, FLAG_NO_USER)) { - sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not in the sudoers " - "file.\n"), user_name); + if (mailit) + sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not in the sudoers " + "file. This incident will be reported.\n"), user_name); + else + sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not in the sudoers " + "file.\n"), user_name); } else if (ISSET(status, FLAG_NO_HOST)) { - sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not allowed to run sudo " - "on %s.\n"), user_name, user_srunhost); + if (mailit) + sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not allowed to run sudo " + "on %s. This incident will be reported/\n"), user_name, user_srunhost); + else + sudo_printf(SUDO_CONV_ERROR_MSG, _("%s is not allowed to run sudo " + "on %s.\n"), user_name, user_srunhost); } else if (ISSET(status, FLAG_NO_CHECK)) { - sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s may not run " - "sudo on %s.\n"), user_name, user_srunhost); + if (mailit) + sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s may not run " + "sudo on %s. This incident will be reported.\n"), user_name, user_srunhost); + else + sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s may not run " + "sudo on %s.\n"), user_name, user_srunhost); } else { sudo_printf(SUDO_CONV_ERROR_MSG, _("Sorry, user %s is not allowed " "to execute '%s%s%s' as %s%s%s on %s.\n"), -- 2.35.1 ____________________________________________________________ sudo-workers mailing list <[email protected]> For list information, options, or to unsubscribe, visit: https://www.sudo.ws/mailman/listinfo/sudo-workers