문제

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