Created
August 18, 2014 00:14
-
-
Save pudquick/43a3797e9af3ed36b4fc to your computer and use it in GitHub Desktop.
An example of using execute-with-privileges verb of security command to bypass GUI for a CLI authorization prompt
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
# This expects that you're already running as sudo'd / root account | |
cat <<EOF | security -i | |
authorize -C adminUserNameHere com.apple.uninstalld.uninstall | |
execute-with-privileges /usr/sbin/uninstall /Applications/SomeMASapp.app | |
EOF | |
# In the example above, if you're already running as root / sudo'd admin, | |
# you still get a prompt for the password of the account in question. | |
# We aren't dodging proving we know the password - we're just doing it | |
# via the CLI instead of via the Authorization GUI dialog. | |
# Here's an alternate form where you're not sudo'd already: | |
cat <<EOF | sudo security -i | |
authorize -C adminUserNameHere com.apple.uninstalld.uninstall | |
execute-with-privileges /usr/sbin/uninstall /Applications/SomeMASapp.app | |
EOF | |
# In this version, you'll actually get prompted for a password twice - | |
# the first time for sudo, the second time for authorization |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment