强制GUI应用程序以root身份运行 [英] Forcing a GUI application to run as root

查看:206
本文介绍了强制GUI应用程序以root身份运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我准备在OS X上部署应用程序.这是我第一次在此平台上编写需要root权限才能正常运行的应用程序,因此我需要为每次启动尝试都集成该功能.

I'm getting ready to deploy an app on OS X. This is the first time I've written an application on this platform which requires root permissions to run properly, so I need that functionality integrated for every startup attempt.

应用程序本身是用Python 2.7编写的,然后使用PyInstaller编译为二进制.到目前为止,我已经尝试过:

The application itself is written in Python 2.7, and then compiled to binary using PyInstaller. So far, I've tried:

  • 使用sudo pyinstaller -w --icon=/path/to/icon /path/to/script.py

使用sudo su

我现在不知道还能尝试什么.使用符号链接可以实现这一目标吗?

I don't know what else to try at this point. Is it something that could be achieved using symlinks?

推荐答案

Apple建议不要以root用户身份运行GUI应用程序,因为此类应用程序中包含的库会增加恶意软件的攻击媒介.

Apple recommend that no GUI applications run as root, as the libraries that are included in such applications increase the attack vector for malware.

相反,建议将您的代码重构为两部分,即Gui和具有根权限的单独的辅助应用程序.

Instead, it is recommended to refactor your code into two parts, the Gui and a separate helper app, which is given root privileges.

有一个示例应用程序此处.

这篇关于强制GUI应用程序以root身份运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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