How do I run the application as root?
1 answer
- You can split the application into two parts, the service (daemon) and the user interface, and install them through the installer so that your service has root privileges.
- You can execute some command from your application with
AuthorizationExecuteWithPrivileges()
, but it is deprecated. Still it works - You can execute some command with using the
NSAppleScript
command "do shell script \" some script \ "with admin rights". But this is more like a hack and the Apple documentation says the classNSAppleScript
should only be used from the main thread of the application. But it works too and personally I have no problem with that. - You can create a helper tool and use
ServiceManagement.framework
andSMJobBless()
+1
source to share