質問

I'm writing an app that needs to overwrite a read-only file. Specifically the /etc/hosts file. To do that I need to ask for permission from the user to get root access and thereby permission to overwrite the hosts file.

I have searched all over the internet, but I have not been able to understand how to do this. I realize that a method called AuthorizationExecuteWithPrivileges() used to be used for this, but that it is deprecated in OSX 10.7. Then I came across something called SMJobBless, but I really didn't understand the concept of that?

So can you explain how to solve my problem the right way?

Regards, Rasmus

役に立ちましたか?

解決

http://atnan.com/blog/2012/02/29/modern-privileged-helper-tools-using-smjobbless-plus-xpc/

SMJobBless + XPC is a os x 10.7+ solution for what you require.

The provided link contains source code showing examples too.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top