嵌入式应用程序应以哪个用户身份运行?
我们有一个嵌入式 Linux 产品,其应用程序允许用户通过菜单系统更改不同的设置。这些设置包括 IP 地址/DHCP 和时间。
我们现在以 root 身份运行此应用程序,但这感觉不对,让用户直接与以 root 身份运行的进程交互。
我们应该使用哪个用户?
如果不是root,我们如何解决出现的权限问题呢?
编辑: 该产品没有经典 Gnome/KDE 风格的图形用户环境。提到的菜单系统是在产品本身的液晶面板上实现的。
We have an embedded linux product with an application which lets the user change different settings through the menu system. These settings include IP address/DHCP and time.
We now run this application as root but this feels wrong, letting the user directly interact with a process run as root.
Which user should we use?
If not root, how do we accomplish the permission issues that arise?
EDIT:
The product does not have a graphical user environment in the classical Gnome/KDE fashion. The menu system mentioned is implemented on an LCD panel on the product itself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果对输入进行严格控制,那么在 Linux 上以 root 身份运行嵌入式应用程序并没有什么问题。
无论如何,当底层操作系统类似于 VxWorks 时,应用程序也会以最大权限运行。
If strict controls are applied to input, there is nothing wrong to run an embedded application as root on Linux.
Anyway, when the underlying OS is something like VxWorks, applications run with maximum privileges as well.
我认为问题是:如果出现问题会发生什么?我认为该产品在任何情况下都会崩溃并挂起或行为不当? root 与普通用户的概念实际上仅适用于非 root 无法防范的情况……如果您拥有的只是固定的 UI,则情况似乎并非如此。
I think the question is: what would happen if something goes wrong? I assume the product would just crash and hang or misbehave in any case? The concept of root vs regular user really only applies if there is something that not being root can protect against... which if all you have is a fixed UI does not seem to be the case.
如果应用程序是系统的主要部分,那么以 root 身份运行它是有意义的。
然而,即使有一些额外的工作,将应用程序与 GUI 分离也是值得的,这样 GUI 就可以作为普通用户运行。
这还可以帮助您自动化测试。
If the application is the main part of the system, then it makes sense to run it as root.
However, even if there is some extra work, it is worthwhile to uncouple your application with your GUI, so your GUI can run with as a normal user.
This can also help you automate your tests.
这假设您正在运行 GNOME。
1) 执行“用户和组”程序的操作。它允许您查看当前设置,但要求您解锁高级设置,例如管理其他用户。
2) 广泛使用gksu。
This assumes that you're running GNOME.
1) Do what the program "Users and Groups" does. It allows you to see the current settings but requires you to unlock the advanced settings such as managing other users.
2) Use gksu extensively.
我会将代码分成几部分。为您的界面代码创建一个用户。您可以将其命名为“接口”。然后让它通过守护进程或 sudo 调用 root 来实际执行需要 root 的更改。限制访问权限,以便仅可以运行批准的命令。
I would split the code into parts. Create a user for your interface code. You could name it "interface." Then have it call into root via a daemon or sudo to actually execute the changes that require root. Limit the access so that only approved commands can be run.