Created
June 23, 2022 13:05
-
-
Save bojan/e97cd8a86764b8db00ea7b512d4064ef to your computer and use it in GitHub Desktop.
sudo with Touch ID support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Original idea: | |
# https://github.com/SladeGetz/MacM1_SudoTID/blob/main/sudo_tid.sh | |
# | |
# Check if we are running as a superuser (ID should be 0). | |
user_id=`id -u` | |
if [[ $user_id -ne 0 ]] | |
then | |
echo "ERROR: You need to run this command using as a superuser (sudo)!" | |
exit 1 | |
fi | |
filename="/etc/pam.d/sudo" | |
# Parse the PAM sudo configuration for Touch ID support. | |
if grep -q "pam_tid.so" $filename | |
then | |
# We do nothing if it has already been configured. | |
echo "Touch ID has been already configured, no need to change anything!" | |
else | |
# Or insert the configuration string on top of the other methods (right after the first commented out line). | |
sed -i '' '1a\ | |
auth sufficient pam_tid.so\ | |
' $filename | |
# Show a message or error after we try to update the file. | |
if [[ $? -eq 0 ]] | |
then | |
echo "Touch ID successfully set!" | |
else | |
echo "ERROR: Touch ID could not be integrated!" | |
exit 1 | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment