Is it possible, on Linux or on BSD systems, to customize the sudo "this incident will be reported" message? I've gone over man sudo and man sudoers on an Ubuntu 16.04 machine, a FreeBSD 10.2 machine, and a Fedora 23 machine, and I haven't found anything useful.


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.

  • 12
    Ah, the beauty of open source. Don't like something? Change it yourself!
    – phyrfox
    May 12 '16 at 16:48
  • 4
    "Change sudo!" but I don't know how! "sudo change sudo!" okay.
    – user541686
    May 13 '16 at 6:20

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.

  • Surely we can make it a different length by recompiling sudo?
    – gerrit
    May 12 '16 at 13:46
  • @gerrit yes, the best solution would be to edit the source and recompile the program.
    – meuh
    May 12 '16 at 14:24
  • 3
    You could make the message shorter by padding with nul characters, since C uses nul-terminated strings. May 13 '16 at 2:44
  • @NateEldredge Good point.
    – meuh
    May 13 '16 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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