我应该使用什么样的API来提升用户权限的超级用户在Mac OS X的? [英] What kind of API should I use to elevate user privilege to super-user in a Mac OS X?

查看:222
本文介绍了我应该使用什么样的API来提升用户权限的超级用户在Mac OS X的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提升我的应用程序的权限的超级用户。
安装应用程序通过显示此对话框支持这一点。
我怎样才能显示此对话框来提升特权?

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。
我在做一种对我使用PCAP的lib Mac OS X的数据包嗅探器的应用。 (这是tcpdump的一部分)

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

推荐答案

<一个href=\"http://developer.apple.com/mac/library/documentation/Security/Reference/authorization_ref/Reference/reference.html\"相对=nofollow> AuthorizationExecuteWithPrivileges 与 kAuthorizationRightExecute

请参阅 BetterAuthorizationSample

作为一般规则,你不应该运行的GUI应用程序的根目录。你应该做一个命令行工具,你可以以root身份运行,并从用户空间GUI应用程序来控制它。

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.

这篇关于我应该使用什么样的API来提升用户权限的超级用户在Mac OS X的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆