如何下运行root权限的应用程序? [英] How to running application under root privilege?
本文介绍了如何下运行root权限的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请告诉我的方式授予我的应用程序修改/库/字体文件夹中添加新的和删除字体文件。
先谢谢了。
Please tell me a way grant for my application to modify /Library/Fonts folder as add new and remove font file. Thanks in advance.
推荐答案
- 您可以将您的应用程序分为两部分:服务(守护进程)和用户界面,并通过安装程序的方式安装它们让你的服务将有root权限
- 您可以使用
AuthorizationExecuteWithPrivileges()
从您的应用程序运行一些命令,但它是pcated德$ P $。还是它的工作原理 - 您可以通过
NSAppleScript
使用做外壳脚本\\一些脚本\\以管理员权限运行一些命令。但它更像是一个黑客和<一个href=\"http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Multithreading/Introduction/Introduction.html\"相对=nofollow>苹果文档说NSAppleScript
类必须只能从应用程序的主线程中使用。但是,它也能工作,并亲自我没有与任何麻烦。 - 您可以创建的辅助工具,并使用
ServiceManagement.framework
和SMJobBless()
- 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()
您可以找到一些额外的信息<一个href=\"http://stackoverflow.com/questions/6841937/authorizationexecutewithprivileges-is-de$p$pcated\">here和<一个href=\"http://stackoverflow.com/questions/6161602/how-can-a-console-application-sudo-itself-under-os-x-if-it-needs-root-privilege?rq=1\">here
You can find some additional info here and here
这篇关于如何下运行root权限的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文