Please tell me a way grant for my application to modify /Library/Fonts folder as add new and remove font file. Thanks in advance.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- You can split your application into two parts: service(daemon) and UI and install them via installer in the way so your service will have root privileges
- You can run some command from your app using
AuthorizationExecuteWithPrivileges()
but it is deprecated. Still it works - You can run some command via
NSAppleScript
using "do shell script \"some script\" with administrator privileges". But it more like a hack and apple documentation says thatNSAppleScript
class must be used only from the main thread of an application. But it works too, and personally I don't have any troubles with that. - You can create helper tool and use
ServiceManagement.framework
andSMJobBless()
You can find some additional info here and here