Skip to content

Instantly share code, notes, and snippets.

@dardo82
Last active June 8, 2023 22:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dardo82/433e6b7930c01cadfac0a772a27aae9f to your computer and use it in GitHub Desktop.
Save dardo82/433e6b7930c01cadfac0a772a27aae9f to your computer and use it in GitHub Desktop.
OSX sudo helper
#!/bin/sh
BIN="/usr/local/bin/askpass"; touch $BIN; chmod 755 $BIN
security add-generic-password -a $USER -s login -T "" -w
echo "#!/bin/sh\\nsecurity find-generic-password -a $USER -s login -w" > $BIN
echo "\\n# Set sudo helper.\\nexport SUDO_ASKPASS=$BIN" >> ~/.${SHELL##/*/}rc
@vishwas325
Copy link

vishwas325 commented Jun 19, 2022

Yes, that right. I am using sudo -A only. The issue is that security add-generic-password doesn't support a UI, i guess. So it's not useful for me because I don't want the user to execute mac-askpass.sh through terminal. I actually see another option in security to bypass sudo which is security execute-with-privileges. Have you worked with this option? Not much doc is mentioned on the man page related to what sort of privilege escalation does it provide? Some pointers to documentation?

@dardo82
Copy link
Author

dardo82 commented Jun 19, 2022

Have you tried searching on Google as I would do? 🧑‍💻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment