Remove Applications from Location Services in Security & Privacy on Mac OS X 10.8
I wanted to remove applications from location services in the security and privacy settings on MaC OS X 10.8 Mountain Lion. (The apps were still listed even though they were uninstalled.) I found the post Remove application from Location Services in Security & Privacy on Mac OS X 10.7, and that got me going in the right direction. Here is the OS X 10.8.2 Mountain Lion equivalent that worked for me. The main difference is the location of the clients.plist file. I also wanted to provide a step-by-step process.
DISCLAIMER: This worked for me. Make sure you have a good backup of your system. This process includes making a backup of the clients.plist file, but one can never be too safe.
1. Start terminal and then sudo to a root shellsudo -s
2. Go to /var/db/locationdcd /var/db/locationd
3. Make a backup of the clients.plist filecp -p clients.plist clients.plist.save
4. Convert clients.plist to xml (editable format)plutil -convert xml1 clients.plist
5. Use vi (vim) to edit the clients.plist file and remove the application.vi clients.plist
The file will likely contain many application entries. Here is the format of a single application entry (Safari in this case). The entire entry needs to be deleted.
<key>com.apple.Safari</key>
<dict>
<key>Authorized</key>
<true/>
<key>BundleId</key>
<string>com.apple.Safari</string>
<key>Executable</key>
<string>/Applications/Safari.app/Contents/MacOS/Safari</string>
<key>LocationTimeStopped</key>
<real>376348187.80421197</real>
<key>Registered</key>
<string>/Applications/Safari.app/Contents/MacOS/Safari</string>
<key>RequirementString</key>
<string>identifier "com.apple.Safari" and anchor apple</string>
<key>Whitelisted</key>
<false/>
</dict>
6. Convert the clients.plist file back to binaryplutil -convert binary1 clients.plist
7. Restart locationdkillall locationd
If the apps are still there, do the process again, except restart locationd using kill -9 after determining the PID as follows. The PID is the second field in the ps output.
ps -ef | grep locationd | grep -v grep
Output: 205 427 1 0 6:31PM ?? 0:00.07 /usr/libexec/locationd
kill -9 427
I ran the process twice to remove one app at a time. The first time, killall was sufficient. The second time, it was not. I do not know why. It acted like locationd was keeping a cache and rebuilding clients.plist. I say this because the entries were added back to clients.plist after running killall -- and even on a reboot. Whatever the root cause, using kill -9 solved the problem for me.
If things go badly, then copy back the original file and restart locationd.cp -p clients.plist.save clients.plist
killall locationd
(or the kill -9 method)
I hope this helps. Cheers!
Xcode's property list editor can also be used to delete old apps' entries, but since the file is hard to get to, permissions have to be temporarily opened:
mini-nevie:~ root# chmod o+rwx /var/db/locationd/ /var/db/locationd/clients.plist
so the directory and file can be read and written by all users. Then, for convenience, su to your login ID:
mini-nevie:~ root# su - nevinwilliams
mini-nevie:~ nevinwilliams$ open /var/db/locationd/clients.plist
This assumes Xcode is the default app for opening *.plist files, and you're familiar with the Property List Editor. Under the Root property, there are 3 default Dictionary entries:
com.appl
com.appl.locationd.executable-/usr/libexec/UserEventAgent
com.appl.aosnotifyd
Those ought not to be removed. For entries that belong to long-gone apps, you can hover just to the left of the Dictionary column of the corresponding app's row, where an inverse grey '-' will appear. Clicking on it will remove the item, and all its children. If you'd rather inspect the entry first, clicking on the grey triangle (familiar to Finder list-view users) to the left of the key string will expand the Dictionary and display its elements.
Once you delete or disable the keys to your satisfaction, save the file, and quit Xcode. Then, back in Terminal, do:
mini-nevie:~ nevinwilliams$ exit
logout
mini-nevie:~ root#
hit the up-arrow twice to recall the chmod command, ctrl-A to go to the beginning of the line, cursor-right about eight times, change the '+' to a '-', or enter the following as shown to restore permissions to what they were:
mini-nevie:~ root# chmod o-rwx /var/db/locationd /var/db/locationd/clients.plist
then HUP the location daemon:
mini-nevie:~ root# killall -HUP locationd
a quick check of the Security.PrefPane Privacy tab ought to confirm your changes.
Standard disclaimers, cautionary tales of woe, scoldings, cluckings, and "Is This Trip Really Necessary?" reflections are especially applicable.
Using tccutil (OS X Command Line utility)
I think the fastest and safest way to do this, is by the OS X command line utility tccutil
- Open a new terminal window
- Close any open "Security & Privacy" prefpane windows
- Type or paste from the following highlighted commands
Reset the Location services
tccutil reset CoreLocationAgent
Reset access to contacts/address book:
tccutil reset AddressBook
Reset access to Reminders
tccutil reset Reminders
Reset access to Calendars
tccutil reset Calendar
And that´s all there is to it. No Sudo needed, by the way.