3
votes

With AuthorizationExecuteWithPrivileges deprecated in 10.7, what is an alternative to programatically running commands like launchctl, chmod, chown, etc... as root? I need to support 10.5 so SMJobBless isn't an option.

Here's the use case. I'm generating a plist for a LaunchDaemons daemon at runtime and need to copy the daemon and plist to their appropriate locations and use launchctl to unload/load the plist

Am I correct in understanding I need root to perform these actions?

1
You need to write your code to detect the O/S version, or detect which APIs are available through introspection, and use those APIs that are available. You can rarely write a one size fits all application without using this technique. - trojanfoe
"Deprecated" doesn't mean "non functional". If you need to support 10.5, use a method that works for 10.5 - JeremyP
Deprecated doesn't mean non functional but Apple has a tendency to deprecate then eventually completely kill all support and I would like to have to code the solution for this as few times a possible - cppguy

1 Answers

0
votes

You can use applescript

do shell script "sh /Users/new/load.sh" with administrator privileges