嵌入式应用程序应以哪个用户身份运行?

发布于 2024-08-05 21:26:45 字数 247 浏览 4 评论 0原文

我们有一个嵌入式 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

濫情▎り 2024-08-12 21:26:45

如果对输入进行严格控制,那么在 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.

萌无敌 2024-08-12 21:26:45

我认为问题是:如果出现问题会发生什么?我认为该产品在任何情况下都会崩溃并挂起或行为不当? 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.

多像笑话 2024-08-12 21:26:45

如果应用程序是系统的主要部分,那么以 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.

黑色毁心梦 2024-08-12 21:26:45

这假设您正在运行 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.

旧人 2024-08-12 21:26:45

我会将代码分成几部分。为您的界面代码创建一个用户。您可以将其命名为“接口”。然后让它通过守护进程或 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文