If you have the pleasure of binding your macOS fleet to Active Directory some of you may have noticed issues using the sudo command for administrative users.
Chatter on the MacAdmins slack channel suggests that Apple has acknowledged the issue and will resolve it in a future update. Here’s how we’re temporarily working around this:
#!/bin/bash # Collects the logged in user loggedInUser="$(stat -f%Su /dev/console)" # Checks to ensure logged in user isn't already in sudoers if grep -Rq "$loggedInUser" /etc/sudoers then echo "User ID already exists in sudoers file...Exiting" else echo "$loggedInUser ALL = (ALL) ALL" >> /etc/sudoers fi
Short and sweet. Run as root.