Tiny Deathstars of Foulness

Awhile back I did a little article on Bluetooth. I also did an article on disabling menu items such as Bluetooth, using Managed Preferences. But I hadn’t looked at granular controls of Bluetooth settings. Luckily, a user submission on the topic just came in and Ted Kidd from Michigan (thanks, Ted!). Ted has provided a script for disabling Bluetooth’s Discoverable mode. His submission:
I’ve found that more than a fair share of preferences are stored for each specific user on a computer. I’ve also found that some preferences are stored in a “ByHost” folder in /Users//Library/Preferences. Anything stored in the ByHost folder has the hardware UUID in the plist file name. /usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c20-57 This line will pull the hardware UUID number so that it can be used in a defaults read/write script or something like that. You probably already know this, but it seems like a good tip to include on a website. I needed to do this to turn off “Discoverable” mode for bluetooth. defaults write /Users/<user>/Library/Preferences/ByHost/`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57` DiscoverableState -bool no launchctl unload /System/Library/LaunchDaemons/ launchctl load /System/Library/LaunchDaemons/ If using in a login script (via managed prefs), it would look like this: uuid=`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57` /usr/bin/defaults write /Users/$@/Library/Preferences/ByHost/$uuid DiscoverableState -bool no /usr/sbin/chown $@ /Users/$@/Library/Preferences/ByHost/$uuid.plist This script will turn discoverablestate to “off” and relaunch the bluetooth service.

September 23rd, 2011

Posted In: Mac OS X, Mac OS X Server, Mac Security, Mass Deployment

Tags: , , , , , , ,

  • Shane Palmer

    It might be safer to use the defaults command’s built-in ability to deal with ByHost files. So the command would be:

    defaults -currentHost write DiscoverableState -bool no

    This will write to the current logged in user’s in their ByHosts folder.

    This makes the script a little simpler and guarantees that it will work on both newer Macs that use the UUID and older Macs (PowerPC and early Intel based Macs) that use the MAC address in the name of the ByHost files.