How to copy a plugin in a system location sorting out root privileges


#1

I'm trying to elevate my app's privileges, to write some audio plugins to a system locations: (/Library/Application Support/Digidesign/Plug-Ins) and  (/Library/Audio/Plug-ins/VST3).  I am trying to do this in C on OSX.

After "Elevating Privileges Safely" doc from Mac Developer Library, there are several ways to do it, none of them easy at all.

One of them is forking a child process that uses authopen to create and write to a file. After several hours figuring out why XCode does not like to debug, even to run the child process, I've abandoned. The other method suggested by Apple is launchd which is harder at first sight.

So, my question is: does anybody have an 'off-the-shelf' solution example to copy a plugin file in the proper system location elevating privileges?

Desperately yours,

Gabriel


#2

You can use the function AuthorizationExecuteWithPrivileges. This will bring up a password dialog and then let you execute any process or script with elevated privileges on OSX. See Google for code examples.

The function is deprecated, but seems to be still working fine (and I doubt they remove it any time soon, since a lot of existing code relies on it). The "proper" Apple way however is nowadays to set up a privileged helper tool using launchd and SMJobBless, which involves quite some effort.

There is also another function in the ServiceManagement framework called SMJobSubmit, which can be "misused" to execute code with elevated privileges.

Whether it's a good idea to use any of this stuff is another topic ;-)


#3

Hi Timur,

First of all, allow me congratulate you for belonging to the privileged group of Jules.

On the other hand, thank you for giving me such piece of advise. I was deeply afraid about deprecated functions in OSX, but I see that the alternatives are not easy nor embraced by the community.

So, you gave a clue to investigate and I found this 'promising jewel' I would like to share in this forum:

https://bitbucket.org/sinbad/privilegedhelperexample

I'll reply with the results

Gabriel