替换嵌入式闪存上的 Linux 库的安全方法

发布于 2024-10-02 14:23:24 字数 132 浏览 2 评论 0原文

我有一个基于 Linux busybox 的片上系统。我想向现场用户提供更新,这需要更新 /lib /usr/bin 和 /etc 中的一些文件。我认为直接简单地解压文件并不安全。有没有一种安全的方法来执行此操作,包括可能正在使用的 /lib 文件?

I have a linux busybox based system on a chip. I want to provide an update to users in the field and this requires updating some files in /lib /usr/bin and /etc. I don't think that it's safe to simple untar the files directly. Is there a safe way to do this including /lib files that may be in use?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

温柔嚣张 2024-10-09 14:23:24

我在嵌入式系统中强烈喜欢的一些东西:

a) 让根文件系统是从闪存中的映像未压缩的 ramdisk。这很棒,因为您可以随心所欲地尝试使用它,如果搞砸了,您只需重新启动即可恢复到闪现的配置。当您测试了一组您喜欢的更改后,您将生成一个新的压缩根文件系统映像并将其刷新。

b) 使用引导加载程序(例如 u-boot)进行更新 - 刷新新的完整映像 - 而不是在 Linux 系统运行时尝试更改它。尽管由于刷新的副本不是实时的,您实际上可以在运行时刷新它。如果你刷入的是一个坏版本,u-boot 仍然可以刷出一个好的版本。

c) 具有 mask-rom UART(甚至 USB)引导加载程序的处理器,使系统不易变砖 - 只需一台笔记本电脑和串行电缆或 USB/串行转换器即可进行维护(即,获得一个工作的 u -闪存上的引导映像,然后使用它来获取工作的 Linux 内核+压缩的 root fs 映像)

Some things I strongly prefer in embedded systems:

a) Have the root file system be a ramdisk uncompressed from an image in flash. This is great because you can experimentally monkey around with it to your heart's content and if you mess up, all you need is a reboot to get back to the flashed configuration. When you have tested a set of change you like, you generate a new compressed root filesystem image and flash that.

b) Use a bootloader such as u-boot to do your updates - flashing a new complete image - rather than trying to change the linux system while it is running. Though since the flashed copy isn't live, you can actually flash it while running. If you flash a bad version, u-boot is still there to flash a good one.

c) Processors which have mask-rom UART (or even USB) bootloaders, making the system un-brickable - nothing more than a laptop and a serial cable or usb/serial converter is ever needed to do maintenance (ie, get a working u-boot image on the flash, which you then use to get a working linux kernel+compressed root fs image on it)

终陌 2024-10-09 14:23:24

理想情况下,您的闪存设备足够大,可以分区为两个完整的文件系统,并且每次更新都会更新另一侧(如果需要,还可以复制配置文件)并更新启动配置以从更新的一侧启动。

不太理想的是就地更新,但有一些检测启动失败的方法(例如,直到启动后才触及看门狗),并有一个较小的后备分区,能够接受另一个更新并修复主分区。

至于实时文件系统的就地更新,只需使用真正的安装程序(它将在替换目标文件之前将其移开,以避免您描述的问题)。

Ideally your flash device is big enough to partition into two complete filesystems and each update updates the other side (plus copying over config files if necessary) and updates the boot configuration to boot from the updated side.

Less ideal is to update in-place but have some means of detecting boot failure (watchdog that's not touched until after boot, for example) and have a smaller, fallback partition which is capable of accepting another update and fixing the primary partition.

As far as the in-place update of a live filesystem, just use a real installer (which will move the target files out of the way before replacing them to avoid the problem you describe).

何以心动 2024-10-09 14:23:24

您在上面收到了两个很好的答案,我强烈鼓励您按照建议去做。

然而,还有一种更简单的方法。事实上,您可以直接解压您的库,前提是执行此操作的进程是静态链接的。

You received two excellent answers above and I Strongly encourage you to do what you were advised to.

There is, however, a more simple way. In a matter of fact you can just untar your libraries, provided that the process that does this is statically linked.

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