Repository navigation
.macos: Touch ID for sudo, and one touch for everything - #98
Merged
Merged
Conversation
Touch ID goes through /etc/pam.d/sudo_local, Apple's update-proof hook, created from the template beside it or appended to. On its own it made things worse for anything that runs sudo once per step from fresh processes: sudo caches a tty-less authorisation per parent process, so an Ansible run raised ten Touch ID prompts. A global timestamp in /etc/sudoers.d/timestamp makes one touch cover every sudo on the machine; the file is validated by visudo before it is installed at 0440, and the 60-minute timeout is a preference behind SUDO_TIMESTAMP_TIMEOUT. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…e it /etc/sudoers.d/timestamp is installed root:wheel 0440, so an unprivileged grep on it dies with "Permission denied". In .macos the -s flag hid that: the check always came back false and the file was reinstalled on every run, the opposite of the "left alone otherwise" the comment promises. In tests/macos-apply.bats the same grep failed loudly, which is how the macOS CI job caught it. Both reads now go through sudo — already live in .macos from the upfront sudo -v, and -n in the test like the visudo check beside it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
/etc/pam.d/sudo_local(Apple's hook that survives OS updates): created from the template when missing, appended when present without the line, untouched otherwise. Never writes/etc/pam.d/sudo./etc/sudoers.d/timestampsetsDefaults timestamp_type=global(the fix) andtimestamp_timeout=60(a preference,$SUDO_TIMESTAMP_TIMEOUToverrides). The file is generated to a temp path, validated withvisudo -cfthere, and only then installed at0440 root:wheel; a rejected file never reachessudoers.d. Idempotent, including repairing a wrong mode.Tests
tests/macos.bats: two static checks (sudo_local not/etc/pam.d/sudo; validate-before-install at 0440).tests/macos-apply.bats(macOS CI runner,MACOS_APPLY_OK=1): the line is insudo_local, the sudoers file parses and is in effect, and a second.macosrun changes nothing.Verified on a Mac:
visudo -cfvalidates a temp file as a normal user and rejects a bad one; BSD grep/sed on the real template.🤖 Generated with Claude Code