Can I customize the sudo "this incident will be reported" message?

From Sudoers Manual below is the only message you are allowed to configure with the sudo conf.

badpass_message="Sorry, try again."

However to answer your question you are more than welcome to compile your own copy of sudo.

This would be the message you are getting.


In some sense this message is already customisable because, as for many parts of GNU/Linux, sudo is internationalised and uses gettext Native Language Support to look up most strings to replace them by a locale version in a different language.

For example, you can see the French language file here which has entries:

msgid "%s is not in the sudoers file.  This incident will be reported.\n"
msgstr "%s n'apparaît pas dans le fichier sudoers. Cet événement sera signalé.\n"

msgid "%s is not allowed to run sudo on %s.  This incident will be reported.\n"
msgstr "%s n'est pas autorisé à exécuter sudo sur %s. Cet événement sera signalé.\n"

So, to change the message you need to specify for which language/locale? and edit the appropriate NLS file. However, the user may not be using a locale, so this will have no effect.


Alternatively, you can use a binary editor to replace the string in /usr/libexec/sudo/sudoers.so, where it occurs, by a string of exactly the same size and with the same number of %s parameters. As this will no longer match for gettext translation, it will apply to all locales. Eg

sed < /usr/libexec/sudo/sudoers.so 's/This incident will be reported/This incident WILL BE REPORTED/' >/tmp/sudoers.so
cmp -l /usr/libexec/sudo/sudoers.so /tmp/sudoers.so

Use cmp to ensure you haven't corrupted the file.

Tags:

Sudo