Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Add trusted realms to Chrome and Firefox configs
- # 2013-09-03 @jestr
- #
- ### REPLACE "yourRealm" with your realm! ###
- #
- currentUser=`ls -l /dev/console | awk {' print $3 '}`
- prefExists=`cat /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js | grep "network.negotiate"`
- twPrefExists=`cat /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js | grep "network.negotiate" | grep "yourRealm"`
- isFirefoxRunning=`ps ax | grep "Firefox" | grep -v "+"`
- # Add realm to Chrome
- if [ ! -f /Users/"$currentUser"/Library/Preferences/com.google.Chrome.plist ]; then
- touch /Users/"$currentUser"/Library/Preferences/com.google.Chrome.plist
- fi
- defaults write /Users/"$currentUser"/Library/Preferences/com.google.Chrome AuthServerWhitelist "yourRealm"
- chown "$currentUser":staff /Users/"$currentUser"/Library/Preferences/com.google.Chrome.plist
- # Add/append realm to Firefox
- if [[ $isFirefoxRunning ]]; then
- osascript <<AppleScript
- tell application "Finder"
- activate
- display dialog "Firefox is currently running. Firefox must be quit and this policy must be reinitiated for your browsing sessions to be trusted." default button "OK"
- end tell
- AppleScript
- exit 1
- elif [[ $prefExists != "" && $twPrefExists == "" ]]; then
- existingRealms=`cat /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js | grep "network.negotiate"| cut -d '"' -f 4`
- updatedRealms="$existingRealms, yourRealm"
- grep -v "network.negotiate" /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js > /tmp/tempKerbFile.js
- echo 'user_pref("network.negotiate-auth.trusted-uris", "'$updatedRealms'");' >> /tmp/tempKerbFile.js
- mv /tmp/tempKerbFile.js /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js
- elif [[ $prefExists == "" ]]; then
- cat /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js > /tmp/tempKerbFile.js
- echo 'user_pref("network.negotiate-auth.trusted-uris", "yourRealm");' >> /tmp/tempKerbFile.js
- mv /tmp/tempKerbFile.js /Users/$currentUser/Library/Application\ Support/Firefox/Profiles/*.default/prefs.js
- else
- exit 0
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement