I ended up creating a Bash script named sudo:
#!/usr/bin/env bash set -e console="$(tty)" readonly console /path/to/real/sudo -v # Sudo normally writes directly to the terminal device instead of # writing to stdout, so that’s what I’m doing here echo "AccessAccess granted." &> "$console" /path/to/real/sudo "$@" Then, I set my PATH to "/path/to/fake/sudo/dir:$PATH". There are a few limitations to this solution:
- It won’t work properly if credential caching is disabled.
- It will always prompt you forIf your passwordcredentials aren’t cached, even if you’re runningthen
sudo --helporsudo -kwill prompt for a password.