What kind of API should I use to elevate user privilege to super-user in a Mac OS X?

折月煮酒 提交于 2020-01-13 14:57:08

问题


I want to elevate my app's privilege to super-user. Installer app supports this by displaying this dialog. How can I show this dialog to elevate privilege?

PS. I'm making a kind of packet sniffer application on Mac OS X. I'm using pcap lib. (which is part of tcpdump)


回答1:


AuthorizationExecuteWithPrivileges with kAuthorizationRightExecute

See BetterAuthorizationSample

As a general rule, you should not run GUI applications as root. You should make a command line tool that you can run as root, and control it from your user space GUI application.



来源:https://stackoverflow.com/questions/3123055/what-kind-of-api-should-i-use-to-elevate-user-privilege-to-super-user-in-a-mac-o

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!