forked from macadmins/escrow-buddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Removal
Bartłomiej Sojka edited this page Oct 9, 2024
·
1 revision
If you no longer need or wish to use Bootstrap Buddy, you can remove it by deploying the uninstall script provided below:
#!/bin/bash
AuthDBTeardown() {
# Create temporary directory for storage of authorization database files
# Using hyphen to prevent escape issues in PlistBuddy commands
BB_DIR="${TMPDIR:=/private/tmp}/com.inetum.Bootstrap-Buddy"
mkdir -pv "$BB_DIR"
AUTH_DB="$BB_DIR/auth.db"
# Output current loginwindow auth database
echo "Reading system.login.console section of authorization database..."
/usr/bin/security authorizationdb read system.login.console > "$AUTH_DB"
if [[ ! -f "$AUTH_DB" ]]; then
echo "ERROR: Unable to save the current authorization database."
exit 1
fi
# Check current loginwindow auth database for desired entry
if ! grep -q '<string>Bootstrap Buddy:Invoke,privileged</string>' "$AUTH_DB"; then
echo "Bootstrap Buddy is not configured in the loginwindow authorization database."
return
fi
# Create a backup copy
cp "$AUTH_DB" "$AUTH_DB.backup"
echo "Removing Bootstrap Buddy from authorization database..."
INDEX=$(/usr/libexec/PlistBuddy -c "Print :mechanisms:" "$AUTH_DB" 2>/dev/null | grep -n "Bootstrap Buddy:Invoke,privileged" | awk -F ":" '{print $1}')
if [[ -z $INDEX ]]; then
echo "ERROR: Unable to index current loginwindow authorization database."
exit 1
fi
# Subtract 2 from the index to account for PlistBuddy output format
INDEX=$((INDEX-2))
# Remove Bootstrap Buddy mechanism
/usr/libexec/PlistBuddy -c "Delete :mechanisms:$INDEX" "$AUTH_DB"
# Save authorization database changes
if ! security authorizationdb write system.login.console < "$AUTH_DB"; then
echo "ERROR: Unable to save changes to authorization database."
exit 1
fi
}
# If in-bundle AuthDB teardown script exists on disk, prefer using that
echo "Removing Bootstrap Buddy from authorization database..."
"/Library/Security/SecurityAgentPlugins/Bootstrap Buddy.bundle/Contents/Resources/AuthDBTeardown.sh" || AuthDBTeardown
echo "Deleting Bootstrap Buddy bundle..."
rm -rf "/Library/Security/SecurityAgentPlugins/Bootstrap Buddy.bundle"
echo "Deleting Bootstrap Buddy preferences..."
defaults delete "/Library/Preferences/com.inetum.Bootstrap-Buddy.plist"
echo "Forgetting receipt..."
pkgutil --forget "com.inetum.Bootstrap-Buddy" 2>/dev/null
echo "Bootstrap Buddy successfully uninstalled."