News for hackers. Stuff that matters.
Re:Use Touch ID for Sudo on Mac by beyondcompute on Monday March 01, 2021 @09:43AM (#26303170)
I’ve just added this to my .bash_profile:

  enable-sudo-touchid() {
    sudo sed -i -e '1s;^;auth       sufficient     pam_tid.so\n;' /etc/pam.d/sudo
  }
But probably automating the check (if the automated checker has the correct permission) would not be that hard.
Re:Use Touch ID for Sudo on Mac by jmarcher on Monday March 01, 2021 @11:55AM (#26304832)
A step further so you don't have to think about enabling it:

  sudo() {
    unset -f sudo
    if [[ "$(uname)" == 'Darwin' ]] && ! grep 'pam_tid.so' /etc/pam.d/sudo --silent; then
      sudo sed -i -e '1s;^;auth       sufficient     pam_tid.so\n;' /etc/pam.d/sudo
    fi
    sudo "$@"
  }
Re:Use Touch ID for Sudo on Mac by mkskm on Monday March 01, 2021 @05:26PM (#26309309)
Here's another function in Fish that incorporates the other suggestions offered in this thread.

    function sudo --description "Execute a command as another user."
        if [ (uname) = "Darwin" ]
            set --local needle "^auth\b.*\bpam_\(reattach\|tid\|watchid\)\.so\$"
            if ! grep $needle --silent /etc/pam.d/sudo && \
                [ -f /usr/local/lib/pam/pam_reattach.so* ] && \
                [ -f /usr/local/lib/pam/pam_watchid.so* ]
            command sudo sh -c "
            cat << EOF >/etc/pam.d/sudo
    auth optional pam_reattach.so
    auth sufficient pam_tid.so
    auth sufficient pam_watchid.so
    \$(grep -v '$needle' /etc/pam.d/sudo)
    EOF"; or return $status
            end
        end
        command sudo $argv
    end
Re:Use Touch ID for Sudo on Mac by beyondcompute on Monday March 01, 2021 @01:00PM (#26305791)
Thanks! That looks good!

Thought on the second thought, I’ll continue to use the more “manual” method for now. As it gives me more control and it would be easier to switch off when touch ID sudo will be supported more officially.

Re:Use Touch ID for Sudo on Mac by ed25519FUUU on Monday March 01, 2021 @10:48AM (#26303894)
The hard part with these kinds of fixes is that they evaluate every time you create a new shell or tab, which for me is very frequently.

It’s already starting to add noticeable latency from all of the various eval statements in there.

Edit: I missed it’s a function def which should be fine speed wise.

Re:Use Touch ID for Sudo on Mac by fwip on Monday March 01, 2021 @11:05AM (#26304115)
That's a function definition, the only overhead will be parsing, not evaluation.
Re:Use Touch ID for Sudo on Mac by ethanpil on Monday March 01, 2021 @03:54PM (#26308259)
Why not run a launchd script on boot that does the update? Does it need to be in the .bashrc?