Enable Location Service with SIP

anverhousseini
Contributor II

Hi Jamf Nation

I'm trying to programmatically enable the location service. I have done this so far:

#!/bin/bash

/usr/bin/defaults write "/var/db/locationd/Library/Preferences/ByHost/com.apple.locationd" LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd "/var/db/locationd"

exit 0

As since macOS 10.12.2 SIP does not allow to reload the com.apple.locationd.plist LaunchDaemon a reboot is necessary. But it does not even work after a reboot. I do have enabled Wi-Fi.

Any ideas?

5 REPLIES 5

r0blee
New Contributor III

Not sure why you’re having issues to be honest as I’ve not tested what you’re doing but if you want to reload launch daemons or agents without rebooting you should be able to do this in the command line as the root user and by running this;

launchctl unload -w /path/to/launchdaemon

Then to reload it:

launchctl load -w /path/to/launchdaemon

If you want to check a launch daemon is running then as the root user run this:

launchctl list

Hopefully that at least helps in some way.

Rob

MTFIDjamf
Contributor II

@anverhousseini The post below might help you out.

Enable Location Services

StoneMagnet
Contributor III

anverhousseini
Contributor II

@r0blee It is not possible to reload LaunchDaemons which are protected by SIP since 10.12.2

@StoneMagnet Thank you, I already saw that thread, but this doesn't work anymore.

r0blee
New Contributor III

@anverhousseini good shout. With the exception of the updatesettings launch daemon the rest are indeed protected in /System/Library/LaunchDaemons/