You can βinvalidateβ sudo permission (actually: close the sudo time window early):
sudo -k
In addition, you can configure sudo only for permissions to certain commands, or even to impersonate non-root for certain commands. See man sudoers . The examples section makes it extremely obvious that there are practically no restrictions on the configurability of sudo (roles, hosts, commands, screening permission, allow suudo users, exceptions for allowed things, password is less than authorization, etc. Etc.).).
Hope an interesting example in your context:
User fred can run commands like any user in DB Runas_Alias ββ(oracle or sybase) without specifying a password.
fred ALL = (DB) NOPASSWD: ALL
If you cannot / do not want to interfere with / etc / sudoers (visudo!), Then I suggest using something like
{ trap "sudo -k" EXIT INT QUIT TERM sudo ls
sehe
source share